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

SeriesDefinition.Visibility +ChartGroupDescriptor

1 Answer 65 Views
Chart
This is a migrated thread and some comments may be shown as answers.
leblanc
Top achievements
Rank 1
leblanc asked on 21 Nov 2012, 08:01 PM
We have a custom behavior that sets mapping.SeriesDefinition.Visibility  with binding to a checkbox mode=twoway.

It works on charts that do not use group descriptors.

Attached is screenshot.

<telerik:SeriesMapping>
                                <telerik:SeriesMapping.SeriesDefinition>
                                    <telerik:LineSeriesDefinition LegendDisplayMode="SeriesLabel" SeriesName="Food" ShowItemLabels="False" ShowItemToolTips="True" ItemLabelFormat="#Y" ItemToolTipFormat="#DATAITEM.Food{C2} Food #DATAITEM.FoodAvg{C2} Avg">
                                        <telerik:LineSeriesDefinition.Appearance>
                                            <telerik:SeriesAppearanceSettings Fill="#00e8ff" />
                                        </telerik:LineSeriesDefinition.Appearance>
                                        <telerik:LineSeriesDefinition.InteractivitySettings>
                                            <telerik:InteractivitySettings HoverScope="Series" SelectionScope="Series" />
                                        </telerik:LineSeriesDefinition.InteractivitySettings>
                                    </telerik:LineSeriesDefinition>
                                </telerik:SeriesMapping.SeriesDefinition>
                                <telerik:SeriesMapping.GroupingSettings>
                                    <telerik:GroupingSettings>
                                        <telerik:GroupingSettings.GroupDescriptors>
                                            <telerik:ChartGroupDescriptor Member="StoreName" />
                                        </telerik:GroupingSettings.GroupDescriptors>
                                    </telerik:GroupingSettings>
                                </telerik:SeriesMapping.GroupingSettings>
                                <telerik:SeriesMapping.ItemMappings>
                                    <telerik:ItemMapping FieldName="Food" DataPointMember="YValue"   />
                                    <telerik:ItemMapping FieldName="Period" DataPointMember="XCategory" />
                                </telerik:SeriesMapping.ItemMappings>
                            </telerik:SeriesMapping>


Notice that Food is unchecked = collapsed on seriesdefinition.visiblity.  However, the generated groupped items remain on the chart.
How else can i get the generated groupping visibility to be turned off?  My next attempt will be to apply seriesmapping programmatically : (

1 Answer, 1 is accepted

Sort by
0
Petar Kirov
Telerik team
answered on 26 Nov 2012, 05:22 PM
Hello Leblanc,

The Grouping feature of the RadChart creates multiple data series from one SeriesMapping (based on the ChartGroupDescriptor(s)). That's why the bindings to the series definition properties are not replicated.

The solution would be to traverse the RadChart1.DefaultView.ChartArea.DataSeries collection and manually set the visibility in CheckBox_Click event handler. For example: 
private void CheckBox_Click(object sender, RoutedEventArgs e)
{
    var checkBox = (CheckBox)sender;
    string tag = checkBox.Tag as string;
 
    foreach (DataSeries series in this.RadChart1.DefaultView.ChartArea.DataSeries)
    {
        if (series.Definition.SeriesName == tag)
        {
            series.Definition.Visibility = checkBox.IsChecked == true
                ? SeriesVisibility.Visible
                : SeriesVisibility.Collapsed
        }
    }
}

In the example above the we show / hide all series which have the same name as the CheckBox tag. Feel free to modify according to your scenario.
 
 
All the best,
Petar Kirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Chart
Asked by
leblanc
Top achievements
Rank 1
Answers by
Petar Kirov
Telerik team
Share this question
or