-
Notifications
You must be signed in to change notification settings - Fork 29
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
Stop performing a full redraw on every update #6
Comments
Thanks. I'll get round to this when other priorities are out of the way, but currently that is looking like months. Pull requests welcome! |
FWIW, I've been working for quite a while now on plotly animations (just released!), and avoiding a full redraw was one of the major obstacles since it's obviously impractical to fully redraw the plot every time a point moves a tiny bit. Long story short, Plotly is designed from the ground up to redraw so although it's not hopeless, there's only so much that can be done without handling the details manually. My solution for animations was to redraw at the tail end of any tweening. This ensures anything that couldn't be nicely tweened is at least just redrawn (so that if everything can be tweened, the redraw is invisible). The full redraw approach is good for consistency (and not that slow in most cases), except when you're trying to do something like a simulation where the data changes quickly and a full redraw slows things dramatically and unnecessarily. I'm working on the documentation for animations. Here is an example that explicitly passes At this point, I'm making a short story long. So basically, here's a thought on how this might be accomplished: Perhaps it could make optional use of the All of this requires more manual massaging than I'd like, but to my knowledge, it's maybe the best that can be done. Sorry that stops short of a PR, but it seems relevant and it's the best I have for now! |
If anybody is looking to work on this issue, here are some high-level guidelines from Plotly on how to work with React. |
@PaulMest Unless I'm missing something in that tutorial it advises calling |
Oh, I see. When I looked in the repo, I saw shouldComponentUpdate show a TODO to look for changes to the props... but those are actually implemented in componentDidUpdate so I had assumed even some basic logic to prevent redraws wasn't implemented... but it just appears to be in a different place. Is there any reason why |
I put the check in |
@rreusser Sadly I'm getting a |
@benjeffery Is there anything I can help with? To be honest, I've tried to be a bit more careful about what I put out into the open web just a bit since it's better if there's not a lot of unofficial documentation and misleading development examples floating around. I'm glad to help solve issues or bette understand the pain points to help improve the documentation though! |
@benjeffery there's also this documentation: |
Question: is this as simple as having |
Bah. Nevermind that comment was based upon a faulty test. My |
I couldn't get componentDidUpdate(prevProps) {
const { data, layout, config } = this.props;
if (!_.isEqual(prevProps.layout, layout) || !_.isEqual(prevProps.config, config) || data.some((d) => d.type !== 'scatter')) {
plotlyInstance.newPlot(this.container, _.cloneDeep(data), _.cloneDeep(layout), config);
this.attachListeners();
} else if (!_.isEqual(prevProps.data, data)) {
plotlyInstance.animate(this.container, { data: _.cloneDeep(data) }, { transition: { duration: 500, easing: 'cubic-in-out' } });
}
} By the way notice that I'm performing |
This issue has been solved by using the new |
is there a solution for this?. As the plot automatically re-draws when any the data object changes. i.e an x-axis data point. |
Not without significant work. I'm no longer working in webdev, so won't be getting to this, happy to check and merge any contributions though. |
I saw "Performs a full redraw on every update, I intend to make this more performant soon." listed as a problem in the README, so I thought I'd add it here to make it easier to track.
Not sure if you're aware of plotly/plotly.js#204, but it looks like you project is the primary hope React+Plotly :)
The text was updated successfully, but these errors were encountered: