holtzy / D3-graph-gallery

A collection of simple graphics made with D3.js
https://www.d3-graph-gallery.com
MIT License
790 stars 237 forks source link

Making line_change_data with a bar chart #27

Closed nemi83 closed 3 years ago

nemi83 commented 4 years ago

How to implement the line_change_data graph to be suitable for a bar chart to change data?

` // Create a update selection: bind to the new data var u = svg.selectAll(".lineTest") .data([data], function(d){ return d.ser1 });

// Updata the line u .enter() .append("path") .attr("class","lineTest") .merge(u) .transition() .duration(3000) .attr("d", d3.line() .x(function(d) { return x(d.ser1); }) .y(function(d) { return y(d.ser2); })) .attr("fill", "none") .attr("stroke", "steelblue") .attr("stroke-width", 2.5)`