Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF toolkit charting set color of Bar or Pie

$
0
0

Experts,

i m new to charting.i am using the WPF charting toolkit and took help form this blog:

http://www.codeproject.com/KB/WPF/WPFChartingMVVM.aspx?fid=1591697&df=90&mpp=25&noise=3&prof=False&sort=Position&view=Quick&fr=26#xx0xx

in XAML i m using 

 <chartingToolkit:Chart x:Name="ChartPie" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="5,0,0,0"            

                        Title="{Binding   Path=Title}" LegendTitle="{Binding   Path=LegendTitle}" Visibility="{Binding IsPiechart}" > 

 

                <chartingToolkit:PieSeries x:Name="XPieSeries" 

                DataContext="{Binding}" DependentValueBinding="{Binding Path=Value}" IndependentValueBinding="{Binding Path=Key}" ItemsSource="{Binding Path=dataPie}" Visibility="{Binding IsPiechart}" />

 

            </chartingToolkit:Chart>

and in the View model i am  just updating the observalbe collcection "dataPie".

 

        private ObservableCollection<KeyValuePair<string, double>> _dataPie = new ObservableCollection<KeyValuePair<string, double>>();

        public ObservableCollection<KeyValuePair<string, double>> dataPie

        {

            get { return _dataPie; }

            set { _dataPie = value; }

        }

 

  dataPie.Add(new KeyValuePair<string, double>("Yes", resultdiv));

  dataPie.Add(new KeyValuePair<string, double>("No", (100 - resultdiv)));

 

but how can i control the color in the pie chart. every time the chart refreshes the color is changing. please let me know how to control the color.

 

thanks in advance. 


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>