Pre loader

Format piechart percentage values without decimals

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums


How can I format the percentage values in the pie chart segments to omit the decimals? e.g i want it to show 20% instead of 20.00%. The values I pass in are always rounded

  • You must to post comments

Good morning Marcus,

Pie chart labels can be formatted using a Custom class implementing SCIPieSegmentLabelFormatterBase

take a look at the Pie Chart documentation page here.

Pie Segment Label Formatter

By default, the Pie Segment Label displays a relative percentage
calculated on values of all segments in SCIPieDonutRenderableSeriesBase.segmentsCollection.
This behavior can be controlled and to do so you’ll need to subclass SCIPieSegmentLabelFormatterBase
and provide your custom data in ISCIPieSegmentLabelFormatter formatLabelForPieSegment method.
As an example, let’s create a label that displays a segment absolute
value. Assume, we create a donutSeries and add four segments with
values 40, 10, 20, and 15. Here is the code sample, how to do this:

class CustomPieSegmentLabelFormatter: SCIPieSegmentLabelFormatterBase {
      override func formatLabel(for pieSegment: ISCIPieSegment!) -> String! {
          return “\(pieSegment.value)”
  // Assume a donutSeries has been created somewhere
  let donutSeries = SCIDonutRenderableSeries()
  donutSeries.pieSegmentLabelFormatter = CustomPieSegmentLabelFormatter()

This produces the following output: enter image description here

Please let me know if this helps

Best regards

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.