Xam PIE Chart changes colors everytime.

Answered (Verified) This post has 1 verified answer | 2 Replies | 2 Followers Thread's RSS feed.

ShrishailHalijol
Points 535
Replied On: Tue, Apr 24 2012 5:59 AM Reply

Hi, I am using the XamPieChart to present a set of data values. I have the following code..

public MainWindow(){

InitializeComponent();

xamPieChart1 .Brushes.Clear();

xamPieChart1 .Brushes.Add(new SolidColorBrush(Colors.Red));

xamPieChart1 .Brushes.Add(new SolidColorBrush(Colors.Green));

xamPieChart1 .Brushes.Add(new SolidColorBrush(Colors.LightGray));

}

 

private void button1_Click(object sender, RoutedEventArgs e)

{

Dictionary<string, int> values = new Dictionary<string, int>();

values.Add("Red", 50);

values.Add("Green", 100);

values.Add("Gray", 150);

xamPieChart1.itemsource = values;

}

 

Also, I have both the values and labels binded to the PIE chart. However, everytime i click on a button, i see the the colors are changing their positions i.e., in place of Red i get Green  etc.. How do i solve this?

Regards, Shrishail

  • Post Points: 5

Verified Answer

ShrishailHalijol
Points 535
Answered (Verified) Replied On: Tue, Apr 24 2012 7:40 AM Reply
Verified by ShrishailHalijol

I think this is because of the values in the dictionary being 0. Is it true that if a first value in the dictionary is 0, the second value gets the 1st color in the PIE? Correct me in case i am wrong here...

Regards, Shrishail.

  • Post Points: 40

All Replies

ShrishailHalijol
Points 535
Answered (Verified) Replied On: Tue, Apr 24 2012 7:40 AM Reply
Verified by ShrishailHalijol

I think this is because of the values in the dictionary being 0. Is it true that if a first value in the dictionary is 0, the second value gets the 1st color in the PIE? Correct me in case i am wrong here...

Regards, Shrishail.

  • Post Points: 40
Stefan
Points 138,023
Infragistics Employee
Replied On: Wed, Apr 25 2012 2:33 AM Reply

Hello Shrishail,

 

Thank you for your post. I have been looking into it and I can say that you are right that if the first non-zero value in the DataSource object gets the first color from the Brushes collection of the XamPieChart.

Sincerely,
Stefan, MCPD
Software Developer
Infragistics, Inc.
www.infragistics.com/support

  • Post Points: 5
Page 1 of 1 (3 items) | RSS