prefer lineX when Y is monotonic, lineY when X is monotonic, for better tooltips#1558
Conversation
…ut when not sure, default to line (whereas area defaults to areaY). closes #1547
00b176f to
c26e64d
Compare
|
Sorry this is not ready yet. |
| markImpl = | ||
| X && Y // same logic as area (see below), but default to line | ||
| ? yZero | ||
| ? lineY | ||
| : xZero || isMonotonic(Y) | ||
| ? lineX | ||
| : isMonotonic(X) | ||
| ? lineY | ||
| : line | ||
| : X // 1d line by index | ||
| ? lineX | ||
| : lineY; |
There was a problem hiding this comment.
If both x and y are monotonic, and neither xZero nor yZero are specified, I think we should default to lineY rather than lineX. If this works, I think I’ll push this:
| markImpl = | |
| X && Y // same logic as area (see below), but default to line | |
| ? yZero | |
| ? lineY | |
| : xZero || isMonotonic(Y) | |
| ? lineX | |
| : isMonotonic(X) | |
| ? lineY | |
| : line | |
| : X // 1d line by index | |
| ? lineX | |
| : lineY; | |
| markImpl = | |
| X && Y // same logic as area (see below), but default to line | |
| ? yZero || isMonotonic(X) | |
| ? lineY | |
| : xZero || isMonotonic(Y) | |
| ? lineX | |
| : line | |
| : X // 1d line by index | |
| ? lineX | |
| : lineY; |
mbostock
left a comment
There was a problem hiding this comment.
Looks good to me with the latest commit I pushed, but I can re-review if there’s something else I missed! 🙏
|
I'm testing it with #1546, and it looks good for lines with two channels. However I don't like that autoLineHistogram is using lineX (not a new thing); it's specified in the 1d line by index part, and it seems we must reverse lineX and lineY here. |
| ? lineX | ||
| : lineY; |
There was a problem hiding this comment.
per the above comment:
| ? lineX | |
| : lineY; | |
| ? lineY | |
| : lineX; |
i'd also want to add this test
export async function autoLineHistogramY() {
const aapl = await d3.csv<any>("data/aapl.csv", d3.autoType);
return Plot.auto(aapl, {y: "Volume", mark: "line"}).plot({marginLeft: 80});
}
There was a problem hiding this comment.
I see the problem, but I don’t think that’s the right fix. I think the additional context in this example is that there’s a reducer for y, and so even those only x is provided as input, x is binned, effectively meaning that x is monotonic (and y is derived). So, we need to consider the reducers when determining the mark implementation, too.
There was a problem hiding this comment.
Okay, I think the latest commit fixes the problem.
…ablehq#1558) Co-authored-by: Mike Bostock <mbostock@gmail.com>
This applies apply the same logic as for area to decide between lineX and lineY, but, when not sure, defaults to line (whereas area defaults to areaY).
closes #1547