Posted 14 Jul 2010 Link to this post
Sorry for the noob question, but why don't I see a pie chart ?
<
UserControl
x:Class
=
"radPie.MainPage"
xmlns
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x
"http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d
"http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc
"http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:telerik
"http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable
"d"
d:DesignHeight
"300"
d:DesignWidth
"400"
>
Grid
x:Name
"LayoutRoot"
Background
"White"
telerik:RadChart
Name
"myPie"
/>
Button
Content
"Next"
Click
"ShowChart"
Width
"50"
Height
"25"
HorizontalAlignment
"Left"
VerticalAlignment
"Top"
</
using System;
using System.Collections.Generic;
using System.Windows.Controls;
using Telerik.Windows.Controls.Charting;
namespace radPie
{
public partial class MainPage : UserControl
public MainPage()
InitializeComponent();
myPie.DefaultView.ChartTitle.Content = "My Pie";
myPie.DefaultSeriesDefinition = new PieSeriesDefinition();
ShowChart(null,null);
}
public void ShowChart(object sender, System.Windows.RoutedEventArgs e)
Random random = new Random();
List<
string
> fruits = new List<
>() { "Apples", "Oranges", "Pears", "Peaches", "Bananas", "Grapes" };
myPie.DefaultView.ChartArea.DataSeries.Clear();
foreach (string s in fruits)
DataSeries series = new DataSeries() { LegendLabel = s };
series.Add(new DataPoint(random.Next(0, 50)));
myPie.DefaultView.ChartArea.DataSeries.Add(series);
Nevermind - I see that I created 6 series ... I changed it to create one series with six data points ...
DataSeries series = new DataSeries() { Definition = myPie.DefaultSeriesDefinition };
DataPoint dp = new DataPoint(random.Next(0, 50)) { LegendLabel = s };
series.Add(dp);
Posted 16 Jul 2010 Link to this post