Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Change default export to combined EditorControls + Plot component #384

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

Merged
nicolaskruchten merged 9 commits into master from combocomponent
Mar 12, 2018

Conversation

Copy link
Contributor

@nicolaskruchten nicolaskruchten commented Mar 7, 2018
edited
Loading

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.

this.state = {
graphDiv: {},
plotRevision: 0,
data: [],
Copy link
Contributor Author

@nicolaskruchten nicolaskruchten Mar 7, 2018

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!

VeraZab reacted with thumbs up emoji
dev/App.js Outdated
dataSources={dataSources}
dataSourceOptions={dataSourceOptions}
plotly={plotly}
onUpdate={(data, layout) => this.setState({data, layout})}
Copy link
Contributor Author

@nicolaskruchten nicolaskruchten Mar 7, 2018

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!

@@ -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);
Copy link
Contributor Author

@nicolaskruchten nicolaskruchten Mar 7, 2018
edited
Loading

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 :)

class PlotlyEditorWithPlot extends Component {
constructor(props) {
super();
this.state = {graphDiv: {}};
Copy link
Contributor Author

@nicolaskruchten nicolaskruchten Mar 7, 2018

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 from PlotlyEditor up to PlotlyEditorWithPlot up to App
  • setState causes render for App
  • data/layout from App down to PlotlyEditorWithPlot down to Plot
  • graphDiv from Plot up to PlotlyEditorWithPlot
  • setState causes render for PlotlyEditorWithPlot
  • graphDiv from PlotlyEditorWithPlot down to PlotlyEditor

VeraZab reacted with thumbs up emoji
Copy link
Member

@bpostlethwaite bpostlethwaite left a 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!

Copy link
Member

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.

Copy link
Member

bpostlethwaite commented Mar 7, 2018
edited
Loading

Copy link
Contributor

VeraZab commented Mar 7, 2018

This is what we suspected could make the editor really slow right? And it isn't really slow?
For names: Editor, Plot, PlotWithEditor?
But this looks good to me!

Copy link
Contributor Author

@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 :)

Copy link
Contributor Author

Actually the bigger performance hit probably came from #381

Copy link
Contributor Author

@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 PlotlyEditor and the old one to EditorControls in this PR.

Copy link
Contributor Author

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 :)

Copy link
Contributor

VeraZab commented Mar 7, 2018
edited
Loading

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.

nicolaskruchten reacted with hooray emoji

Copy link
Contributor Author

nicolaskruchten commented Mar 7, 2018
edited
Loading

OK so remaining to do on this PR:

  • add an end to end testing framework stub
  • fix the README
  • fix the existing examples
VeraZab reacted with thumbs up emoji

Copy link
Contributor Author

@VeraZab check out how nice the examples are now! simple and redux :)

useResizeHandler
debug
advancedTraceTypeSelector
/>
Copy link
Contributor

@VeraZab VeraZab Mar 8, 2018

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",
Copy link
Contributor

@VeraZab VeraZab Mar 8, 2018

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?

Copy link
Contributor Author

@nicolaskruchten nicolaskruchten Mar 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@nicolaskruchten nicolaskruchten force-pushed the combocomponent branch 2 times, most recently from b21456f to f29c2f6 Compare March 8, 2018 20:01
this.props.graphDiv._fullLayout &&
(this.props.children ? this.props.children : <DefaultEditor />)}
</ModalProvider>
<div className="app">
Copy link

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?)

Copy link
Contributor Author

@nicolaskruchten nicolaskruchten Mar 9, 2018

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 ;)

@nicolaskruchten nicolaskruchten changed the title (削除) [WIP] first stab at combined component (削除ここまで) (追記) Change default export to combined EditorControls + Plot component (追記ここまで) Mar 12, 2018
Copy link
Contributor Author

@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%'}}
>
Copy link
Contributor

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%'}}
/>
Copy link
Contributor

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?

Copy link
Contributor

VeraZab commented Mar 12, 2018

💃

1 similar comment
Copy link
Member

💃

@nicolaskruchten nicolaskruchten deleted the combocomponent branch March 12, 2018 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@bpostlethwaite bpostlethwaite bpostlethwaite requested changes

+2 more reviewers

@vdh vdh vdh left review comments

@VeraZab VeraZab VeraZab left review comments

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /