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

Possible bug in Radchart legend?

8 Answers 72 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Pablo
Top achievements
Rank 1
Pablo asked on 25 Aug 2011, 10:14 AM
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?

8 Answers, 1 is accepted

Sort by
0
Pablo
Top achievements
Rank 1
answered on 30 Aug 2011, 08:46 AM
Good day,

Any update on this?

Thank you,

Pablo.
0
Yavor
Telerik team
answered on 31 Aug 2011, 06:50 AM
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 >>

0
Pablo
Top achievements
Rank 1
answered on 31 Aug 2011, 08:27 AM
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.
0
Pablo
Top achievements
Rank 1
answered on 31 Aug 2011, 08:55 AM
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.
0
Yavor
Telerik team
answered on 02 Sep 2011, 11:19 AM
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 >>

0
Pablo
Top achievements
Rank 1
answered on 07 Sep 2011, 03:31 PM
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.
0
marinus bosman
Top achievements
Rank 1
answered on 06 Oct 2011, 09:04 AM
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
0
Yavor
Telerik team
answered on 10 Oct 2011, 07:38 AM
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 >>

Tags
Chart
Asked by
Pablo
Top achievements
Rank 1
Answers by
Pablo
Top achievements
Rank 1
Yavor
Telerik team
marinus bosman
Top achievements
Rank 1
Share this question
or