Display Value with Label

1 Answer 74 Views
Charts Styling
MiDAS
Top achievements
Rank 1
Iron
Iron
MiDAS asked on 07 Nov 2022, 08:29 PM

I am using a donut chart and have data with wide varying data values. This means that some of the individual segments can be very small. I would like to display the value next to each label e.g. Active [890], Backlog [2156], Rejected [2].

I need this for both labels around the chart or in the Legend on charts where I only display the legend.

Attached chart shows an example of my chart. The yellow highlights are where I'd like the data value to appear.

Thanks

1 Answer, 1 is accepted

Sort by
1
Accepted
Hetali
Telerik team
answered on 08 Nov 2022, 10:10 PM

Hello,

In order to modify the Series label and Legend label to show the value with the text, use the content property of the SeriesLabelsComponent and the labels property of the LegendComponent. For example:

<kendo-chart [style.height.px]="200" [transitions]="false">
  <kendo-chart-series>
  <kendo-chart-series-item type="donut" [data]="data">
    <kendo-chart-series-item-labels
      [content]="labelContent"
      >
      </kendo-chart-series-item-labels>
    </kendo-chart-series-item>
  </kendo-chart-series>
  <kendo-chart-legend
    [labels]="{ content: legendContent }"
  >
  </kendo-chart-legend>
</kendo-chart>

public labelContent(e: SeriesLabelsContentArgs): string {
  return e.category + " [" + e.value + "]";
}

public legendContent(e: LegendLabelsContentArgs): string {
  return e.text + " [" + e.value + "]";
}


In this StackBlitz example, I have shown item value after the text in both Series label and Legend label of the Kendo UI Donut Chart.

I hope this helps. Please let me know if I can further assist you.

Regards,
Hetali
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Charts Styling
Asked by
MiDAS
Top achievements
Rank 1
Iron
Iron
Answers by
Hetali
Telerik team
Share this question
or