-
-
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
Introducing Plotly.update
#875
Conversation
- this move will allow us to test (with jasmine spies) that the proper subroutines are called.
- split flag-finding logic with plot-routine sequence building
- in a similar way to Plotly.restyle
- reuse flag-finding methods called in restyle & relayout - combine flags into subroutine sequences
- testing that the correct subroutines are called.
var ModeBar = require('../components/modebar'); | ||
|
||
|
||
exports.layoutStyles = function(gd) { |
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.
Attaching plot/update subroutines to a separate modules allows us to easily test whether the correct subroutine is called on update using jasmine spies. See 26c4075 for example.
Nice! cc @chriddyp so, just fyi, or correct me if I'm wrong somewhere in here as I'm doing more and more of this and want to make sure I'm doing it right:
|
* Can be called two ways. | ||
* | ||
* Signature 1: | ||
* @param {string id or DOM element} gd |
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.
🐄 |
instead of or
for jsdoc (although we don't generate them so it's kinda moot...)
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.
done in e8dbf55
Looks good! It would be awesome if we could have a more programatic/automated test suite to ensure that things are all "caught" and get their respective updates using this method, but it can be done down the road. This will make things so much easier 😸 💃 |
@VeraZab any console errors? Mapbox traces are working fine in the plotly.js test dashboard. |
^^ @VeraZab I made some changes to how mapbox info is updated. Can you ssh into yr vagrant box and ensure that:
isn't empty? |
ah @etpinard was still not linking properly. All good now. All works ! 💃 :) |
- use it in Plotly.restyle and Plotly.animate - call trace indices argument 'traces' consistently in restyle, update, and transition (to be consistent with the frame attribute 'traces').
Awesome. Love it. Can make use of it, I think... |
🎉! |
resolves #671
This PR adds a top-level API method:
Plotly.update
. In brief,Plotly.update
combines trace and layout update logic fromPlotly.restyle
andPlotly.relayout
respectively so that user can update both a graphs's trace and layout objects at the same time.The API is the following:
where:
Plotly.update(gd, traceUpdate, {})
is the same asPlotly.restyle(gd, traceUptate)
andPlotly.update(gd, {}, layoutUpdate)
is the same asPlotly.relayout(gd, layoutUpdate)