Event fired with chart name and y value - CanvasJS
Event fired with chart name and y value - CanvasJS
by canvasjs
HTML
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div id="chartContainer" style="width:100%; height:300px"></div>
JavaScript
var chart = new CanvasJS.Chart( "chartContainer", {
title: {
text: "Click event fired with dataPoint and legend text"
},
legend: {
itemclick: function(e){
alert( "Legend item clicked with name : " + e.dataSeries.name );
}
},
data: [
{
type: "column",
showInLegend: true,
name: "Column Chart",
dataPoints: [
{ x: 10, y: 23, click: onClick},
{ x: 20, y: 13},
{ x: 30, y: 03},
{ x: 40, y: 12},
{ x: 50, y: 19},
{ x: 60, y: 27}
]
}
]
});
chart.render();
function onClick() {
alert("DataPoint clicked with y : " + chart.options.data[0].dataPoints[0].y );
}