How to draw a yy axis line chart in google charts

I am assigned to create a google chart where I need to implement a line chart with two y-axes. Although, google has a guide only for single y-axis diagrams. How can I implement a line with two y-axis lines using google diagram. I am using ajax answer to get the relevant data! If anyone can help me with a good tutorial or sample code, that would be very grateful.

I created a sample graph to get an idea of ​​what I'm trying to do.

enter image description here

Thanks.

+4
source share
1 answer
function drawVisualization() { // Create and populate the data table. var data = google.visualization.arrayToDataTable([ ['x', 'Data 1', 'Data 2', 'Data 3'], ['A', 1, 1, 0.5], ['B', 2, 0.5, 1], ['C', 4, 1, 0.5], ['D', 8, 0.5, 1], ['E', 7, 1, 0.5], ['F', 7, 0.5, 1], ['G', 8, 1, 0.5], ['H', 4, 0.5, 1], ['I', 2, 1, 0.5], ['J', 3.5, 0.5, 1], ['K', 3, 1, 0.5], ['L', 3.5, 0.5, 1], ['M', 1, 1, 0.5], ['N', 1, 0.5, 1] ]); // Create and draw the visualization. new google.visualization.LineChart(document.getElementById('visualization')). draw(data, {vAxes:[ {title: 'Title 1', titleTextStyle: {color: '#FF0000'}, maxValue: 10}, // Left axis {title: 'Title 2', titleTextStyle: {color: '#FF0000'}, maxValue: 20} // Right axis ],series:[ {targetAxisIndex:1}, {targetAxisIndex:0} ],} ); }​ 
+6
source

Source: https://habr.com/ru/post/1481696/


All Articles