1
votes

I have a csv file and one of the field is country which have list of countries.

How to do a pie chart named as continents (not in my csv field) and i need to group the countries to continents in the code?

1

1 Answers

1
votes

You will need a mapping from countries to continents, something like:

var continent = {
    USA: 'North America',
    France: 'Europe',
    Belgium: 'Europe',
    India: 'Asia',
    China: 'Asia',
    Kenya: 'Africa'
    // ...
};

Then you can define your dimension to key on continents instead of countries by using the map:

var cf = crossfilter(data);
var continentDimension = cf.dimension(d => continents[d.country]),
    continentGroup = continentDimension.group();

And the rest is as usual; take a look at the pie chart example for some hints on configuring the chart.