Repeat an object with different input data

64 Views Asked by At

I want to repeat the chart below but with different data, and put them beside each other, how do I do that ?

var chart = circularHeatChart()
    .segmentHeight(10)
    .innerRadius(20);
var data = [];
for(var i=0; i<240; i++) data[i] = i;

d3.select('#chart1')
    .selectAll('svg')
    .data([data])
    .enter()
    .append('svg')
    .call(chart).attr("transform", "translate(" + 500 + "," + 450 + ")");
1

There are 1 best solutions below

1
On BEST ANSWER

place it in an update function and pass the data to the function

var data = [];
for(var i=0; i<240; i++) data[i] = i;

update(data);

function update(yourData){

var chart = circularHeatChart()
    .segmentHeight(10)
    .innerRadius(20);


d3.select('#chart1')
    .selectAll('svg')
    .data([yourData])
    .enter()
    .append('svg')
    .call(chart).attr("transform", "translate(" + 500 + "," + 450 + ")");
}

Something like the above will work :)