[英]Styling Wpf Pie Chart
Here is my xaml for the pie chart. 这是饼图的我的xaml。
<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>
And Here is the code for filling the data 这是填充数据的代码
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;
}
And the output is as follows 输出如下
Now how do i change the background color of various segments of the chart. 现在我如何更改图表各个部分的背景颜色。 Similar to below chart.
类似于下面的图表。
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.
请看一下如何在StackOverflow上的WPF饼图中设置默认颜色到Pie切片 。
Additionally, take a look at the Chart Appearance article on MSDN. 另外,请查看MSDN上的Chart Appearance文章。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.