Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to display check boxes for legend items to control the visibility of series in the bound mode

$
0
0

This example demonstrates how you can provide each legend item with a check box, which controls the visibility of the corresponding series in the bound mode (obsolete approach).
Note that starting with the DXperience version 13.2.1, the chart control supports a built-in check box in the Legend feature. For more details, see the Legend Check Box topic.  

To accomplish this, it is necessary to assign the Legend.Template property to custom template and then bind the ItemsSource property of the ItemsControl object to SeriesNonVisualWrappersCollection.

This custom collection is synchronized with the diagram's series collection when the SeriesCollection.CollectionChanged event fires.

In addition, the fake series source is created in the chart's data source to avoid hiding the legend when the Series.Visible property is set to false for all series.

See also:

- How to display custom information in the legend;

- How to display check boxes for legend items to control the visibility of series in the unbound mode

Question Comments

Added By: Aleksei Smirnov at: 4/28/2014 8:44:38 AM    

Hello,
thanks for a very good example. It is really useful. However it is not working as expected. The color in the legend is not the same as the color in the chart in cases when visibility is changed.

The reason is that chart is uses palette only for visible elements. I mean if only one series is visible it would be always the same color independently on the series type. For example, if Series2 is the only visible series it is red. If Series1 is the only visible it is red too! When I make Series1 invisible, Series2 changes it's color from Green to Red. Legend still shows the original colors!

Could you please suggest the way how to disable such behavior? I don't want the series to change their colors if amount of visible series are changing.

Thanks

Added By: Eugene M (DevExpress) at: 4/28/2014 11:24:14 PM    

Hello, Aleksei
Can you please clarify what version of DevExpress product you are using?

Added By: Aleksei Smirnov at: 4/29/2014 12:45:35 AM    

Hello Eugene,
I am using DevExpress 13.2_9

Added By: Eugene M (DevExpress) at: 4/29/2014 5:40:24 AM    

I'm happy to inform you that we have a built-in check box in the Legend feature starting from the 13.2.1 release. Please refer to the Legend Check Box topic.

Added By: Aleksei Smirnov at: 4/29/2014 6:54:10 AM    

Thanks, Eugene. Good news!


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>