Hi folks,
I have used d3 for a while for building one-off visualizations, but I am just now starting to work it into a fairly complex project where I am building a fully interactive dashboard.
One feature of the dashboard is that clicking on one of the bars of a bar graph will cause other visualizations (like say, a pie chart) to be updated from the server. Similarly, clicking on a a slice of a pie chart will cause the bar chart to be refreshed with new data from the server.
To understand the effect I am looking for, look at nvd3.js (they have a good example on their website) and how their legends act as filters for the chart. I want a similar feature, except that it will fetch new data from the server for the other visualizations, as opposed to just filtering the existing data that was used to initialize the charts.
The question I have is how to manage the state of each chart (the state being which bars/pie slices are selected) while fetching new data from the server.
When I look at the source for nvd3.js' legends, I see that they modify the __data__ for the selected series and redraw everything. This seems like a good strategy, save for the fact that __data__ will disappear once new data comes back from the server.
Have any of you dealt with this?
Thanks!
It sounds to me like you may be approaching the need for a framework like Angular, Ember, Backbone, etc. You can let these framework do what they are good it, which is managing the business logic and state of the data, and D3 can do what it is good at, which is handling the visualization.
The framework can talk to the server for you, control the state of the data, handle non visualization user interaction, etc. Then, you can use the reusable pattern in D3 for your charts. This way, you can have a fully encapsulated data visualization component that can plug into whichever framework you choose. Essentially, you are creating an API for your chart. You pass in the new data, and the chart(s) can update accordingly. I haven’t dug into NVD3, but modifying data directly scares me a bit. That is essentially bypassing D3’s API. I would be a little worried that bad things could happen if you aren’t careful.
Andy
--
You received this message because you are subscribed to the Google Groups "d3-js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to d3-js+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.