content - Sets Content for Tool Tip - 0 | JSFiddle Sample Code
content - Sets Content for Tool Tip - 0 | JSFiddle Sample Code
by Ragu Nathan
HTML
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div id="chartContainer" style="height: 300px; width: 100%;"></div>
<div style="margin-top:16px;color:dimgrey;font-size:9px;font-family: Verdana, Arial, Helvetica, sans-serif;text-decoration:none;">Source: <a href="https://canvasjs.com/docs/charts/chart-options/tooltip/content/" target="_blank" title="content - Sets Content for Tool Tip ">https://canvasjs.com/docs/charts/chart-options/tooltip/content/</a></div>
JavaScript
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer",
{
title:{
text: "Using Keywords inside content string"
},
toolTip:{
shared: true,
content: "{name}: {y}" ,
contentFormatter: (e) => {
if (e.entries[0].dataSeries.name === "Visits") {
return null;
}
return e.entries[0].dataSeries.name + " - " + e.entries[0].dataPoint.y;
}
},
axisX:{
gridColor: "Silver",
valueFormatString: "DD/MMM"
},
axisY2: {
includeZero: false,
toolTipContent: null,
},
data: [
{
type: "line",
showInLegend: true,
name: "Visits",
dataPoints: [
{ x: new Date(2010,0,3), y: 650 },
{ x: new Date(2010,0,4), y: 700 },
{ x: new Date(2010,0,5), y: 710 },
{ x: new Date(2010,0,6), y: 658 },
{ x: new Date(2010,0,7), y: 734 },
{ x: new Date(2010,0,8), y: 963 },
{ x: new Date(2010,0,9), y: 847 },
{ x: new Date(2010,0,10), y: 853 },
{ x: new Date(2010,0,11), y: 869 },
{ x: new Date(2010,0,12), y: 943 },
{ x: new Date(2010,0,29), y: 970 }
]
},
{
type: "line",
showInLegend: true,
name: "Unique Visits",
axisYType: "secondary",
dataPoints: [
{ x: new Date(2010,0,3), y: 510 },
{ x: new Date(2010,0,4), y: 560 },
{ x: new Date(2010,0,5), y: 540 },
{ x: new Date(2010,0,6), y: 558 },
{ x: new Date(2010,0,7), y: 544 },
{ x: new Date(2010,0,10), y: 693 },
{ x: new Date(2010,0,11), y: 657 },
{ x: new Date(2010,0,12), y: 663 },
{ x: new Date(2010,0,19), y: 639 },
{ x: new Date(2010,0,21), y: 673 },
{ x: new Date(2010,0,29), y: 660 }
]
}
]
});
chart.render();
}