Relative Value at the Bars (percentage )

2 posts, 0 answers
  1. ksafadi
    ksafadi avatar
    11 posts
    Member since:
    Oct 2012

    Posted 28 Nov 2012 Link to this post


    I am using the telerik winform components specially the bar char view. I created a bar series where we set the combine mode to bar100 so that we can see the percentage values at the x-axes. My problem is that we want to display the percentage values directly at the bars instead at absolute values. 

    Does anybody know how I can display the relative value at the bars?


  2. Ivan Petrov
    Ivan Petrov avatar
    715 posts

    Posted 03 Dec 2012 Link to this post

    Hello Karim,

    Thank you for writing.

    You can use RadChartView's LabelFormatting event to customize the text displayed in the labels. Here is a code snippet which demonstrates how to do it in your case:
    private void radChartView1_LabelFormatting(object sender, ChartViewLabelFormattingEventArgs e)
      CategoricalDataPoint point = e.LabelElement.DataPoint as CategoricalDataPoint;
      double total = 0d;
      foreach (BarSeries series in this.radChartView1.Series)
        foreach (CategoricalDataPoint dp in series.DataPoints)
          if (dp.Category.Equals(point.Category) && dp.Value.HasValue)
            total += dp.Value.Value;
      e.LabelElement.Text = string.Format("{0:P2}", (point.Value / total));

    I hope this will be useful. Should you have further questions, I would be glad to help.
    Kind regards,
    Ivan Petrov
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Back to Top