Combo Chart Example Two Axes
Two axes example
by Gonzalo Guevara
HTML
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
JavaScript
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawVisualization);
function drawVisualization() {
// Some raw data (not necessarily accurate)
var data = google.visualization.arrayToDataTable([
[ 'Genre', 'Resultado del Ejercicio', 'ROA', 'ROE', { role: 'annotation' } ],
['2009', -370830.93, -56.46, 327.57, ''],
['2010', -455949.97, -68.24, 280.61, ''],
['2011', -368860.80, -49.27, 2418.71, ''],
['2012', -440973.70, -52.41, -192.80, ''],
['2013', -472139.50, -48.84, -131.90, ''],
['2014', -499909.10, -47.71, -119.67, ''],
['2015', -724753.00, -68.44, -208.70, ''],
['2016', -837807.34, -78.46, -421.43, '']
]);
var options = {
title : 'Monthly Coffee Production by Country',
//vAxis: {title: 'Cups'},
//hAxis: {title: 'Año'},
seriesType: 'bars',
series: {
0: {
targetAxisIndex:0
},
1: {type: 'line', targetAxisIndex: 1},
2: {type: 'line', targetAxisIndex: 1}
},
vAxes: {
0: {
title:'Losses',
textStyle: {color: 'red'}
},
1: {
title:'Cosas locas',
format:"percent"
}
}
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
chart.draw(data, options);
}