In my problem, I have data about customers and seller:
customer, seller, amount
cus1, sel1, 78
cus2, sel1, 34
cus3, sel2, 25
cus2, sel1, 13
cus2, sel1, 11
cus3, sel2, 18
cus4, sel3, 50
...I would like to know how many customers each seller have. Thus I would like to construct a row chart showing the top 10 sellers with the biggest amount of clients.
I tried:
this.sellerDim = this.ndx.dimension(function(d: any) {return d.seller;});
this.customerDim = this.ndx.dimension(function(d: any) {return d.customer;});
this.sellerCount = this.sellerDim.group();
I also tried something like:
this.sellerCount = this.sellerDim.group().reduceSum(function(d:any){return d.customerDim});
...but it did not work out.
for displaying the chart I am using:
this.topSellerChart = dc.rowChart("#chart-row");
this.topSellerChart.data(function(d: any){
return d.order(function (d: any) {
return d;
}).top(10);
})
.dimension(this.sellerDim)
.group(this.sellerCount)
.elasticX(true)
.controlsUseVisibility(true);
anyhow I and convinced that the mistake is during the .group()
creation.
So, does anyone know how can I group sellers without counting more then once the same customer?