2017-01-30 5 views
1
var composite = dc.compositeChart("#test_composed"); 
var LineChart1 = dc.lineChart(composite) 
      .dimension(yearDim) 
      .colors('yellow') 
      .group(spendPerYear, "Top Line") 
      .dashStyle([2,2]) 

var LineChart2 = dc.lineChart(composite) 
      .dimension(yearDim) 
      .colors('blue') 
      .group(incomePerYear, "Bottom Line") 
      .dashStyle([5,5]) 

var abc = [LineChart1, LineChart2]; 

composite 
    .x(d3.scale.linear().domain([2011,2013])) 
    .yAxisLabel("The Y Axis") 
    .legend(dc.legend().x(80).y(20).itemHeight(13).gap(5)) 
    .renderHorizontalGridLines(true) 
    .elasticY(true) 
    .compose([ 
     //abc 
    LineChart1, LineChart2 
     ]) 
dc.renderAll(); 

このコードは機能します。しかし.composeでどうすればabc配列を含めることができるので、私はabcの配列.composeでさらにチャートをプッシュすると自動的に更新されます。私は各グラフを手動で配置する必要はありません。DC複合チャートに動的チャートを含める

基本的に私はあなたがmulti-dimensional配列として.composeを呼んでいるこの

var abc = [LineChart1, LineChart2, LineChart3, LineChart4 ....]; 
composite 
    .x(d3.scale.linear().domain([2011,2013])) 
    .yAxisLabel("The Y Axis") 
    .legend(dc.legend().x(80).y(20).itemHeight(13).gap(5)) 
    .renderHorizontalGridLines(true) 
    .elasticY(true) 
    .compose([ 
     abc 
    ]) 
+0

こんにちは、グラフ作成用ライブラリに関する質問は、dc.jsタグを使用してください。 – Gordon

答えて

0

のような機能を構成します。代わりに次のコードを使用してください:

var abc = [LineChart1, LineChart2, LineChart3, LineChart4 ....]; 
composite 
    .x(d3.scale.linear().domain([2011,2013])) 
    .yAxisLabel("The Y Axis") 
    .legend(dc.legend().x(80).y(20).itemHeight(13).gap(5)) 
    .renderHorizontalGridLines(true) 
    .elasticY(true) 
    .compose(abc) 
関連する問題