2013-08-27 82 views
3

这是我的饼图xaml。造型Wpf饼图

<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; 
} 

并且输出是如下

Chart

现在如何变更的各部分的背景颜色图表。类似于下图。

enter image description here

+0

请帮助我一样。看看我的[问题](http://stackoverflow.com/questions/25660079/wpf-chart-is-not-plotting-the-chart) –

+0

好吧,我会为源代码提供dropbox链接。等待几分钟 – Redone

+0

Ohhkk谢谢:) –

回答