Kai Feng Chew
Kai Feng Chew

Reputation: 779

PieChart in DC.js with Queue.js not working

Here is an example using Queue.js to loading multiple csv in a dc.js : https://github.com/dc-js/dc.js/blob/master/web/examples/composite.html

Here is my version (javascript):

var composite = dc.compositeChart("#test_composed");
var composite2 = dc.compositeChart("#test_composed2");

var q = queue()
  .defer(d3.csv, "morley.csv")
  .defer(d3.csv, "morley2.csv");

q.await(function(error, exp1, exp2) {

var ndx = crossfilter();
ndx.add(exp1.map(function(d) {
    return {x: d.Run};
}));
ndx.add(exp2.map(function(d) {
    return {x: d.Run};
}));

var dim  = ndx.dimension(dc.pluck('x')),
    grp = dim.group().reduceCount(dc.pluck('x'));  

composite
    .width(768)
    .height(480)
    .x(d3.scale.linear().domain([0,200]))
    .compose([
        dc.barChart(composite)
            .dimension(dim)
            .group(grp)
        ])
    .brushOn(false)
    .render();

composite2
    .width(768)
    .height(480)
    .x(d3.scale.linear().domain([0,200]))
    .compose([
        dc.lineChart(composite2)
            .dimension(dim)
            .group(grp)
        ])
    .brushOn(false)
    .render();    
});

Using the same data, should be good as picture attached.

my version of composite charts of line and bar with original datasets

It worked very well for lineChart and barChart but not working for pieChart, rowChart...

Is there any similiar example for working pieChart?

Thanks!

Upvotes: 1

Views: 401

Answers (2)

Gordon
Gordon

Reputation: 20150

Thanks for posting a jsfiddle. If you complete your fiddle, we can better help you troubleshoot it. ;-)

Looks like you are trying to create a composite chart with a pieChart. That's unusual - why do you want to do that? Normally a composite is for when you want to overlay different charts, but you've only got the one chart in your fiddle.

I'm not sure if the composite chart works with non-grid charts.

Upvotes: 0

Chad
Chad

Reputation: 90

I know this doesn't really solve your problem but I'm just letting you know of a different solution. Google code playground shows off some of the cool code google has for developers to use. Check out these links Bar Chart: https://code.google.com/apis/ajax/playground/#bar_chart

Upvotes: 0

Related Questions