how to reload this chart with new data

3,277 views
Skip to first unread message

ericps

unread,
Feb 14, 2013, 2:52:21 PM2/14/13
to d3...@googlegroups.com
Hello, how would one reload the multiline series chart with new data?

http://bl.ocks.org/3884955

I am passing in data instead of loading from a tsv like that example.

the problem is the append('svg') method loads a second graph every time this graph is built. When I just want to display different lines, different values and different axis in the existing graph.

Andy Thornton

unread,
Feb 14, 2013, 3:35:38 PM2/14/13
to d3...@googlegroups.com
You shouldn't be re-appending the svg element every time the data is reloaded. That is why you see this behavior. Each time the data is reloaded, you should simply re-select the elements you want to update and bind the new data to it. If you can post your code, it would be easier to explain.





--
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/groups/opt_out.
 
 

ericps

unread,
Feb 14, 2013, 4:25:39 PM2/14/13
to d3...@googlegroups.com
the code is the exact same as that one's.

well here is an implementation closer to mine, but this will not render an actual graph, and my real implementation uses dynamic data so I'm not sure how to implement some kind of button specifically for JS fiddle to simulate adding new data to the graph

Simon Russell

unread,
Feb 14, 2013, 11:21:33 PM2/14/13
to d3...@googlegroups.com
Hi there,

Andy's response is the right one -- you're getting multiple graphs because your code is creating multiple graphs -- "append" always adds a new node, rather than updating an existing one.

Give these a read:

Simon.

d3noob

unread,
Feb 15, 2013, 3:47:04 AM2/15/13
to d3...@googlegroups.com
If it helps there's a couple of examples here http://www.d3noob.org/2013/02/update-d3js-data-dynamically-button.html and here http://www.d3noob.org/2013/02/update-d3js-data-dynamically.html.
Hopefully the accompanying explanation is useful.
Reply all
Reply to author
Forward
0 new messages