【问题标题】:Styling Wpf Pie Chart样式化 Wpf 饼图
【发布时间】:2013-08-27 11:58:44
【问题描述】:

这是我的饼图 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;
}

输出如下

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

【问题讨论】:

标签: c# wpf charts wpftoolkit


【解决方案1】:

我认为您应该可以使用Color Palette。查看 StackOverflow 上的 How to set a default colour to the Pie slices in WPF Pie chart 帖子。

另外,请查看 MSDN 上的 Chart Appearance 文章。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多