Google Charts Combochart与烛台

时间:2016-02-15 07:00:55

标签: google-visualization

我正在尝试使用烛台和趋势线创建一个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]

1 个答案:

答案 0 :(得分:0)

我明白了。

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