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

RadChart clears data series on zoom

3 Answers 56 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Nikos
Top achievements
Rank 1
Nikos asked on 16 Apr 2013, 11:15 AM
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

3 Answers, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 19 Apr 2013, 07:32 AM
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.

0
Nikos
Top achievements
Rank 1
answered on 19 Apr 2013, 07:37 AM
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?
0
Peshito
Telerik team
answered on 24 Apr 2013, 06:45 AM
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.

Tags
Chart
Asked by
Nikos
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Nikos
Top achievements
Rank 1
Share this question
or