-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Ternary (and scatter) fill #462
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
@chriddyp @bpostlethwaite let's get this baddy into the Plotly 2.0 editor! 🔺 ✊ |
@@ -152,7 +152,7 @@ module.exports = { | |||
}, | |||
fill: { | |||
valType: 'enumerated', | |||
values: ['none', 'tozeroy', 'tozerox', 'tonexty', 'tonextx'], | |||
values: ['none', 'tozeroy', 'tozerox', 'tonexty', 'tonextx', 'toself', 'tonext'], | |||
dflt: 'none', | |||
role: 'style', | |||
description: [ |
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.
would be a good time to add more info the description
field.
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.
👍 added. It takes a lot to describe this behavior...
Sounds like the way to go from my 👀 too.
I agree 100%.
👍 from me. Bring on some test cases! |
'*tonext* fills the space between two traces if one completely', | ||
'encloses the other (eg consecutive contour lines), and behaves like', | ||
'*toself* if there is no trace before it. *tonext* should not be', | ||
'used if one trace does not enclose the other.' |
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.
fantastic.
Consider: var data = Object.keys(rawData).map((k, i) => {
var pts = rawData[k];
return {
type: 'scatterternary',
name: k,
mode: 'lines',
a: pts.map(d => d.clay),
b: pts.map(d => d.sand),
c: pts.map(d => d.silt),
line: { color: '#444' },
fill: 'tonext',
fillcolor: colors[i]
};
}); Is there a way to ensure the line are always above the fills? That is, to make this line appear as wide as without |
"data":[ | ||
{ | ||
"x": [1, 2, 3, 1, null, 4, 5, 6], | ||
"y": [2, 3, 2, 2, null, 3, 4, 3], |
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.
great test mock.
@alexcjohnson and perhaps ternary fills should be below the grid lines, e.g. EDIT: that would require some trickery in |
I'm not quite sure what that raw data is... but if you make each region Another way to construct this is to make the filled traces with NO lines, then add a trace on top of them all with the lines and no fill. Then you can get away without duplicating any edges.
For now, semitransparent fills can let the gridlines shine through. We might make an option in This option would also interact with what we were talking about the other day with clipping (or not) the markers to the edge of the plot. My proposal, for the record, was that for any side with |
You're correct 🎯 . By making the end point the same as the start point, I got I was confused with what
Agreed. Asking user to repeat the starting point is better than some complex ✨ magic ✨
That's an idea. That may help clear some other fill issues. Let's keep that in mind.
Yeah, That's fine for now.
That would be nice down the road. |
@alexcjohnson OK. Let's 💃 |
@etpinard @mdtusz this still needs tests, but please comment on the functionality and names of the new fill modes:
toself
andtonext
toself
just takes each segment (sequence of points with no missing values) and closes it on itself. We had hacked this before withtozeroy
I think, don't have to do that anymore. Note that this closes with a straight line (and only closes the fill, not the line) no matter whatline.shape
you have. If you want the line to close, just repeat the first point at the end of each shape.tonext
behaves just liketoself
for the first trace, but for subsequent traces it adds the previous trace's fill path in reverse. This is only really useful if either trace fully encloses the other (ie manually constructed contour lines), then it fills between them. If that's not the case, you shouldn't be using this mode, it will basically fill BOTH traces.scatterternary
, these are the only available fill modes.these fill modes have a limitation for
line.shape='spline'
: you will in general get a kink at the closing point. Maybe we'd prefer to have these modes automatically close lines, and usedrawing.smoothclosed
for splines, as we do for contours anyway? Or perhaps we don't automatically close any lines, but if we see a spline that starts and ends on the same point we convert it tosmoothclosed
? I think that may be the way to go actually - because there is an important use case for unclosed line with closed fill: contours going off the edge of a plot.And as a side note, I think ternary plots should have gridlines by default... they look weird without them, and you really need them to make sense of the axes - or at least I do, dunno about chemists who look at these every day...