HumbleSoftware / Flotr2

Graphs and Charts for Canvas in JavaScript.
http://www.humblesoftware.com/flotr2/
MIT License
2.45k stars 528 forks source link

Added series index params in pie labelFormatter #253

Closed lukeupup closed 6 years ago

lukeupup commented 10 years ago

Hi,

First of all I'd like to thank you for creating such a wonderful lib. I am using flotr2 to develop a website that contains many kinds of chart.

However, I found that there's one thing that can't satisfy my requirement - that is, I want to show some extra info in pie chart's label. Currently labelFormatter can only show the total value and current value. I added some data in the series I passed to flotr, but the pie chart just cannot access them.

I think I can show more info if I know the index of the pie slice. So I just add a count attribute, so that it can tell me what the index of the current part.

NisSAM commented 10 years ago

+1 I also think that adding series number or series object as a second parameter to labelFormat will be great. Not only for pie diagrams but for any diagram type.

lukeupup commented 10 years ago

Added more options for pie chart:

  Flotr.draw(context, data, {
    pie: {
      labelDistance: 10,
      // ...
    },
    //...
  });
  Flotr.draw(context, data, {
    pie: {
      htmlText: false, // must be false for rotating the label
      radiateLabel: true,
      // ...
    },
    //...
  });

example