带图表的Google Chart ComboChart烛台

时间:2021-10-09 12:54:28

I have looked at the docs for combo charts and am able to reproduce a bar chart with a line as a different series. But how do I have a candlestick chart with a line as a different series?

我查看了组合图表的文档,并能够重现一个条形图,其中一条线作为一个不同的系列。但是如何将烛台图表作为不同的系列?

When I try, I get the error Last domain does not have enough data columns (missing 3). Yes, I am adjusting my datatable so it has the right number of variables (columns).

当我尝试时,我得到错误最后一个域没有足够的数据列(缺少3)。是的,我正在调整我的数据表,因此它具有正确数量的变量(列)。

Date, Low, Open, High, Close, Average

I can create a candlestick combo chart with only one series when my data looks like:

我的数据如下所示,我可以创建一个只有一个系列的烛台组合图:

Date, Low, Open, High, Close

What is happening when I add another column?

添加另一列时发生了什么?

Update:

更新:

    google.load("visualization", "1", {packages:["corechart"]});
    google.setOnLoadCallback(drawChart);  
    function drawChart() {
        var data = google.visualization.arrayToDataTable([
            ['Date',     'Low', 'Open', 'High', 'Close', 'Average'],
            ['2014/05',   200,   300,    500,    400,     350],
            //...
        ]);

        var options = {
            seriesType: "candlesticks",
            series: {
                5: {type: "line"}
            }
        };

        var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
        chart.draw(data, options);
   }

1 个解决方案

#1


2  

The "line" series is the 2nd data series, not the 6th, so your series option should be:

“line”系列是第2个数据系列,而不是第6个,所以你的系列选项应该是:

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

#1


2  

The "line" series is the 2nd data series, not the 6th, so your series option should be:

“line”系列是第2个数据系列,而不是第6个,所以你的系列选项应该是:

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