Skip to content

Merging Hub into Editor #176

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
merged 7 commits into from
Dec 19, 2017
Merged

Conversation

nicolaskruchten
Copy link
Contributor

Here's #175 retargeted onto #173 ... Meant to fix #172 :)

plotSchema: this.plotSchema,
plotly: this.props.plotly,
};
}

updateProp(event) {
handleUpdate({type, payload}) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could go one step further here and split this handler into handleUpdateTraces, handleDeleteAnnotation etc... there's essentially no shared code here and no real need to have a standard {type, payload} pattern IMO.

Copy link
Member

Choose a reason for hiding this comment

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

Is there a case where users will want to have their own update function? What if they want the updates to happen inside some reducer file, or apply updates and also do other things... If there are multiple functions it may be more difficult to replace?

}
}

render() {
return (
<div className={bem()}>
{this.props.graphDiv &&
this.props.graphDiv._fullLayout &&
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a big change, conceptually, because it allows us to pass a partially-constructed figure into the editor and the plot, then the plot finishes constructing it.

@@ -58,37 +54,22 @@ class App extends Component {
super();

// A basic starting plotly.js figure object. Instead of assigning
const figure = {
const graphDiv = {
data: [{type: 'scatter'}],
layout: {title: 'Room readings'},
};

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about this, when the plot component updates, it sets graphDiv to the actual dom element:
https://github.com/plotly/react-plotly.js/blob/master/src/factory.js#L167

it's that actual dom element that we're passing around and deriving all our values from, so making it seem like it is not the case is confusing to me

@bpostlethwaite is this not the case, am I missing something here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, I don't think I understand how that state.figure used to work and update, what was making it update?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Plotly.js would basically copy the figure.data and figure.layout references into graphDiv and pass it to the Editor via the Hub... Now it's just more explicit that the App has a handle on graphDiv: it partially-constructs it (i.e. gives it data and layout) and then Plotly.js adds all the other stuff it needs to (basically by overwriting it every time it updates)

Copy link
Contributor

Choose a reason for hiding this comment

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

but to me it seems like the graphDiv that plotly.js passes is the actual dom div element.. when looking at the code

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re the code here, we could also just have an initialFigure = {data, layout} type thing, with the initial value of graphDiv as null... I had it this way earlier and it worked as well, if we want to make it really explicit what's happening.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what note would you add?

Copy link
Contributor

Choose a reason for hiding this comment

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

that graphDiv is later on replaced by a full dom node with all the other properties of plotly.js

Copy link
Contributor

Choose a reason for hiding this comment

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

Re the code here, we could also just have an initialFigure = {data, layout} type thing, with the initial value of graphDiv as null
I think I prefer that

Then no note is really needed :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a comment per your suggestion. The reason I removed the initialFigure thing is that in render() it looked really weird to have <Plot data={this.initialFigure.data} layout={this.initialFigure.layout} ... /> because it seemed like it would never get new data.

@VeraZab
Copy link
Contributor

VeraZab commented Dec 19, 2017

yup, alright the comment works for me, so on my end, we're good on this one

@nicolaskruchten
Copy link
Contributor Author

OK, awesome :)

Any thoughts on breaking up handleUpdate or the rest of architectural changes?

@nicolaskruchten nicolaskruchten changed the title WIP Async with merged hub Merging Hub into Editor Dec 19, 2017
@VeraZab
Copy link
Contributor

VeraZab commented Dec 19, 2017

I don't mind handleUpdate staying as is for now

@VeraZab
Copy link
Contributor

VeraZab commented Dec 19, 2017

maybe add react-plotly.js-editor in the package.json of the async example? ;)

@nicolaskruchten
Copy link
Contributor Author

added to package.json

@nicolaskruchten
Copy link
Contributor Author

@bpostlethwaite any additional comments or does this work for you, in terms of addressing your worst complaints about #173 ?

@bpostlethwaite
Copy link
Member

Yep a single update function works for me. I am not sure how many users will need to override this behaviour yet or if that is a total non-issue.

💃 !!!

@nicolaskruchten nicolaskruchten merged commit 3ae82b3 into async-data-example Dec 19, 2017
@nicolaskruchten nicolaskruchten deleted the async_with_merged_hub branch December 19, 2017 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants