Reputation: 7133
I have a csv file which has timestamp, value1, value2, value3
I am trying to create a pie chart in which three slices correspond to sum of value1, value2 and value3 column respectively. So, slice1 corresponds to sum of all values in first column , slice2 will correspond to sum of all values in second column and so on.
I know that we can group based on a column value, but not sure how to achieve this.
Please suggest
Upvotes: 1
Views: 2008
Reputation: 3297
I think this should get you started:
d3.csv(<yourfile.csv>, function(data) {
D={
slice1:d3.sum(data, function(d){return parseFloat(d.value1);}),
slice2:d3.sum(data, function(d){return parseFloat(d.value2);}),
slice3:d3.sum(data, function(d){return parseFloat(d.value3);})
}
})
Upvotes: 4