2016-12-19 4 views
1

내 문제는 Google Charts API가있는 누적 세로 막 대형 차트에 관한 것입니다.Google Charts - 누적 세로 막 대형 차트의 트렌드

나는 글로벌 추세선을 얻으려고 노력하고있다.

<script type="text/javascript"> 
google.charts.load("current", {"packages":["corechart"]}); 
google.charts.setOnLoadCallback(drawVisualization); 
function drawVisualization() { 
var data = google.visualization.arrayToDataTable([['Month', 'OK', 'KO', 'Estimation'],[ '2016/08', 1990, 49, null ],[ '2016/09', 6892, 97, null ],[ '2016/10', 6018, 0, null ],[ '2016/11', 7329, 146, null ],[ '2016/12', 3059, 97, 1827 ]]); 
var options = { 
    isStacked: true, 
    seriesType: "bars", 
    legend: "none", 
    hAxis:{ textPosition: "none" }, 
    vAxis: { viewWindow: { min: 0, max: 8000 } }, 
    trendlines: { 0: {} } 
}; 
var chart = new google.visualization.ComboChart(document.getElementById("bar")); 
chart.draw(data, options); 
} 
</script> 

trendlines: { 0: {} },을 추가하면 결과가 없습니다.

참조 가이드에서 아무 것도 발견되지 않았습니다. 어쩌면 구현되지 않았거나 잘못 되었습니까? 문서에서 언급하지 않았지만

답변

1

, trendlines연속 X 축

에서 지원이 ... 날짜, 숫자 등되어야 첫번째 컬럼의 값을 의미

문자열 값 ...

discrete vs continuous는 참조 개별

SE 발생할 즉 다음과 같은 작업 조각 ...

첫번째 열 trendlines 있도록하는 DataView를 이용한 실제 날짜로 변환되어 ...

google.charts.load('current', { 
 
    callback: function() { 
 
    var data = google.visualization.arrayToDataTable([ 
 
     ['Month', 'OK', 'KO', 'Estimation'], 
 
     ['2016/08', 1990, 49, null], 
 
     ['2016/09', 6892, 97, null], 
 
     ['2016/10', 6018, 0, null], 
 
     ['2016/11', 7329, 146, null], 
 
     ['2016/12', 3059, 97, 1827] 
 
    ]); 
 

 
    var view = new google.visualization.DataView(data); 
 
    view.setColumns([{ 
 
     calc: function (dt, row) { 
 
     var dateParts = dt.getValue(row, 0).split('/'); 
 
     return new Date(parseInt(dateParts[0]), parseInt(dateParts[1]) - 1, 1); 
 
     }, 
 
     type: 'date', 
 
     label: data.getColumnLabel(0) 
 
    }, 1, 2, 3]); 
 

 
    var options = { 
 
     isStacked: true, 
 
     seriesType: 'bars', 
 
     legend: 'none', 
 
     hAxis: { 
 
     textPosition: 'none' 
 
     }, 
 
     vAxis: { 
 
     viewWindow: { 
 
      min: 0, 
 
      max: 8000 
 
     } 
 
     }, 
 
     trendlines: { 
 
     0: {} 
 
     } 
 
    }; 
 

 
    var chart = new google.visualization.ComboChart(document.getElementById('bar')); 
 
    chart.draw(view, options); 
 
    }, 
 
    packages:['corechart'] 
 
});
<script src="https://www.gstatic.com/charts/loader.js"></script> 
 
<div id="bar"></div>

관련 문제