JavaScript
var chart = new CanvasJS.Chart("chartContainer",
{
title: {
text: "Chart with additional toolTip content"
},
toolTip: {
shared: true,
contentFormatter: function (e) {
var content = CanvasJS.formatDate(e.entries[0].dataPoint.x, "DD MMM YY") + "<br/>";
for (var i = 0; i < e.entries.length; i++) {
content += e.entries[i].dataSeries.name + " : " + "<strong>" + e.entries[i].dataPoint.y + "</strong>" + " " + e.entries[i].dataPoint.extraContent;
content += "<br/>";
}
return content;
}
},
axisX: {
gridColor: "Silver",
valueFormatString: "DD/MMM"
},
axisY: {
includeZero: false
},
data: [
{
name: "Error",
type: "area",
legendMarkerType: "triangle",
axisYIndex: 0, //defaults to 0
color: "#B61919",
showInLegend: true,
dataPoints: [
{ x: new Date(2021,10,20), y: 1, extraContent: "(5)" },
{ x: new Date(2021,10,21), y: 3, extraContent: "(1,4,3)"},
{ x: new Date(2021,10,22), y: 2, extraContent: "(2,3)" }
]
},
{
name: "WARNING",
type: "line",
legendMarkerType: "circle",
axisYIndex: 1,
color: "#f6a603",
showInLegend: true,
dataPoints : [
{ x: new Date(2021,10,20), y: 3, extraContent: "(10,`12)" },
{ x: new Date(2021,10,21), y: 2, extraContent: "(1,4,8)"},
{ x: new Date(2021,10,22), y: 1, extraContent: "(2,3,11)" }
]
},
{
name: "SIGNAL",
type: "area",
legendMarkerType: "cross",
axisYIndex: 2,
markerSize: 0,
color: "purple",
showInLegend: true,
dataPoints : [
{ x: new Date(2021,10,20), y: 4, extraContent: "(2)" },
{ x: new Date(2021,10,21), y: 3, extraContent: "(1,4,3,2)"},
{ x: new Date(2021,10,22), y: 2, extraContent: "(2,1)" }
]
}
]
});
chart.render();