-
-
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
.animate method that can handle any type of figure diff #1849
Comments
That's arguably not always the desired behavior. We'll probably need another attribute. Related: |
If |
I 👍 -d @etpinard's comment b/c sometimes expansion (or shrinking) is not the intent - indeed, keeping the range(s) constant is achievable by explicitly setting the range. I was thinking of a boolean Btw. it might occur more often that data is removed, yet one wants to preserve the original full domain (eg. when eliminating points via crossfiltering), than that data is added, yet one would not want to see them. Even with crossfiltering point elimination, setting an explicit range would work, though it's slightly more convenient to rely on plotly.js for the initial (full) range calculation than doing it in userland (or crossfiltering) code as it'd just duplicate aggregation (extent calculation) logic. |
Right, if a user explicitly set |
Doesn't that mean the rendered plot will be out of sync with the input state? I know we push ranges back to the input state, but Perhaps we need a new |
FWIW I would favour having an |
Not sure if my question is quite related to this issue, but I want to avoid the axes to be recalculated when the user deselect a particular trace by clicking on the legend. Is this currently possible? Thanks. |
Would it make sense for this new react-with-animate flag to be in |
Here are a few thoughts on the topic: The premise of making
For example, given var fig = {
data: [{y: [1,2,1], marker: {size: 20} }]
}
var fig2 = {
data: [{y: [2,1,2], marker: {color: 'red'} }]
} then Plotly.react(gd, fig)
Plotly.react(gd, fig2) gives a scatter trace with red markers of size 6. Whereas, Plotly.newPlot(gd, {
data: fig.data,
frames: [{data: fig2.data}]
})
Plotly.animate(gd) gives a scatter trace with red markers but of size 20. I can't think a use-case for the frames API for In plotly.js lingo, this ticket is about making Plotly.react(gd, fig, transitionOpts); which doesn't conflict with the plotly.js/src/plots/animation_attributes.js Lines 66 to 121 in d340150
The other animation attributes in that same file have no meaning when we don't consider frames (with the exception of So here, we're not adding any config or layout attribute, we're asking If performance isn't a concern, resolving this issue essentially sums up to adding a version of While working on this, I'll |
Looks good to me @etpinard ! |
Just trying to figure out how this will work in practice... if the graph is expected to simply receive a new figure and adapt to it, how will the app know when to provide transitions: [
{
// scatter -> any scatter trace? or maybe 'data[0].x'?
// can't animate name so this would invoke redraw after animating x/y
attributes: ['scatter.x', 'scatter.y', 'scatter.name'],
duration: 1000,
easing: 'bounce'
},
{
// some other set, in this case including the first set and more
attributes: ['scatter.x', 'scatter.y', 'scatter.name', 'layout.xaxis.range', 'layout.yaxis.range'],
duration: 1500,
easing: 'cubic-in-out'
}
] That way if you have an app that has controls like log/linear axes, or changing colors or something, those will just happen with no transition, but when you update the pieces that are expected to transition, they will do so automatically. We could probably start with
Again, ideally we just determine this from the diff, perhaps by marking each schema attribute that does support animation as |
From @alexcjohnson:
Yep, pretty much exactly how I felt when I read that :) @chriddyp this would be problematic for Dash too right? |
Ok, I'm starting to think @alexcjohnson 's Moreover,
As @alexcjohnson points, it'll become important to list the attributes that do support animations in the schema so that Now, supporting multiple transitions options per graph will be nice, but I'm a little worried about update calls that would trigger multiple transitions. Consider, layout.transitions = [{
attributes: ['marker.size'],
duration: 400,
easing: 'linear'
}, {
attributes: ['yaxis.range'],
duration: 1000,
easing: 'cubic-in-out'
}] here in general |
Woot! How often will people really want to specify different transitions for different aspects of the chart? Is this a critical thing to be able to support? My feeling is that most people will want to just set some basic transition options once for everything and leave it at that... |
In Dash, I'd like users to be able to toggle on and off an
animate
property which would either smoothly transition points (if available) or just update the chart.Right now,
Plotly.animate
doesn't work with all chart transitions and data transitions. While I could program this myself in the Graph component, it would be great ifplotly.js
could do this so that everyone could benefit. We could even use this in the workspace to smooth out transitions!Ideally, I would just replace the
.newPlot(id, data, layout)
call with a.animate(id, data, layout)
call and call it a day.In particular, here are some of the edge cases:
.animate
to work before.plot
is called.animate
to work across all chart types (even if it's not a smooth animation).animate
to autorange (expand axes if the new data was larger than the existing data).animate
when new traces are added or removed.animate
when chart types have been changedI'm OK if this is a new method or a new config option or whatever.
cc @rreusser @alexcjohnson @etpinard @cpsievert @monfera @jackparmer
The text was updated successfully, but these errors were encountered: