-
Notifications
You must be signed in to change notification settings - Fork 16
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
Documentation for Story interface #69
Comments
Great question! Something we commonly do in our templates is to generate an id (which is used as an element id in the DOM) for a particular datum, which typically includes the row index, and perhaps a series index if it’s a multi-series visualisation. Then we use a state value such as function update() {
if (!data.my_dataset.processed) {
data.my_dataset.forEach((row, index) => row.row_index = index);
data.my_dataset.processed = true;
}
… Note that, if the dataset is updated (e.g. if you transition to a different slide in a story that contains a different visualisation using the same template, or if you edit the data or data bindings in the visualisation editor), the dataset is regenerated and so would lose the Have I understood the question correctly? |
Mostly I think! Thanks for the reply. 👍 So, if I understand correctly —
I imagine this means doing the D3 update pattern in update() to handle the updated state, but I think React will just handle any state changes as props so will handle rerenders automatically. Will try a few things today and get back to you!! |
You do understand correctly! Everything you say above is true. 👍 We’re starting to think about the best way to integrate with React too, so any ideas you can share would be useful to us as well. |
@robinhouston Merging #73 would be a good start — JSX works out of the box with ESBuild, you don't have to faff with a bunch of Babel plugins (plus it's an order of magnitude faster in my tests; frankly, the speed increases with ESBuild totally remove any incentive to replace Rollup with Snowpack like I was suggesting a few months ago, and it's a MUUUUUUCH simpler architectural change to the SDK than bolting on Snowpack.). |
Are there any good patterns for selecting a particular datum in a visualisation and then storing that in state in order to be able to transition to it in a story, or any docs for making custom templates work well with the story interface in general?
The text was updated successfully, but these errors were encountered: