RadChart clears data series on zoom

4 posts, 0 answers
  1. Nikos
    Nikos avatar
    8 posts
    Member since:
    Dec 2011

    Posted 16 Apr 2013 Link to this post

    Version: 2013 Q1 with SP1

    In a RadChart with zoom enabled, trying to zoom-in causes automatic removal of the underlying DataSeries object from the ChartArea.DataSeries collection. I have attached some sample code that reproduces the issue. Note that this behavior is reproduced both programatically, and through UI interaction (by resizing the zoom bar).

    XAML code:

    <Window
        x:Class="MainWindow"
        Title="MainWindow" Height="350" Width="525"
        Loaded="Window_Loaded">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <telerik:RadChart
            Name="chart" telerik:StyleManager.Theme="Summer" MaxWidth="5000" MaxHeight="5000"
            FontFamily="Segoe UI" FontSize="10" Background="Transparent" PaletteBrushesRepeat="False">
                <telerik:RadChart.DefaultView>
                    <telerik:ChartDefaultView>
                        <telerik:ChartDefaultView.ChartLegend>
                            <telerik:ChartLegend
                            Name="chLegend" Background="Transparent" UseAutoGeneratedItems="True"
                            FontSize="9" IsHitTestVisible="False"/>
                        </telerik:ChartDefaultView.ChartLegend>
                        <telerik:ChartDefaultView.ChartArea>
                            <telerik:ChartArea EnableAnimations="True" LegendName="chLegend">
                                <telerik:ChartArea.AxisX>
                                    <telerik:AxisX/>
                                </telerik:ChartArea.AxisX>
                                <telerik:ChartArea.AxisY>
                                    <telerik:AxisY/>
                                </telerik:ChartArea.AxisY>
                                <telerik:ChartArea.AnimationSettings>
                                    <telerik:AnimationSettings TotalSeriesAnimationDuration="00:00:00.600" />
                                </telerik:ChartArea.AnimationSettings>
                                <telerik:ChartArea.DataSeries>
                                    <telerik:DataSeries LegendLabel="Product Sales">
                                        <telerik:DataSeries.Definition>
                                            <telerik:BarSeriesDefinition/>
                                        </telerik:DataSeries.Definition>
                                    </telerik:DataSeries>
                                </telerik:ChartArea.DataSeries>
                            </telerik:ChartArea>
                        </telerik:ChartDefaultView.ChartArea>
                    </telerik:ChartDefaultView>
                </telerik:RadChart.DefaultView>
            </telerik:RadChart>
     
            <Button x:Name="btnSetZoom" Grid.Row="1" Padding="3" Content="Click to set zoom" HorizontalAlignment="Right" Click="btnSetZoom_Click"/>
        </Grid>
    </Window>

    VB code behind:

    Imports Telerik.Windows.Controls.Charting
     
    Class MainWindow
     
        Private Sub btnSetZoom_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
            Me.SetZoom()
        End Sub
     
        Private Sub Window_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs)
            Me.InitChart()
            Me.GenerateData()
        End Sub
     
        Private Sub InitChart()
            With Me.chart.DefaultView.ChartArea.AxisX
                .AutoRange = True
                .IsZeroBased = True
            End With
            With Me.chart.DefaultView.ChartArea.AxisX
                .AutoRange = True
                .IsZeroBased = True
            End With
     
            Dim zoomX As ZoomScrollSettings = chart.DefaultView.ChartArea.ZoomScrollSettingsX
            zoomX.ScrollMode = ScrollMode.ScrollAndZoom
            zoomX.RangeStart = 0
            zoomX.RangeEnd = 1
            Dim zoomY As ZoomScrollSettings = chart.DefaultView.ChartArea.ZoomScrollSettingsY
            zoomY.ScrollMode = ScrollMode.ScrollAndZoom
            zoomY.RangeStart = 0
            zoomY.RangeEnd = 1
        End Sub
     
        Private Sub GenerateData()
            Dim data As New List(Of DataPoint)()
     
            For Each i In Enumerable.Range(0, 20)
                Dim p = New DataPoint(i, i + 1.0)
                data.Add(p)
            Next
     
            Me.chart.DefaultView.ChartArea.DataSeries(0).AddRange(data)
        End Sub
     
        Private Sub SetZoom()
            Dim zoomX As ZoomScrollSettings = chart.DefaultView.ChartArea.ZoomScrollSettingsX
            zoomX.RangeStart = 0.2
            zoomX.RangeEnd = 0.7
        End Sub
     
    End Class
  2. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 19 Apr 2013 Link to this post

    Hi,

    Zooming and Scrolling feature is available in data bound scenarios only! Additional requirement is an ItemMapping with DataPointMember set to XValue or XCategory. You can find more information here.

    Hope this helps.

    Greetings,
    Peshito
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Nikos
    Nikos avatar
    8 posts
    Member since:
    Dec 2011

    Posted 19 Apr 2013 Link to this post

    The constraint you mention does not apply in our current version, i.e. RadControls WPF Q3 2010. We just noticed this behavior while evaluating the 2013 Q1 SP1.

    So we might assume that after some point, RadChart does not support zoom on unbound data, as it did?
  5. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 24 Apr 2013 Link to this post

    Hello,

    Zooming and scrolling feature is intended to work in data bound scenarios only. At some time there might have been an issue with it, which I assume has let you use it in a different scenario like the one you have for example. I also tried your scenario with the Q3 2010 RadControls version and I found that the zooming works on your vertical axis only.

    In order to have properly working Zooming and Scrolling feature, please use it in a data bound scenario.

    Regards,
    Peshito
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top