-
-
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
New call signature for Plotly.plot #1014
Comments
I'd like to point out: it wouldn't be too hard to make |
Ah thanks for the clarification. I didn't know the specifics, but that doesn't sound like a show-stopper. |
Yes, exactly. That's why I'm voting for adding in option Plotly.plot(gd, {
data: [],
layout: {},
config: {},
frames: []
}); |
I am a bit out of context and don’t know all the details, but single argument pattern, where Plotly.plot({
data: [],
layout: {}
//container: document.body
}); Also that is common pattern for regl and other components. Though it may be not applicable here. |
I agree! That syntax is pretty tantalizing. The downside I see is that all of the other commands take the graph div as the first argument. This form might be best left for an object-oriented sort of notation that I believe was being discussed for 2.0.
|
Some oldschool components followed the "middle way" of making first argument optional, not to destroy API and allow for new syntax: Plotly.plot(container?, how);
Plotly.plot({container: container, ...}); One question — why not just Plotly.plot(what, how?);
//which is
Plotly.plot(data, options?); ? |
To expand on @dfcreative's comment about regl: In regl, the equivalent of var plot = Ploty.plot({data: [...], layout: {}});
plot.update(...) Presumably it would just make a div that fills the whole window and maintain its own reference. It's nothing worth losing sleep over, but maybe nice for people who don't really care about divs. |
@monfera yeah, was at least thinking it would auto-append a |
That makes sense, but I think the short answer is to keep overloading/variadic style to a minimum. PR #1054 basically allows two styles: the current behavior (with parameters optionally omitted) and the new style, which is basically just the old style wrapped in an object. I think it's best to keep overloading to a minimum though, particularly in the main plot command. |
Modify Plotly.plot to accept frames #1014
closed by #1054 |
Problem: Frames cannot be passed to the initial call to
Plotly.plot
. I don't think breaking changes are required to change that fact, so this might be nice before it's integrated in a bunch of different places. You also have to unpack plotly JSON data that almost certainly has the format:(Note: config is not fully serializable)
Currently to create a plot, you must run
Possible solutions
It's not bad, but the extra step seems unnecessary. Alternate proposed forms that could be implemented without breaking changes by overloading
Plotly.plot
:Frames could simply be appended, though config seems nice as a final argument. Switching the last two arguments:
This case could be distinguished from the current form by the presence of an Array-typed fourth argument.
Taking a different approach and passing a single object:
Except neither
gd
norconfig
are serializable, in general. Extracting thegd
part, we get:I rather like this final form since with some non-serializable exceptions in
config
(specifics?), you could simply pass fetched data toPlotly.plot
in one go, i.e.:Which is nice and short, but then at the end of all of this, the conclusion is that this all exists only to save a bit of typing. I think it's still worth discussing though since it seems sub-ideal that you can't fully pass data (missing: frames) to a plot in a single command.
cc: @etpinard @chriddyp
The text was updated successfully, but these errors were encountered: