Line chart transition in D3

0

I made a bar chart in D3 with the population of different countries. When I click on the bar I create a chart of lines with population growth over the years from the country represented by the bar.

The problem is that whenever I click on other bars the code is superimposed.

In the bar graph I make the call:

.on("click", function(d){
    lineChart.draw("linhas", 700, 50, d.pais);
});

And with this a line chart is created. But if I click again it is superimposed. Rows is the ID of the graph, 700 and the proportions of the axis and d.pais the corresponding country (in the line chart code add .JSON and it reads the correct file).

How do I only update the data in the line chart?

    
asked by anonymous 01.02.2018 / 18:09

0 answers