JQPlot - Pie Chart - Get Click Color

My requirement is to get the selected slice color of the cake when the user clicks on it. It would be nice if I could do this as part of the following function:

$('#chart1').bind('jqplotDataClick', function (ev, seriesIndex, pointIndex, data) { alert("ev = " + ev + " seriesIndex = " + seriesIndex + "pointIndex = " + pointIndex + "data = " + data); }); 

Any ideas? Thanks.

+4
source share
1 answer

Yes, you can get the color:

 plot.series[seriesIndex].seriesColors[pointIndex] 

where plot is var in which you store your jqPlot

Working example here

+7
source

Source: https://habr.com/ru/post/1413734/


All Articles