Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Chart ComboChart Candlesticks with Line

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).

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);
   }
like image 462
brno792 Avatar asked Oct 02 '14 20:10

brno792


People also ask

How do I combine a bar graph and a line graph in Google Sheets?

Click the Chart button in the top right of the toolbar. OR, in the menu, select the Insert tab; you will see a chart option, choose that. In Chart type, Select “Combo Chart.”

What is combo chart?

A combo chart is a combination of two column charts, two line graphs, or a column chart and a line graph. You can make a combo chart with a single dataset or with two datasets that share a common string field. Combo charts can answer questions about your data, such as: What are the trends for the same categories?

How do I add a clustered column combo chart in Excel?

Click anywhere in the chart you want to change to a combo chart to show the CHART TOOLS. Click DESIGN > Change Chart Type. On the All Charts tab, choose Combo, and then pick the Clustered Column - Line on Secondary Axis chart.


1 Answers

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

series: {
    1: {
        type: 'line'
    }
}
like image 171
asgallant Avatar answered Oct 11 '22 15:10

asgallant