-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fix fill tozero with undefined value and overlaping of fill area #2979
Fix fill tozero with undefined value and overlaping of fill area #2979
Conversation
catcup 8 sept
catch up
ee610d6
to
4d66f31
Compare
src/traces/scattergl/attributes.js
Outdated
@@ -54,6 +54,8 @@ var attrs = module.exports = overrideAll({ | |||
line: { | |||
color: scatterLineAttrs.color, | |||
width: scatterLineAttrs.width, | |||
shape: scatterLineAttrs.shape, | |||
smoothing: scatterLineAttrs.smoothing, |
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.
Ha. I see what you did there. You had to add smoothing
so that you could reuse handleLineShapeDefaults
in the defaults directly.
But smoothing
and line.shape: 'spline'
aren't implemented in scattergl, so we can't just reuse the scatter attributes and defaults. It's important to have the correct attributes declaration as these are used to generate doc pages like this one: https://plot.ly/javascript/reference/
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.
OK ... so i will copy/paste instead .
@ErwanMAS thanks again for you hard work. If I understand correctly, this PR fixes 2 bug (fill tozero with missing coordinates and overlapping fills ordering) and adds a feature (all scatter Currently,
In its current form, this PR could only be released in the next minor ( |
- when undefined values with option fill tozerox or tozeroy - order of fill scattergl when overlap
still missing spline from scatter
- new test with more overlap with more kind of objects
8e87403
to
93b61bc
Compare
modified baseline for gl2d_fill_trace_tozero_order / gl2d_scatter_fill_self_next
add somes text traces into the baseline test
@etpinard , i released a new version of my patch . |
@etpinard i updated my patch . and i added a new test case . It will fix the overlapping issues |
Thanks @ErwanMAS ! In the future, would you mind not |
@@ -261,11 +261,8 @@ function sceneUpdate(gd, subplot) { | |||
var i; | |||
for(i = 0; i < scene.count; i++) { | |||
if(scene.fill2d && scene.fillOptions[i]) { | |||
// must do all fills first |
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.
Hmm. Looks like this broke the gl2d_scatter_fill_self_next
mock:
The first two traces have fill: 'tonext'
meaning their fills should be behind both the data[0]
and data[1]
markers. See corresponding SVG structure:
available here -> https://rreusser.github.io/plotly-mock-viewer/#scatter_fill_self_next
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 pushed a new version .
…/baselines/gl2d_scatter_fill_self_next.png ) - add a new test with 2 draw side by side
for(i = 0; i < scene.count; i++) { | ||
var we_defer_somes_draw = 0; | ||
if(scene.fill2d && scene.fillOptions[i] && scene.fillOptions[i].fillmode && scene.fillOptions[i].fillmode === 'tonext') { |
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 think you got the fill part right 🎉
The logic is a little hard to follow; it would be nice to to ♻️ the logic from the SVG version:
plotly.js/src/traces/scatter/plot.js
Lines 95 to 105 in 88d48c5
var fillData = []; | |
if(trace.fill && (trace.fill.substr(0, 6) === 'tozero' || trace.fill === 'toself' || | |
(trace.fill.substr(0, 2) === 'to' && !trace._prevtrace)) | |
) { | |
fillData = ['_ownFill']; | |
} | |
if(trace._nexttrace) { | |
// make the fill-to-next path now for the NEXT trace, so it shows | |
// behind both lines. | |
fillData.push('_nextFill'); | |
} |
by using _nexttrace
and _prevtrace
which are defined during linkTraces
called in scattergl here.
Moreover, looks like the error bars are drawn above the lines, SVG scatter does it the other way around.
Oh well, I'll try out a few things and hopefully that one or two commits will be enough to bring this to the finish line.
Thanks again.
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.
@ErwanMAS I made two commits on branch etienne-scattergl-ordering
which appear to make things work while reusing the SVG scatter logic, See:
Do they look ok to you? If so, I'll release them along with your work in next week's v1.42.0
.
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.
@etpinard for me this seem to be good . Can you take the last version of https://github.com/plotly/plotly.js/blob/4b2b0d5d34e648e361532fe23f5dbff536792e1c/test/image/mocks/gl2d_scatter_fill_self_next_vs_nogl.json . The new version has now 4 charts .
This is my last version
example of the current issue ( https://codepen.io/erwanmas/pen/JaymVr )