Changing series color at run time

5 posts, 0 answers
  1. Anne Lyon
    Anne Lyon avatar
    90 posts
    Member since:
    Jan 2010

    Posted 26 Jan 2010 Link to this post

    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

     



  2. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 28 Jan 2010 Link to this post

    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.
  3. Anne Lyon
    Anne Lyon avatar
    90 posts
    Member since:
    Jan 2010

    Posted 28 Jan 2010 Link to this post

    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
  4. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 29 Jan 2010 Link to this post

    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.
  5. Anne Lyon
    Anne Lyon avatar
    90 posts
    Member since:
    Jan 2010

    Posted 29 Jan 2010 Link to this post

    Thank you Ves,
    Re-assigning the ItemSource to the chart did the trick for the time being.
    Anne
Back to Top