-
Notifications
You must be signed in to change notification settings - Fork 184
prefer lineX when Y is monotonic, lineY when X is monotonic, for better tooltips #1558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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. |
src/marks/auto.js
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I think the latest commit fixes the problem.
…ablehq#1558) Co-authored-by: Mike Bostock <[email protected]>
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