Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google combo charts with stacked bar and lines

Wondering if someone can help, I am trying to create google charts using stacked bars and two lines.I am able to create with one line, but not sure how I can add another line into same chart. I want to show "Average2" as a line chart.

google.setOnLoadCallback(drawVisualization);

function drawVisualization() {
  // Some raw data (not necessarily accurate)
  var data = google.visualization.arrayToDataTable([
    ['Month', 'Bolivia', 'Ecuador',   'Average1' , 'Average2'],
    ['April',  165,      938, 614.6 , 400],
    ['May',  135,      1120,  682 , 500],
    ['June',  157,      1167,  623, 600],
    ['July',  139,      1110,  609.4, 450],
    ['August',  136,      691,   569.6 , 700]
  ]);

  var options = {
    title : 'Month (Q2-Q1 2015)',
    vAxis: {title: ""},
    hAxis: {title: ""},
      isStacked: true,
    seriesType: "bars",
    series: {2: {type: "line"}},
 
  };

  var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
  chart.draw(data, options);
}
<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.1','packages':['corechart']}]}"></script>
       <div id="chart_div" style="width: 900px; height: 500px;"></div>
like image 646
niku Avatar asked Apr 28 '15 23:04

niku


1 Answers

Try:

series: {2: {type: "line"}, 3: {type: "line"}},
like image 56
user4941745 Avatar answered Oct 07 '22 13:10

user4941745