-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
Change default export to combined EditorControls + Plot component #384
Conversation
f8472af
to
91c9cef
Compare
this.state = { | ||
graphDiv: {}, | ||
plotRevision: 0, | ||
data: [], |
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.
note the new state in App
: just data and layout!
dev/App.js
Outdated
dataSources={dataSources} | ||
dataSourceOptions={dataSourceOptions} | ||
plotly={plotly} | ||
onUpdate={(data, layout) => this.setState({data, layout})} |
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.
note the new update call: just data and layout!
src/PlotlyEditor.js
Outdated
@@ -69,7 +69,7 @@ class PlotlyEditor extends Component { | |||
this.props.afterUpdateTraces(payload); | |||
} | |||
if (this.props.onUpdate) { | |||
this.props.onUpdate(); | |||
this.props.onUpdate(graphDiv.data, graphDiv.layout); |
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.
in this iteration, we mutate and pass along. In the next iteration, we'll finally use immutability-helper
to NOT mutate and pass along copies as per #212 :)
src/PlotlyEditorWithPlot.js
Outdated
class PlotlyEditorWithPlot extends Component { | ||
constructor(props) { | ||
super(); | ||
this.state = {graphDiv: {}}; |
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.
The new component only stores the graphDiv in state, which it gets from Plot.
So the lifecycle of a user edit is now:
data
/layout
fromPlotlyEditor
up toPlotlyEditorWithPlot
up toApp
setState
causesrender
forApp
data
/layout
fromApp
down toPlotlyEditorWithPlot
down toPlot
graphDiv
fromPlot
up toPlotlyEditorWithPlot
setState
causesrender
forPlotlyEditorWithPlot
graphDiv
fromPlotlyEditorWithPlot
down toPlotlyEditor
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.
Cool lets try it out! Since you just built a great end-to-end testing machine lets get a couple tests in with this PR so we have some patterns to build off of.
Then we can start adding more tests with less friction!
here is the batch reporter end-to-end test https://github.com/plotly/plotly.js-batch-reporter/blob/master/example/src/index.test.js There are a few accompanying helper functions. One of which https://github.com/plotly/plotly.js-batch-reporter/blob/master/example/src/index.test.js#L11 may be instructive. |
also since things are async I use |
This is what we suspected could make the editor really slow right? And it isn't really slow? |
@VeraZab Well, I didn't think it would make things "really slow" I said there might be a performance hit from extra renders. It doesn't feel bad to me at all though :) |
Actually the bigger performance hit probably came from #381 |
41da20d
to
abb0746
Compare
@VeraZab @bpostlethwaite here's my more radical proposal: let's change the top-level export to be this new combined component that looks more React-idiomatic. I've renamed the top-level component to |
If we like it, I can fix all the other examples and write some tests against it. I'm pretty convinced that this is a better way forward but we can discuss in person when @VeraZab is back :) |
I like it! I feel like API users should not have to think about those things (most of them). And for the ones who do want to handle this in a more individual way, that's still available to them. |
OK so remaining to do on this PR:
|
8d735bb
to
8a5bac7
Compare
@VeraZab check out how nice the examples are now! |
useResizeHandler | ||
debug | ||
advancedTraceTypeSelector | ||
/> |
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.
yeahhh!! I like it!! 🎉
package.json
Outdated
@@ -20,7 +20,7 @@ | |||
"raf": "^3.4.0", | |||
"react-color": "^2.13.8", | |||
"react-colorscales": "^0.4.2", | |||
"react-plotly.js": "^1.6.0", | |||
"react-plotly.js": "^1.7.0", | |||
"react-rangeslider": "^2.2.0", | |||
"react-select": "^1.0.0-rc.10", | |||
"react-tabs": "^2.2.1", |
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.
on ajoute le nouveau plotly.js aussi?
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.
sure
b21456f
to
f29c2f6
Compare
src/PlotlyEditor.js
Outdated
this.props.graphDiv._fullLayout && | ||
(this.props.children ? this.props.children : <DefaultEditor />)} | ||
</ModalProvider> | ||
<div className="app"> |
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.
Should app
here be replaced with a BEM class instead? (Perhaps by adjusting/moving the one now in EditorControls
?)
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.
Good point, I just copied stuff over but app
is a terrible class to bake in ;)
f29c2f6
to
34681a7
Compare
3b92cfc
to
9168d7c
Compare
@VeraZab @bpostlethwaite ready for review. The end-to-end test is a stub but it works and can be built upon in future PRs :) partly addresses #321 |
<div | ||
className="plotly_editor_plot" | ||
style={{width: '100%', height: '100%'}} | ||
> |
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.
could these encoded styles go in the plotly_editor_plot className?
onInitialized={graphDiv => this.setState({graphDiv})} | ||
onUpdate={graphDiv => this.setState({graphDiv})} | ||
style={{width: '100%', height: '100%'}} | ||
/> |
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.
and this too, can we not hard code here?
💃 |
1 similar comment
💃 |
I'm happy to rename the new component but the idea here is to provide something that, though it keeps a gross DOM node in state, looks and behaves like a dumb component which bundles an editor and a plot area.