2016-02-15 43 views
0

我正在嘗試用燭臺和趨勢線創建一個combochart。Google Charts Combochart與燭臺

<html> 
<head> 
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> 
<script type="text/javascript"> 
    google.charts.load('current', {'packages':['corechart']}); 
    google.charts.setOnLoadCallback(drawChart); 
function drawChart() { 
var data = google.visualization.arrayToDataTable([ 
    [Date(2016, 2, 14, 8, 0), 20, 28, 38, 45], 
    [Date(2016, 2, 14, 8, 1), 31, 38, 55, 66], 
    [Date(2016, 2, 14, 8, 2), 50, 55, 77, 80], 
    [Date(2016, 2, 14, 8, 3), 77, 77, 66, 66] 
], true); 

var options = { 
     legend: 'none', 
     bar: { groupWidth: '90%' }, 
     candlestick: { 
     fallingColor: { strokeWidth: 0, fill: '#a52714' }, // red 
     risingColor: { strokeWidth: 0, fill: '#0f9d58' } // green 
     }, 
     seriesType: 'candlesticks', 
     series: {5: {type: 'line'}} 


    }; 


var chart = new google.visualization.ComboChart(document.getElementById('chart_div')); 

chart.draw(data, options); 
} 

</script> 
</head> 

<body> 

<div id="chart_div"></div> 
</body> 
</html> 

這就形成了一個陰陽燭圖,但是當我添加數據的趨勢線,我得到錯誤信息「最後域沒有足夠的數據列(失蹤3)。」

[Date(2016, 2, 14, 8, 0), 20, 28, 38, 45, 25], 
    [Date(2016, 2, 14, 8, 1), 31, 38, 55, 66, 30], 
    [Date(2016, 2, 14, 8, 2), 50, 55, 77, 80, 35], 
    [Date(2016, 2, 14, 8, 3), 77, 77, 66, 66, 40] 

回答

0

我想通了。

series: {1: {type: 'line'}}