2016-02-15 42 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'}}