Multi Series Line Chart - CanvasJS
Creating Multi Series Line Chart - CanvasJS HTML5 Charts
HTML
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div id="chartContainer" style="height: 360px; width: 100%;"></div>
<p class="description">Built using <a href="http://canvasjs.com" title="CanvasJS HTML5 Charts" target="_blank">CanvasJS HTML5 Charts</a>
</p>
CSS
.description{
margin-top: 50px;
text-align:left;
font-family: calibri;
font-size: 16px;
color: gray;
}
a:link, a:visited, a:active{color: #4F81BC;}
JavaScript
//Creating a multi-series line graph from 2 sets of data. Namely dps1 and dps2.
var dps1 = [{ x: 0, y: 10 }, { x: 2, y: 17 }, { x: 3, y: 29 }]; //dataPoints – line 1
var dps2 = [{ x: 1, y: 15 }, { x: 2, y: 28 }, { x: 3, y: 42 }]; //dataPoints. – line 2
var chart = new CanvasJS.Chart("chartContainer", {
title:{
text: "Earthquakes - per month"
},
axisX: {
minimum: new Date(2012, 01, 1),
maximum: new Date(2012, 11, 1),
},
data: [
{
type: "line",
indexLabel: "Some label",
indexLabelTextAlign: "right",
dataPoints: [
{ x: new Date(2012, 02, 1), y: 520 },
{ x: new Date(2012, 03, 1), y: 460 },
{ x: new Date(2012, 04, 1), y: 450 },
{ x: new Date(2012, 05, 1), y: 500 },
{ x: new Date(2012, 06, 1), y: 480 },
{ x: new Date(2012, 07, 1), y: 480 },
{ x: new Date(2012, 08, 1), y: 410 },
{ x: new Date(2012, 09, 1), y: 500 },
{ x: new Date(2012, 10, 1), y: 480 }
]
}
]
// end of data for 2 line graphs
}); // End of new chart variable
chart.render();