Skip to content

Instantly share code, notes, and snippets.

@jeffersfp
Forked from jgonera/gist:3084341
Created March 31, 2017 17:49
Show Gist options
  • Save jeffersfp/f0d7bac747621b892ccf331a7769ad5d to your computer and use it in GitHub Desktop.
Save jeffersfp/f0d7bac747621b892ccf331a7769ad5d to your computer and use it in GitHub Desktop.
Google Chart: Scatter Chart with a line
<!doctype html>
<html>
<head>
<title>Google Chart: Scatter Chart with a line</title>
<meta charset="UTF-8" />
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", { packages: ["corechart"] });
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['X', 'Points', 'Line'],
[3, 3.5, 1],
[4, 5.5, 2],
[4, 5, null],
[6.5, 7, 3],
[8, 12, 4],
[11, 14, 5]
]);
var options = {
title: 'Scatter Chart with a line',
hAxis: { title: 'X', minValue: 0, maxValue: 15 },
vAxis: { title: 'Y', minValue: 0, maxValue: 15 },
legend: 'none',
interpolateNulls: true,
series: {
1: { lineWidth: 1, pointSize: 0 }
}
};
var chart = new google.visualization.ScatterChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment