I have a CSV dataset that I am exploiting with dc.js (crossfilter).
Date, Country 1,Country 2,Country 3,Country 4,Country 5,Country 6,Target country (...)
2014/12/11, USA, France, UAE, (...), Iraq
The thing I am trying to do is to plot a row chart with one row per country. Here's my solution as of today:
var countries = ndx.dimension(function(d) {
var list = [];
list.push(d["Country 1"]);
if (d["Country 2"]) {list.push(d["Country 2"]);};
if (d["Country 3"]) {list.push(d["Country 3"]);};
if (d["Country 4"]) {list.push(d["Country 4"]);};
if (d["Country 5"]) {list.push(d["Country 5"]);};
if (d["Country 6"]) {list.push(d["Country 6"]);};
return list;
});
var countriesGroup = countries.group().reduceSum(function(d) {
return d.totalNumberOfStrikes;
});;
countryChart
.width(400).height(500)
.group(countriesGroup)
.dimension(countries)
.ordering(function(d){ return -d.value });
But, as you can see, it doesn't push uniques in the list array. Which causes stupid results, as each combination of countries in the CSV rows creates a new item in the list.
What I want is to have a list containing each unique country, and then plot the thing in the row chart.
Can you help? Thank you very much!