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

Changing visibility of series

4 Answers 147 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Randy
Top achievements
Rank 1
Randy asked on 01 Aug 2011, 12:52 AM
I have a chart with 5 series and have given the user 5 toggle buttons to enable or disable each series.  It does not seem to matter if I use hidden or collapsed, but the colors of the legend and the datapoints get out of sync.  It appears that the color of the datapoints are fixed from the first series always getting what appears to be cyan.  But as I change the visibility of each series defintion, the colors of the datapoints are recalcualted.  So if the user clicks the button to turn off the very first series definition, it will disappear, but the second series definition will now take on cyan.  That would be fine, except the legend colors don't change.

SeriesMapping sm1 = _rchtHH.SeriesMappings[0];
ISeriesDefinition sd1 = sm1.SeriesDefinition;
sd1.Visibility = (_rrbnHH.IsChecked == true) ? SeriesVisibility.Visible : SeriesVisibility.Collapsed;
ChartLegendItem cli1 = (ChartLegendItem)(_rchtHH.DefaultView.ChartLegend as Telerik.Windows.Controls.ItemsControl).Items[0];
cli1.Visibility = (_rrbnHH.IsChecked == true) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
<telerik:RadChart x:Name="_rchtHH" Margin="{StaticResource InnerMargin}">
    <telerik:RadChart.DefaultView>
        <telerik:ChartDefaultView>
            <telerik:ChartDefaultView.ChartLegend>
                <telerik:ChartLegend x:Name="_clSource" >
                </telerik:ChartLegend>
            </telerik:ChartDefaultView.ChartLegend>
            <telerik:ChartDefaultView.ChartArea >
                <telerik:ChartArea LegendName="_clSource">
                    <telerik:ChartArea.AxisX>
                        <telerik:AxisX DefaultLabelFormat="MMM-yyyy" LabelRotationAngle="60">
                        </telerik:AxisX>
                    </telerik:ChartArea.AxisX>
                    <telerik:ChartArea.AxisY>
                        <telerik:AxisY IsLogarithmic="True" LogarithmBase="2.2">
                        </telerik:AxisY>
                    </telerik:ChartArea.AxisY>
                </telerik:ChartArea>
            </telerik:ChartDefaultView.ChartArea>
        </telerik:ChartDefaultView>
    </telerik:RadChart.DefaultView>
    <telerik:RadChart.SeriesMappings>
        <telerik:SeriesMapping LegendLabel="HH Count" >
            <telerik:SeriesMapping.SeriesDefinition>
                <telerik:LineSeriesDefinition>
                    <telerik:LineSeriesDefinition.InteractivitySettings>
                        <telerik:InteractivitySettings HoverScope="Series" SelectionScope="Series" />
                    </telerik:LineSeriesDefinition.InteractivitySettings>
                </telerik:LineSeriesDefinition>
            </telerik:SeriesMapping.SeriesDefinition>
            <telerik:SeriesMapping.ItemMappings>
                <telerik:ItemMapping DataPointMember="XValue" FieldName="Date"></telerik:ItemMapping>
                <telerik:ItemMapping DataPointMember="YValue" FieldName="Line1"></telerik:ItemMapping>
            </telerik:SeriesMapping.ItemMappings>
        </telerik:SeriesMapping>
        <telerik:SeriesMapping LegendLabel="Auto Count">
            <telerik:SeriesMapping.SeriesDefinition>
                <telerik:LineSeriesDefinition >
                    <telerik:LineSeriesDefinition.InteractivitySettings>
                        <telerik:InteractivitySettings HoverScope="Series" SelectionScope="Series" />
                    </telerik:LineSeriesDefinition.InteractivitySettings>
                </telerik:LineSeriesDefinition>
            </telerik:SeriesMapping.SeriesDefinition>
            <telerik:SeriesMapping.ItemMappings>
                <telerik:ItemMapping DataPointMember="XValue" FieldName="Date"></telerik:ItemMapping>
                <telerik:ItemMapping DataPointMember="YValue" FieldName="Line2"></telerik:ItemMapping>
            </telerik:SeriesMapping.ItemMappings>
        </telerik:SeriesMapping>

4 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 03 Aug 2011, 07:38 AM
Hi Randy,

To handle this setup, you can take an approach similar to the one demonstrated in this example:

http://demos.telerik.com/silverlight/#Chart/SimpleFiltering

The colors there are not changed.
I hope this gets you started properly.

All the best,
Yavor
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
alizator
Top achievements
Rank 1
answered on 16 Mar 2012, 09:43 AM
Hello,

But if we use it with StackedBarChart is just hide the serie. If I use the SeriesVisibility.Collapsed I have the issue discrabe in this post: 
http://www.telerik.com/community/forums/silverlight/chart/filtering-and-stacked-bar.aspx 

Do you have any suggestion?
0
Yavor
Telerik team
answered on 20 Mar 2012, 04:10 PM
Hello,

In this case, you can also remove the item(s) from the legend of the chart as well.

All the best,
Yavor
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
alizator
Top achievements
Rank 1
answered on 21 Mar 2012, 01:32 PM
Hello,

The desire was like the "Simple Filtering" future(Have the posibility to show the series again). I manage to altering the Palette color and now it's ok.
Tags
Chart
Asked by
Randy
Top achievements
Rank 1
Answers by
Yavor
Telerik team
alizator
Top achievements
Rank 1
Share this question
or