4

my requirement is to get the selected colour of the pie slice when the user clicks on it. It would be good if I can do it within the following function:

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

Any ideas? Thanks.

thecodeparadox
  • 86,271
  • 21
  • 138
  • 164
Knissanka
  • 207
  • 1
  • 3
  • 12

1 Answers1

7

Yes you can get the color :

plot.series[seriesIndex].seriesColors[pointIndex]

where plot is the var in which you store your jqPlot

Working Example here

Manse
  • 37,765
  • 10
  • 83
  • 108
  • 1
    +1 good one. Thanks for forking my sample :) Nice to see people reusing it. – Boro May 22 '12 at 12:17
  • @Boro i removed a few of the comments to try and make it easier to show the OP the code i added ... nice example though – Manse May 22 '12 at 12:36
  • @ManseUK Could you please tell me how to do this incase I want the legend name associated with that color? – Sohaib Jul 13 '13 at 10:27
  • @SilentPro if you have a question please ask one ... comments are not for asking further questions ! – Manse Jul 15 '13 at 08:32