score:0

Accepted answer

Currently your best bet is to create a fake group. Really the .data method on the charts is supposed to do this, but it doesn't work for charts that derive from the stack mixin.

https://github.com/dc-js/dc.js/wiki/FAQ#filter-the-data-before-its-charted

score:2

I believe you are asking a few questions here. I will try to answer the main question: how do you add data to a dc chart.

I created an example here: http://jsfiddle.net/djmartin_umich/qBr7y/

In this example I simply add random data to the crossfilter, though this could easily be adapted to pull data from the server:

function AddData(){
  var q = Math.floor(Math.random() * 6) + 1;
  currDate = currDate.add('month', 1);
  cf.add( [{date: currDate.clone().toDate(), quantity: q}]);  
  $("#log").append(q + ", ");
}

I call this method once a second. Once it completes, I reset the x domain and redraw the chart.

window.setInterval(function(){
  AddData();
  lineChart.x(d3.time.scale().domain([startDate, currDate]));
  dc.redrawAll();
}, 1000);

I recommend trying to get this working in isolation before trying to add the complexity of multiple y-axis scales.


Related Query