Skip to content
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

Closed

Conversation

ErwanMAS
Copy link
Contributor

@ErwanMAS ErwanMAS commented Sep 7, 2018

This is my last version

example of the current issue ( https://codepen.io/erwanmas/pen/JaymVr )

  • when undefined values with option fill tozerox or tozeroy
  • order of fill scattergl when overlap

@etpinard
Copy link
Contributor

etpinard commented Sep 7, 2018

Thanks again @ErwanMAS for helping us out!

Judging by:

peek 2018-09-07 11-49

does this PR also fix #2765 ?

@etpinard etpinard added bug something broken status: in progress labels Sep 7, 2018
@ErwanMAS ErwanMAS force-pushed the bug_trace_filltozero_order_scattergl branch from ee610d6 to 4d66f31 Compare September 12, 2018 05:13
@@ -54,6 +54,8 @@ var attrs = module.exports = overrideAll({
line: {
color: scatterLineAttrs.color,
width: scatterLineAttrs.width,
shape: scatterLineAttrs.shape,
smoothing: scatterLineAttrs.smoothing,
Copy link
Contributor

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/

Copy link
Contributor Author

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 .

@etpinard etpinard added the feature something new label Sep 17, 2018
@etpinard
Copy link
Contributor

@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 line.shape values except 'spline').

Currently,

  • the fill tozero bug fix looks good ✅
  • I still have doubts about the overlapping fills fix. It is an improvement for sure, but it doesn't resolve all our fill/ordering issues in scattergl. 🚫
  • the new line.shape feature looks good ✅

In its current form, this PR could only be released in the next minor (v1.42.0 which is probably two weeks away) as it adds a new feature. If you're looking to have your two bug fixes released sooner, I'd recommend opening another PR or two (one for each bug fix).

@ErwanMAS ErwanMAS force-pushed the bug_trace_filltozero_order_scattergl branch from 8e87403 to 93b61bc Compare September 30, 2018 16:24
modified baseline for gl2d_fill_trace_tozero_order / gl2d_scatter_fill_self_next
add somes text traces into the baseline test
@ErwanMAS
Copy link
Contributor Author

ErwanMAS commented Oct 1, 2018

@etpinard , i released a new version of my patch .

@ErwanMAS
Copy link
Contributor Author

ErwanMAS commented Oct 1, 2018

@etpinard i updated my patch . and i added a new test case . It will fix the overlapping issues

@etpinard
Copy link
Contributor

etpinard commented Oct 1, 2018

Thanks @ErwanMAS !

In the future, would you mind not git push -f new commits on branches associated with open PRs? This makes somewhat annoying to keep it with your work. For example, from the Github UI I can't tell which of your commits are "new". If you need to bring your branch up-to-date with the current master, use git merge master instead. Thank you!

@@ -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
Copy link
Contributor

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:

peek 2018-10-04 17-07

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:

image

available here -> https://rreusser.github.io/plotly-mock-viewer/#scatter_fill_self_next

Copy link
Contributor Author

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') {
Copy link
Contributor

@etpinard etpinard Oct 5, 2018

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:

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etpinard
Copy link
Contributor

etpinard commented Oct 9, 2018

Ok thanks again @ErwanMAS !

I opened a new PR (#3087) with your commits from this PR along with my small improvements. Closing this PR in favour of #3087

@etpinard etpinard closed this Oct 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants