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

Sum a series label

3 Answers 63 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Mindy
Top achievements
Rank 1
Mindy asked on 21 Aug 2012, 06:31 PM
I have the below code.  I am trying to format the series label so that it sums all the values of that series.   I know that the below code snippet labelDefinition.Format = "#Sum"; doesn't work.  Can you recommend something?
BarSeries ser = new BarSeries();
ser.ValueBinding = new PropertyNameDataPointBinding("IRBDuration");
ser.CategoryBinding = new PropertyNameDataPointBinding("EndYear");
ser.CombineMode = Telerik.Charting.ChartSeriesCombineMode.Stack;
ser.ShowLabels = true;
  
ChartSeriesLabelDefinition labelDefinition = new ChartSeriesLabelDefinition();
labelDefinition.Binding = new PropertyNameDataPointBinding("IRBDuration");
labelDefinition.VerticalAlignment = System.Windows.VerticalAlignment.Center;
labelDefinition.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
labelDefinition.Format = "#SUM";
ser.LabelDefinitions.Add(labelDefinition);
chart.Series.Add(ser);
ser.ItemsSource = _context.Protocols;

3 Answers, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 24 Aug 2012, 10:08 AM
Hello Mindy,

Unfortunately this is not possible out-of-the-box with the ChartView. However using some code behind I think you can get the results you need. Attach a handler to the DataBindingComplete event of the series and apply your logic on changing the labels, in your scenario - hide all labels for a single category, except the last one. The last label should display the sum of the values of all data points for this category. I have attached a simple app to demonstrate this and a snapshot of the output that I get when I run the pp.  

All the best,
Petar Marchev
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Mindy
Top achievements
Rank 1
answered on 24 Aug 2012, 01:33 PM
Thanks, I will take a look.  Also, would recommend using the RadChart or the Chartview at this point?
0
Petar Marchev
Telerik team
answered on 27 Aug 2012, 07:49 AM
Hi Mindy,

At this point I would recommend the RadChartView as it is the new charting control.

Greetings,
Petar Marchev
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ChartView
Asked by
Mindy
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Mindy
Top achievements
Rank 1
Share this question
or