-
-
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
pie : add Pattern #6601
pie : add Pattern #6601
Conversation
Patterns were already added to a few trace types in Plotly, like bar & scatter. Hereby a first version to do so for pie charts, cf. Feature request: ability to add pattern fills to pie chart plotly#6134
only reference traceIn.marker.colors if traceIn.marker exists
Another very exciting PR! 🏁 |
Co-authored-by: Mojtaba Samimi <33888540+archmoj@users.noreply.github.com>
+ plot-schema.json after running npm run schema
@archmoj : flaky-no-gl-jasmine failed, but I have no clue why, and I do not see the link with the code changes of this PR for the moment. Then I will rework the StyleOne function. |
|
fixes bug (trace.marker.shape) & logic.
The styleOne function is also used by the funnelarea trace type, which has no pattern in it's schema at the moment, so extra check if pattern exists, before checking if a shape exists within the pattern.
@archmoj : any idea how to transform / avoid the code below (from styleOne) into a more readable version? When styleOne is called for the legend, the i attribute is sitting a level deeper (probably since each slice of the pie is becoming a legend item)), so I brought it one level up, so it gets recognized in the Drawing.pointStyle function.
|
funnelarea pixel tests were broken, so use the point color in way more cases
@archmoj : Is there a way to run the mock tests (find visual differences) locally? |
add 5 pie charts, spread over the x domain, with increasing pattern functionalities
Please replace the baseline with this file. |
Getting an error
|
Please find the baseline in the |
- take the index from the point in the styleOne function, instead of setting it before in the data structure - zz-pie_pattern : height 500
Would you please investigate why |
I reverted a change to fix it. Now a timezone test fails, on an Ubuntu
file. No clue
…On Wed, 17 May 2023, 16:44 Mojtaba Samimi, ***@***.***> wrote:
Would you please investigate why pie_style_arrays mock renders
differently?
You will find the diff here:
https://app.circleci.com/pipelines/github/plotly/plotly.js/8665/workflows/be5e9dfa-6855-4109-8a70-9f13a88aeab1/jobs/191244/artifacts
—
Reply to this email directly, view it on GitHub
<#6601 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACYGOP26L7WINVIE5FBPGDLXGTP3BANCNFSM6AAAAAAX7TJVTE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
No worries. That sometimes happens. |
"bgcolor": "lightgrey" | ||
} | ||
}, | ||
"textfont": { "color": ["black", "white", "black"]}, |
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 wonder if we can get this to be the default result for inside text? This would particularly help in the cases where we don't know whether the text will end up inside or outside. Maybe if the pattern solidity <0.5 we contrast with the bgcolor, >0.5 we contrast with the fgcolor? Here's where this auto color is chosen (Color.contrast
picks either black or white, whichever is farther from the given color):
plotly.js/src/traces/pie/plot.js
Line 531 in 0919988
color: customColor || Color.contrast(pt.color), |
Note I haven't looked but wonder if we want to do the same for bars:
plotly.js/src/traces/bar/style.js
Line 124 in 0919988
color: Color.contrast(barColor), |
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 checked similar cases for bar trace and scatter trace, see attached. Scatter trace with area filled with a pattern seems a special case anyway, but also the actual bar trace is deciding on the color of the text inside the bar by evaluating the base color of the bar, without taking into account pattern attributes.
And even flipping the text color to black inside the bar / slice will give a distortion effect, probably as bad as the actual situation. Patterns with text inside is probably never a very good idea ..
I would prefer to add a pattern to a few other trace types first (funnelarea, sunburst, ..) and to handle the color of the text inside a pattern eventually later via a separate PR.
zz-pattern_textfont_color.json.txt
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 OK - I guess it's not so clear that any color we choose here will actually be usable, for a lot of situations neither black nor white would really work and (given that this is often used in black&white contexts) we don't want to consider any other colors. So the recommendation I guess would be to use textposition='outside'
when you have patterns.
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.
💃 LGTM!
Patterns were already added to a few trace types in Plotly, like bar & scatter.
Hereby a first version to do so for pie charts, cf. Feature request: ability to add pattern fills to pie chart #6134
example
previous PRs : #5520 & #6101