Hi,
I am trying to configure the legend items shown in a RadLegend control associated to a RadPieChart.
This is how I load the data:
I am creating a PieSeries and adding some PieDataPoint. For each data point I add the value and the label, and I think the RadLegend takes this label to show its items. Am I correct?
In the beginning I wasn't using the RadLegend so I was showing the name and the value in the chart, assigning both values to Label:
And then I added the RadLegend Control and it shows the same values.
How can I configure the RadLegend control to show only the names if I change the Label shown in the RadPieChart to show only the values?
I am trying to configure the legend items shown in a RadLegend control associated to a RadPieChart.
This is how I load the data:
<Window xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="WpfApplication1.MainWindow" Title="MainWindow" Height="594.024" Width="902.888"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <telerik:RadPieChart Name="PieChartDemo" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="543" Width="428"/> <telerik:RadLegend x:Name="PieLegend" Grid.Column="1" Items="{Binding LegendItems, ElementName=PieChartDemo}"/> </Grid></Window>public MainWindow() { InitializeComponent(); FillPieChart(); } void FillPieChart() { DataTable dtData = new DataTable("DATA"); dtData.Columns.Add(new DataColumn("Name", typeof(string))); dtData.Columns.Add(new DataColumn("Value", typeof(double))); dtData.Rows.Add(new object[] { "Scrap", 5429287.5 }); dtData.Rows.Add(new object[] { "KWH", 713631 }); dtData.Rows.Add(new object[] { "Electrode", 327349 }); dtData.Rows.Add(new object[] { "Alloys", 2372722.3 }); dtData.Rows.Add(new object[] { "Fluxes", 317157.65 }); dtData.Rows.Add(new object[] { "Labor", 300084.1 }); PieChartDemo.Palette = ChartPalettes.Arctic; PieSeries pieSer = new PieSeries(); pieSer.ShowLabels = true; foreach (DataRow drCost in dtData.Rows) { pieSer.DataPoints.Add(new PieDataPoint() { Value = double.Parse(drCost["Value"].ToString()), Label = string.Format("{0}\n{1:N} K", drCost["Name"].ToString(), double.Parse(drCost["Value"].ToString()) / 1000.00) } ); } pieSer.LabelDefinitions.Add(new ChartSeriesLabelDefinition() { Margin = new Thickness(-5, 0, 0, 0) }); pieSer.AngleRange = new AngleRange(270, 360); pieSer.LegendSettings = new DataPointLegendSettings(); PieChartDemo.Series.Clear(); PieChartDemo.Series.Add(pieSer); }I am creating a PieSeries and adding some PieDataPoint. For each data point I add the value and the label, and I think the RadLegend takes this label to show its items. Am I correct?
In the beginning I wasn't using the RadLegend so I was showing the name and the value in the chart, assigning both values to Label:
pieSer.DataPoints.Add(new PieDataPoint() { Value = double.Parse(drCost["Value"].ToString()), Label = string.Format("{0}\n{1:N} K", drCost["Name"].ToString(), double.Parse(drCost["Value"].ToString()) / 1000.00) }And then I added the RadLegend Control and it shows the same values.
How can I configure the RadLegend control to show only the names if I change the Label shown in the RadPieChart to show only the values?