这是我的饼图 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>
这是填充数据的代码
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;
}
输出如下
现在我如何更改图表各个部分的背景颜色。类似于下图。
我认为你应该能够使用调色板 http://msdn.microsoft.com/en-us/library/windows/desktop/dd183459%28v=vs.85%29.aspx。看看如何为 WPF 饼图中的饼图切片设置默认颜色 https://stackoverflow.com/questions/16667136/how-to-set-a-default-color-to-the-pie-slices-in-wpf-pie-chart在 StackOverflow 上发布。
此外,请查看图表外观 http://msdn.microsoft.com/en-us/library/dd489226.aspxMSDN 上的文章。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)