Is there any way to set the PieChart slice colors from code behind? I know how to do it with other chart styles (i.e. for line charts .. I use <series>.Definition.Appearance.Stroke/Fill). But when you use that same idea for pie charts, all the slices are the same color. Which I expect since I've only got one series.
var series = new DataSeries { Definition = new PieSeriesDefinition() };
series.Definition.ShowItemLabels = true;
series.Add(new DataPoint(_dataList.A, _dataList.A));
series.Add(new DataPoint(_dataList.B, _dataList.B));
//series[0].LegendLabel = "Series A";
//series[1].LegendLabel = "Series B";
// this is what I do in other charts for each series... but pie charts don't work.
//series.Definition.Appearance.Stroke = new SolidColorBrush(Colors.Black);
//series.Definition.Appearance.Fill = new SolidColorBrush(myCustomColor);
RadChart1.DefaultView.ChartArea.DataSeries.Add(series);
If I change the theme colours in XAML using the StylesPalette, the colors change. But I really want to change them from code (dynamic when a user control starts up only, not necessarily dynamic while the app is running). Any ideas? Could the color of of the Fill property in the Xaml be changed using binding?
<SolidColorBrush x:Key="RadialItemStroke" Color="#FF000000"/>
<system:Double x:Key="RadialItemStrokeThickness">2</system:Double>
<telerikStyling:StylesPalette x:Key="{telerikStyling:ThemeResourceKey
ThemeType={x:Type telerikStyling:Office_BlackTheme},
ElementType={x:Type telerikStyling:ChartArea},
ResourceId={x:Static telerikStyling:ResourceHelper.ResourceKeyRadialStyle}}">
<Style TargetType="{x:Type Shape}">
<Setter Property="Stroke" Value="{StaticResource RadialItemStroke}" />
<Setter Property="StrokeThickness" Value="{StaticResource RadialItemStrokeThickness}" />
<Setter Property="Fill" Value="{Insert some binding expression here?}" />
</Style>
<Style TargetType="{x:Type Shape}">
<Setter Property="Stroke" Value="{StaticResource RadialItemStroke}" />
<Setter Property="StrokeThickness" Value="{StaticResource RadialItemStrokeThickness}" />
<Setter Property="Fill" Value="{Insert some binding expression here?}" />
</Style>
</telerikStyling:StylesPalette>
Thanks
Greg
var series = new DataSeries { Definition = new PieSeriesDefinition() };
series.Definition.ShowItemLabels = true;
series.Add(new DataPoint(_dataList.A, _dataList.A));
series.Add(new DataPoint(_dataList.B, _dataList.B));
//series[0].LegendLabel = "Series A";
//series[1].LegendLabel = "Series B";
// this is what I do in other charts for each series... but pie charts don't work.
//series.Definition.Appearance.Stroke = new SolidColorBrush(Colors.Black);
//series.Definition.Appearance.Fill = new SolidColorBrush(myCustomColor);
RadChart1.DefaultView.ChartArea.DataSeries.Add(series);
If I change the theme colours in XAML using the StylesPalette, the colors change. But I really want to change them from code (dynamic when a user control starts up only, not necessarily dynamic while the app is running). Any ideas? Could the color of of the Fill property in the Xaml be changed using binding?
<SolidColorBrush x:Key="RadialItemStroke" Color="#FF000000"/>
<system:Double x:Key="RadialItemStrokeThickness">2</system:Double>
<telerikStyling:StylesPalette x:Key="{telerikStyling:ThemeResourceKey
ThemeType={x:Type telerikStyling:Office_BlackTheme},
ElementType={x:Type telerikStyling:ChartArea},
ResourceId={x:Static telerikStyling:ResourceHelper.ResourceKeyRadialStyle}}">
<Style TargetType="{x:Type Shape}">
<Setter Property="Stroke" Value="{StaticResource RadialItemStroke}" />
<Setter Property="StrokeThickness" Value="{StaticResource RadialItemStrokeThickness}" />
<Setter Property="Fill" Value="{Insert some binding expression here?}" />
</Style>
<Style TargetType="{x:Type Shape}">
<Setter Property="Stroke" Value="{StaticResource RadialItemStroke}" />
<Setter Property="StrokeThickness" Value="{StaticResource RadialItemStrokeThickness}" />
<Setter Property="Fill" Value="{Insert some binding expression here?}" />
</Style>
</telerikStyling:StylesPalette>
Thanks
Greg