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는 차트 라이브러리에 대한 질문을하시기 바랍니다. dc는 아주 다른 것입니다. – 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)