Pie Chart Series

1 Answer 175 Views
Chart
Richard
Top achievements
Rank 4
Iron
Iron
Iron
Richard asked on 15 Nov 2021, 05:55 PM

Good afternoon,

I have created a pie chart based on a ViewModel that contains:
int OperatorId,
string OperatorName,
int OperatorTotal

The chart series is created with a click event as:

.Series(series => series .Pie(model => model.OperatorTotal, model => model.OperatorName) .ColorField("Color") .Padding(0) )
.Events(events => events.SeriesClick("onPieChartClick"))

I can access e.series.name and e.category in the click event which gives me the OperatorName, but I really need the OperatorId.

Is there a way that I can group the pie chart by Id but display the name, or pass the Id in the click event?

Many thanks

Richard

1 Answer, 1 is accepted

Sort by
1
Accepted
Stoyan
Telerik team
answered on 18 Nov 2021, 04:03 PM

Hello Richard,

Thank you for the comprehensive explanation of the scenario at hand. 

The SeriesClick event also exposes a dataItem property which holds the series' Model item. To access it use the e.dataItem syntax.

function onPieChartClick(e){
     console.log(e.dataItem);
}

I hope this information is useful. Please let me know, if further questions on the topic arise. Thank you.


Regards,
Stoyan
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Richard
Top achievements
Rank 4
Iron
Iron
Iron
commented on 18 Nov 2021, 06:34 PM

Hi Stoyan,

Many thanks for your answer - it is exactly what I am looking for.

Regards,

Richard

Tags
Chart
Asked by
Richard
Top achievements
Rank 4
Iron
Iron
Iron
Answers by
Stoyan
Telerik team
Share this question
or