当前位置: 代码迷 >> .NET报表 >> 如何修改饼状图各块的颜色
  详细解决方案

如何修改饼状图各块的颜色

热度:258   发布时间:2016-05-05 01:40:04.0
怎么修改饼状图各块的颜色?
win 8 商店应用程序:
目前效果如下:

我想把它的红蓝色块改成别的颜色,请问怎么改,如下是代码:


CS代码:


/// <summary>
        /// 饼状图
        /// </summary>
        private void UpdateCharts()
        {
            List<NameValueItem> items = new List<NameValueItem>();
            NameValueItem nv = new NameValueItem();
            nv.Value = Convert.ToInt32(20);
            nv.Name = nv.Value.ToString() +  "%   及格比例";

            NameValueItem nv1 = new NameValueItem();
            nv1.Value = Convert.ToInt32(100 - Convert.ToInt32(20));
            nv1.Name = nv1.Value.ToString() + "%   不及格比例";
            items.Add(nv);
            items.Add(nv1);
            ((PieSeries)this.PieChart.Series[0]).ItemsSource = items;
            
        }
        public class NameValueItem
        {
            public string Name { get; set; }
            public int Value { get; set; }
        }



XAML代码:

<Charting:Chart
                             Grid.Row="1" Grid.Column="0"
                            HorizontalAlignment="Left"
                            Width="500"
                            x:Name="PieChart"
                            Title="" Foreground="Black" FontSize="12">
                            <Charting:Chart.Series>
                                <Series:PieSeries
                            Title="Population"
                            ItemsSource="{Binding Items}"
                            IndependentValueBinding="{Binding Name}"
                            DependentValueBinding="{Binding Value}"
                            IsSelectionEnabled="True"/>
                            </Charting:Chart.Series>
                        </Charting:Chart>

------解决方案--------------------
看半天了就是不会
  相关解决方案