Canvasjs, allow single selection of data point -
in pie chart, possible explode 1 data point @ time?
right explode (move out) clicked items in pie chart.
ashutosh,
you can try this:
var chart = new canvasjs.chart("chartcontainer", { data: [ { type: "pie",//"doughnut" 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} ] } ] }); chart.options.data[0].click = function(e){ var dataseries = e.dataseries; var datapoint = e.datapoint; var datapointindex = e.datapointindex; for(var = 0; < dataseries.datapoints.length; i++){ if(i === datapointindex){ dataseries.datapoints[i].exploded = true; }else dataseries.datapoints[i].exploded = false; } chart.render(); }; chart.render();
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script> <div id="chartcontainer" style="height: 200px; width: 100%;"></div>
Comments
Post a Comment