1

This post show how to add same chart type (line) How to add another data series to a Google chart

and this one is not really candlestick chart Candlesticks is always on top of lines in combo chart google chart

True candlestickcharts are not combochart https://developers.google.com/chart/interactive/docs/gallery/candlestickchart

so is it possible to add a line and/or bar chart to a true candlestick google chart ?

user310291
  • 36,946
  • 82
  • 271
  • 487

1 Answers1

1

use the series option to change the type...

the four candlestick columns will be considered series #: 0

see following working snippet...

google.charts.load('current', {
  packages: ['corechart']
}).then(function () {
  var data = google.visualization.arrayToDataTable([
    ['Day', 'Candlestick', 'Begin', 'End', 'High'],
    ['Mon', 20, 28, 38, 45],
    ['Tue', 31, 38, 55, 66],
    ['Wed', 50, 55, 77, 80],
    ['Thu', 77, 77, 66, 50],
    ['Fri', 68, 66, 22, 15]
  ]);

  // add column for line, add data to rows...
  var colIndex = data.addColumn('number', 'Line');
  for (var i = 0; i < data.getNumberOfRows(); i++) {
    data.setValue(i, colIndex, data.getValue(i, 1));
  }

  var options = {
    height: 400,
    series: {
      1: {
        type: 'line'
      }
    }
  };

  var chart = new google.visualization.CandlestickChart(document.getElementById('chart_div'));
  chart.draw(data, options);
});
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>
WhiteHat
  • 59,912
  • 7
  • 51
  • 133