Skip to content

Instantly share code, notes, and snippets.

@natke
Last active September 25, 2022 20:32
Show Gist options
  • Save natke/7a801305791da761da5ed877d60dbdb0 to your computer and use it in GitHub Desktop.
Save natke/7a801305791da761da5ed877d60dbdb0 to your computer and use it in GitHub Desktop.
Google chart
google.charts.load('current', {packages: ['corechart', 'line']});
google.charts.setOnLoadCallback(drawBasic);
function drawBasic() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Date');
data.addColumn('number', 'MAU');
data.addColumn('number', 'search %')
data.addRows([
["Oct 2021", 10041, 54],
["Nov 2021", 11664, 59],
["Dec 2021", 13078, 60],
["Jan 2021", 13591, 65],
["Feb 2022", 14276, 67],
["Mar 2022", 18674, 65],
["Apr 2022", 18617, 67],
["May 2022", 20391, 64],
["Jun 2022", 22063, 65],
["Jul 2022", 21732, 66],
["Aug 2022", 22421, 68],
["Sep 2022", 23833, 69]]);
var options = {
vAxes: {0: {viewWindow: {min: 0, max: 25000},
title: 'MAU',
curveType: 'function'},
1: {viewWindow: {min: 0, max: 100},
title: 'Search %',
curveType: 'function'}},
series:{
0:{targetAxisIndex:0},
1:{targetAxisIndex:1}}};
//var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment