I am trying to display two trend lines Using a ScatterChart visualization with two trendlines, but nothing displays.
1. Is this even supported by the API?
2. If it is, what is wrong with my code?
<html>
<head>
<title>Google Charts Tutorial</title>
<script type="text/javascript">
google.charts.load('current', { 'packages': ['corechart'] });
</script>
</head>
<body>
<div id="emblem" style="width: 100%; height: 75px;"></div>
<div id="graph_container" style="width: 100%; height: 500px"></div>
<script language="JavaScript">
function drawChart()
{
// Define the chart to be drawn.
var data = new google.visualization.DataTable();
data.addColumn('number', 'Year');
data.addColumn('number', 'Rate');
data.addRows([
[2018, 9.60, 8.60],
[2019, 9.79, 8.79],
[2020, 10.08, 9.08],
[2021, 10.38, 9.38],
[2022, 10.69, 9.69]
]);
// Set chart options
var options =
{
title: 'Activity Rates',
hAxis: { title: 'Year', format:'0' },
vAxis: { title: 'Activity Rate' },
legend: 'none',
backgroundColor: 'transparent',
trendlines: { 0: { color: 'red' }, 1: { color: 'blue' } },
isStacked: true
};
// Instantiate and draw the chart.
var chart = new google.visualization.ScatterChart(document.getElementById('graph_container'));
chart.draw(data, options);
}
google.charts.setOnLoadCallback(drawChart);
</script>
</body>
</html>