Changing visibility of series

5 posts, 0 answers
  1. Randy
    Randy avatar
    50 posts
    Member since:
    Aug 2010

    Posted 31 Jul 2011 Link to this post

    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>
  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 03 Aug 2011 Link to this post

    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 >>
  3. DevCraft banner
  4. alizator
    alizator avatar
    12 posts
    Member since:
    Oct 2011

    Posted 16 Mar 2012 Link to this post

    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?
  5. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 20 Mar 2012 Link to this post

    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 >>
  6. alizator
    alizator avatar
    12 posts
    Member since:
    Oct 2011

    Posted 21 Mar 2012 Link to this post

    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.
Back to Top
DevCraft banner