Read the color of dataPoints

Click on the dataPoint and get particular datapoint's color. Set the color explicitly

by Anjali Jain

HTML

<script src="http://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div id="chartContainer" style="width:100%; height:300px;"></div>

JavaScript

var colorSet = ["#369EAD",
			    "#C24642",
			    "#7F6084",
			    "#86B402",
                "#A2D1CF",			
                "#C8B631",
                "#6DBCEB",			
                "#52514E",
                "#4F81BC",
                "#A064A1",
                "#F79647"]; 
	CanvasJS.addColorSet("custom",colorSet);   
    
	var chart = new CanvasJS.Chart("chartContainer", {
	colorSet: "custom",  
	title:{
		text: "Determining DataPoint's Color"
    },
    data: [
    {        
        type: "column",
        dataPoints: [
            { x: 10, y: 71 },
	        { x: 20, y: 55 },
	        { x: 30, y: 50 },
	        { x: 40, y: 65 },
	        { x: 50, y: 95 },
	        { x: 60, y: 68 },
	        { x: 70, y: 28 },
	        { x: 80, y: 34 },
	        { x: 90, y: 14 },
            { x: 100, y : 23},
            { x: 110, y : 90},
            { x: 120, y : 39},
            { x: 130, y : 56},
            { x: 140, y : 43}
        ],
        click: function(e){
          alert(colorSet[e.dataPointIndex % colorSet.length]);
      },
    }
    ]
	});
	chart.render();