JavaScript
var chart = new CanvasJS.Chart("chartContainer", {
legend:
{
fontSize: 12,
fontWeight:"bold",
fontFamily:"'Montserrat',sans-serif",
cursor: "pointer",
dockInsidePlotArea: false,
itemclick: toggleDataSeries
},
data: [
{
showInLegend:true,
type: "line",
dataPoints: [
{ x: 10, y: 71 },
{ x: 20, y: 55 },
{ x: 30, y: 50 },
{ x: 40, y: 65 },
{ x: 50, y: 95 },
{ x: 60, y: 68 },
{ x: 70, y: 28 },
{ x: 80, y: 34 },
{ x: 90, y: 14 }
]
} ,
{
showInLegend:true,
type: "line",
dataPoints: [
{ x: 11, y: 73 },
{ x: 21, y: 56},
{ x: 31, y: 57 },
{ x: 41, y: 68 },
{ x: 51, y: 98 },
{ x: 61, y: 69 },
{ x: 71, y: 29 },
{ x: 81, y: 39 },
{ x: 91, y: 14 }
]
} ,
{
showInLegend:true,
type: "line",
dataPoints: [
{ x: 15, y: 71 },
{ x: 25, y: 55 },
{ x: 35, y: 50 },
{ x: 45, y: 65 },
{ x: 55, y: 101 },
{ x: 65, y: 69},
{ x: 75, y: 27 },
{ x: 85, y: 36 },
{ x: 95, y: 13 }
]
}
]
});
function toggleDataSeries(e)
{
if (typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible)
{
e.dataSeries.visible = false;
}
else
{
e.dataSeries.visible = true;
}
chart.render();
}
chart.render();