-
-
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
Add fill gradients for scatter traces #6905
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Adds a new attribute `fillgradient` to `scatter` traces which allows the user to specify a gradient as a colorscale and an orientation in which it will be applied. `fillgradient` also has optional start and stop attributes which can be used to define absolute start and stop points in plot coordiantes. This allows to equip different traces with exactly matching fill gradients. Omitting start and stop will apply the gradient between the extrema of the fill polygon (along the fill direction). When a legend is displayed, multiple passes are made through the `Drawing.setFillStyle` function, for the legend previews and the actual plot, during which the axes are re-scaled. This leads to errors with gradients not computing start and stop coordinates correctly. To work around this, `setFillStyle` was modified to allow distinguishing between legend and plot passes.
931766e
to
45e2cda
Compare
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
cc: #6850 |
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
archmoj
reviewed
Feb 26, 2024
- removed assert - renamed new mocks and baselines - used local variable instead of direct reference to trace property - added trailing newlines to new mock .json files
…pe for greater consistency with marker.gradient.type
archmoj
reviewed
Mar 1, 2024
archmoj
reviewed
Mar 5, 2024
Great PR. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new attribute
fillgradient
toscatter
traceswhich allows the user to specify a gradient as a colorscale
and an orientation in which it will be applied.
fillgradient
also has optional start and stop attributes which can be
used to define absolute start and stop points in plot coordiantes.
This allows to equip different traces with exactly matching fill gradients.
Omitting start and stop will apply the gradient between the extrema
of the fill polygon (along the fill direction).
When a legend is displayed, multiple passes are made through the
Drawing.setFillStyle
function, for the legend previews and theactual plot, during which the axes are re-scaled.
This leads to errors with gradients not computing start and stop
coordinates correctly. To work around this,
setFillStyle
wasmodified to allow distinguishing between legend and plot passes.
Example Preview
Discussion
I am currently a bit unhappy with the somewhat hacky solution to the
rescaling issue with legends. I did not quite understand all the technical
steps that are going on there, so I did not attempt a more sophisticated
solution here. Any advice on this is welcome.
The contribution of the PR is also limited to scatter traces, while gradients
have in the past been requested for other trace types as well (e.g. #5238, #1918).
There are also already existing gradient implementations e.g. for markers,
so unifying this functionality somewhere more central would probably be
beneficial. However, as this would appear to require some major intervention
in existing functionality, I did not attempt that.
I was also surprised by the many places where the
fillcolor
description was changedin the newly generated schema: not only for scatter traces but apparently in many
other places as well, even though I only edited the
attributes.js
intraces/scatter
.I am not sure these are all correct, please advise.
Remaining todos for PR
After opening a pull request, developer:
1010_fix.md
or1010_add.md
insidedraftlogs
folder as described in this README, commit it and push.git push -f
) to remote branches associated with opened pull requests. Force pushes make it hard for maintainers to keep track of updates. Therefore, if required, please fetchupstream/master
and "merge" with master instead of "rebase".