1

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!

Kai Feng Chew
  • 779
  • 8
  • 24
  • Looks to me like a straight dc.js question, queue.js is just a way to make sure the data is loaded before initializing the chart. Could you post a jsfiddle with your non-working pieChart? If you look at the pie chart examples or the API reference, you will see that the API is a bit different - for example, there is no `.x()`, for obvious reasons. – Gordon May 02 '14 at 18:44
  • @Gordon You're right! To change to pieChart, actually is easy. Let's use the composite2 above. In normal case, We just need to 1. remove the .x() 2. remove the .brushOn() 3. add .radius() 4. changing lineChart to pieChart. After with Queue.js, it is just not working... :( http://jsfiddle.net/8K66Q/ – Kai Feng Chew May 04 '14 at 02:12

2 Answers2

0

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

Chad
  • 90
  • 7
0

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.

Gordon
  • 19,811
  • 4
  • 36
  • 74