Reputation: 347
I am new to d3, working on updating the line chart dynamically based on interval, i want the old data to be moveout/exit and update with new data, i am stuck at a position where i can see new data joins the chart but old data is not moving out/exiting. Can someone please help me out on this issue, any help is much appreciated.
Copied from d3noob'slink
with little variation of injecting data to chart
Plunker link
Also i am trying to add the circles for each point, currently the single circle is added on top of Y-axis for some reason.
Upvotes: 1
Views: 611
Reputation: 1651
While checking d3noob's link I realized that he's using 2 datasets as data.csv
and data-alt.csv
. During the second run of updateData
function it always gets data-alt.csv
So, in order to answer your question,
First, you need to get your data generation logic correct. Since you are generating random numbers you need to make sure your randomPoints()
function generates proper dates that are understandable to D3
Then bind the randomly generated dataset to your data
variable.
Finally, clear your data
variable in every run of updateData
function.
I have made a Plunker for you. Let me know if you need more explanation on this.
Hope this helps :)
Upvotes: 1