This is a migrated thread and some comments may be shown as answers.

Changing series color at run time

4 Answers 105 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Anne Lyon
Top achievements
Rank 1
Anne Lyon asked on 26 Jan 2010, 12:51 PM
Hello,

I want to allow the user to change the series color on a line chart by picking a new color from a RadColorSelector. With this color I have tried several ways to assign it to my series, but even if the debugger shows that the series color attribute changes, the displayed chart is not updated.
This is what I have tried:

 

 

 

                 aChart.DefaultView.ChartArea.DataSeries[0].Definition.Appearance.Stroke = new SolidColorBrush(clrSel.SelectedColor);  
                 aChart.DefaultView.ChartArea.DataSeries[0].Definition.Appearance.Fill = new SolidColorBrush(clrSel.SelectedColor);  
 

OR

 

                    aChart.SeriesMappings[0].SeriesDefinition.Appearance.Stroke = new SolidColorBrush(clrSel.SelectedColor);  
                    aChart.SeriesMappings[0].SeriesDefinition.Appearance.Fill = new SolidColorBrush(clrSel.SelectedColor);  
 

 

 

Neither updates the chart.

As a comment, if the same user tries to switch on or off ItemLabels, this code works and updates the chart:

aChart.DefaultView.ChartArea.DataSeries[0].Definition.ShowItemLabels = menuItem.IsChecked; 

this one doesn't:

aChart.SeriesMappings[0].SeriesDefinition.ShowItemLabels = menuItem.IsChecked; 

 

 

Can anybody explain?
How do I change a series color after the chart is displayed?

Anne

 



4 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 28 Jan 2010, 08:20 AM
Hi Anne,

The approach where the SeriesDefinition.Appearance.Fill/Stoke is updated is used in this online example, so I am a bit surprised it wouldn't work for your. Can you please elaborate on your setup or send us a sample, where the issue is reproduce, so we can investigate it? Thanks.

Best regards,
Ves
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Anne Lyon
Top achievements
Rank 1
answered on 28 Jan 2010, 09:51 AM
Thank you Ves,
I do see that your Example code works fine, I donwnloaded it and ran it in my debugger.
But I still cannot get my own project to work.
I have zipped a test project for you and created a Support ticket since I cannot upload zip files here. Would you mind having a look and see if you can figure out why color change does not happen?

Thanks,
Anne
0
Ves
Telerik team
answered on 29 Jan 2010, 12:00 PM
Hello Anne,

I hope this has been sorted out in your support ticket. Just for the record and in case anyone else runs into the same issue -- the problem is in RadChart and the fix will be available in the next internal build.

Sincerely,
Ves
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Anne Lyon
Top achievements
Rank 1
answered on 29 Jan 2010, 01:04 PM
Thank you Ves,
Re-assigning the ItemSource to the chart did the trick for the time being.
Anne
Tags
Chart
Asked by
Anne Lyon
Top achievements
Rank 1
Answers by
Ves
Telerik team
Anne Lyon
Top achievements
Rank 1
Share this question
or