Possible bug in Radchart legend?

9 posts, 0 answers
  1. Pablo
    Pablo avatar
    38 posts
    Member since:
    Oct 2012

    Posted 25 Aug 2011 Link to this post

    Hi all, 

    I have found a strange behaviour in the radchart legend and I'd like to know whether it is due to something I am missing or to a bug.

    The scenario is pretty simple. I have a Radchart plotting several line series. Each series's parametrization (color, axis ranges, and so on) is stored in a settings class. As the user edits the series settings, the settings class is updated and changes are propagated to the chart (not via binding but using normal procedural code). The problem comes when the user changes the series color. I then use the following piece of code to change the color in the chart series:

    obSerie.TelerikSeriesMapping.SeriesDefinition.Appearance.Stroke = new SolidColorBrush(obSerie.SerieColor);

    This works great and the chart series changes its color accordingly. However, the small square in the legend associated to that serie does not update itself and keeps the color previous to the change. 

    Am I supposed to make any other updates in the control or is this a bug?
  2. Pablo
    Pablo avatar
    38 posts
    Member since:
    Oct 2012

    Posted 30 Aug 2011 Link to this post

    Good day,

    Any update on this?

    Thank you,

    Pablo.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 31 Aug 2011 Link to this post

    Hello Pablo,

    One possible option in this case would be to alter the fill of the series. This may look something like this:

    RadChart.DefaultSeriesDefinition.Appearance.Stroke = new SolidColorBrush(Colors.Red);
    RadChart.DefaultSeriesDefinition.Appearance.Fill = new SolidColorBrush(Colors.Red);

    This will also change the background of the legend item.
    Another option would be to access the legend item directly.

    I hope this information gets you started properly.

    Kind regards,
    Yavor
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  5. Pablo
    Pablo avatar
    38 posts
    Member since:
    Oct 2012

    Posted 31 Aug 2011 Link to this post

    Hi Yavor, 

    Thank you for your response. I'll try these options. 

    Just to let you know, the legend color gets updated correctly when the user decides to "refresh" the chart pressing the refresh button. As the user does, we programmatically "reset" the chart deleting its configuration (series mappings, etc.) and applying the settings again. 

    Thanks, 

    Pablo.
  6. Pablo
    Pablo avatar
    38 posts
    Member since:
    Oct 2012

    Posted 31 Aug 2011 Link to this post

    Hi Yavor, 

    I've tried the suggested options and none of theme works. Setting the series fill color (I tried to change the fill color of the series which color is updated, and also setting the fill at DefaultSeriesDefinition as you mentioned) doesn't solve the problem. On the other hand, accessing the legend items does not seem to be possible. While debugging I can see that Chart.DefaultView.ChartLegend.Items is 0 (I guess this is due to that the legend items are not custom). I see another property, MergedLegendItemsCollection, that contains the ChartLegendItems that appear in the legend, but it is not accessible from code. 

    Is there another workaround for this issue?

    Thank you very much.
  7. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 02 Sep 2011 Link to this post

    Hello Pablo,

    In this case, since the legend items are not always directly accessible, you can look into retemplating the legend. More information on this is available in the following article:

    http://www.telerik.com/help/silverlight/radchart-styling-and-appearance-styling-chart-legend.html

    I hope this gets you started properly.

    Greetings,
    Yavor
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  8. Pablo
    Pablo avatar
    38 posts
    Member since:
    Oct 2012

    Posted 07 Sep 2011 Link to this post

    Hello Yavor, 

    thank you for  your response. We'll consider to apply this solution. However, I still think it would be logic that the legend updated its color when the series color is modified... 

    Regards,

    Pablo.
  9. marinus bosman
    marinus bosman avatar
    4 posts
    Member since:
    Apr 2005

    Posted 06 Oct 2011 Link to this post

    We have a simular issue, when Binding Series to a Chart the Legend shows the wrong colors.
    After a Refresh the right colors are shown.

    We solved this by changing the Order of the Databindings on the Radchart.
    Changing the order made the legend appear in the right color.

    Feels funny though... the order of the declaration in the Databind influences the outcome.....
    ItemsSource="{Binding Data}"  SeriesMappings="{Binding SeriesMapping}" PaletteBrushes="{Binding SeriesBrushes}" 
    Doesnt Work, but
    PaletteBrushes="{Binding SeriesBrushes}"  ItemsSource="{Binding Data}"  SeriesMappings="{Binding SeriesMapping}" 
    Does...
    Regards,
    M
  10. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 10 Oct 2011 Link to this post

    Hi Marinus,

    It will be best if you send us a small sample, demonstrating the discrepancy, so that we are sure to be on the same page. We will debug it locally, and address the issue as needed.

    All the best,
    Yavor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
UI for WPF is Visual Studio 2017 Ready