[Chartjs]-Chart.js increase value on click

2đź‘Ť

You can use function “getPointsAtEvent”, which returns ChartElement:

ChartElement {value: 4, label: "January", datasetLabel: "My First dataset", x: 197.1083317156525, y: 125.62930048634354…}

To work with this function:

var canvas = document.getElementById("myChart") canvas.onclick = function(evt){
var activePoints = myRadarChart.getPointsAtEvent(evt);
activePoints[0].value++;
myRadarChart.update();
console.log(activePoints[0]); };

See full example: http://jsfiddle.net/pevy7vsz/29/

Leave a comment