造型WPF饼图 [英] Styling Wpf Pie Chart
本文介绍了造型WPF饼图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我的饼图XAML
Here is my xaml for the pie chart.
<chartingToolkit:Chart Name="pieChart" Title="Top Products" Margin="10,10,0,0" Height="262" BorderBrush="#00000000" DataContext="{Binding}" IsHitTestVisible="False" IsTabStop="True" ForceCursor="True">
<chartingToolkit:PieSeries DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding}" IsSelectionEnabled="True" />
<!-- Plot area-->
<chartingToolkit:Chart.PlotAreaStyle>
<Style TargetType="Grid">
<Setter Property="Background" Value="White" />
</Style>
</chartingToolkit:Chart.PlotAreaStyle>
</chartingToolkit:Chart>
和下面是填充数据
public void GenerateChart()
{
List<KeyValuePair<string, double>> valueList = new List<KeyValuePair<string, double>>();
valueList.Add(new KeyValuePair<string, double>("Apple", 101));
valueList.Add(new KeyValuePair<string, double>("Banana", 201));
valueList.Add(new KeyValuePair<string, double>("Cake", 20));
valueList.Add(new KeyValuePair<string, double>("Others", 200));
pieChart.Title = "Top Products";
pieChart.DataContext = valueList;
}
和输出如下:
现在该怎么办我改变图表的各部分的背景色。类似下图。
Now how do i change the background color of various segments of the chart. Similar to below chart.
推荐答案
我认为你应该能够使用的调色板。看看的的如何设置一个默认的颜色在这里StackOverflow的WPF饼图后的扇形。
I think that you should be able to use a Color Palette. Take a look at the How to set a default colour to the Pie slices in WPF Pie chart post here on StackOverflow.
此外,看一看在的图外观上 MSDN文章。
Additionally, take a look at the Chart Appearance article on MSDN.
这篇关于造型WPF饼图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文