Change the color of Column on-click over data-point - CanvasJS JavaScript Charts
Change the color of Column on-click over data-point - CanvasJS JavaScript Charts
HTML
<script src="http://canvasjs.com/assets/script/canvasjs.min.js"></script>
<br/><!-- Just so that JSFiddle's Result label doesn't overlap the Chart -->
<div id="chartContainer" style="height: 360px; width: 100%;"></div>
JavaScript
var chart = new CanvasJS.Chart("chartContainer",
{
title:{
text:"Click on the dataPoints to change the color"
},
axisX:{
labelMaxWidth:30
},
data: [
{
type: "column",
color: "blue",
click: function(e){
e.dataPoint.indexLabel = "{label}",
e.dataPoint.color = "red";
e.chart.render();
},
//indexLabelMaxWidth: 30,
dataPoints: [
{ label: "21 June", y: 71 },
{ label: "22 June", y: 55},
{ label: "23 June", y: 50 },
{ label: "24 June", y: 65 },
{ label: "25 June", y: 95 },
{ label: "26 June", y: 68 },
{ label: "27 June", y: 28 },
{ label: "28 June", y: 34 },
{ label: "29 June", y: 14}
]
}
]
});
chart.render();