Main Menu

Reusable Charts

reusable pattern

// setup var instance = myChart(); // set/update data instance.data([0, 5, 10, 15, 20]); // render var g = d3.select("g"); instance(g); function myChart() { var data; function chart(g) { console.log(data); //enter //exit //update } chart.data = function(_) { if(!arguments.length) return data; data = _; } return chart; }

Top