This is a migrated thread and some comments may be shown as answers.

series.name is undefined on custom pie chart legend items

3 Answers 321 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Brady
Top achievements
Rank 1
Brady asked on 14 Mar 2016, 06:39 PM

I created a custom legend visual for some column charts we are using. When I tried to apply the same visual to a pie chart the series name is undefined. I see there is a e.options.series.data[] property but I have no way to figure out what index I am currently on. How do you create a custom legend item for a pie chart?

I created an example of the issue. Line 56.

http://plnkr.co/edit/WJ2J5Meor3AVC5pckhXk?p=preview

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 16 Mar 2016, 10:01 AM
Hello,

The series.name will be undefined because the pie chart has a single series and a name is not set in the options. The text for the corresponding item would be the category from the point data which can be found from the series data and the argument pointIndex field:
function drawLegendItem(e) {
    var seriesName = e.series.data[e.pointIndex].name;


Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Brady
Top achievements
Rank 1
answered on 16 Mar 2016, 09:00 PM
That works perfect. I was looking for a property like that but I must have completely overlooked it. Thanks.
0
beauXjames
Top achievements
Rank 2
answered on 24 Jul 2018, 07:41 PM

That's the answer! Took a little digging, but I'm happy to see it work. Here's a plunkr for anyone wanting to see it in action :: https://plnkr.co/edit/6RWPIWHyVH8GdIUw1Xpk?p=preview

Thanks!

Tags
Charts
Asked by
Brady
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Brady
Top achievements
Rank 1
beauXjames
Top achievements
Rank 2
Share this question
or