Index out of range exception in CategoricalSeriesRoundLayoutContext.SnapPointToGridLine

6 posts, 0 answers
  1. Dan
    Dan avatar
    8 posts
    Member since:
    Jul 2011

    Posted 27 May 2012 Link to this post

    I recently upgraded my application to the Q12012 controls and am seeing the following index out of range exception. I haven't debugged it in detail yet and first wanted to check if it's a known issue. Does this look familiar? If not, I'll spend some more time digging in.

      mscorlib.dll!System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument argument, System.ExceptionResource resource) + 0x10 bytes
      mscorlib.dll!System.ThrowHelper.ThrowArgumentOutOfRangeException() + 0x9 bytes
      mscorlib.dll!System.Collections.Generic.List<Telerik.Charting.AxisTickModel>.this[int].get(int index) + 0xe bytes
      mscorlib.dll!System.Collections.ObjectModel.Collection<Telerik.Charting.AxisTickModel>.this[int].get(int index) + 0x7 bytes
    > Telerik.Windows.Controls.Chart.dll!Telerik.Charting.CategoricalSeriesRoundLayoutContext.SnapPointToGridLine(Telerik.Charting.CategoricalDataPoint point) + 0x55 bytes
      Telerik.Windows.Controls.Chart.dll!Telerik.Charting.BarSeriesModel.ApplyLayoutRounding() + 0x2f bytes
      Telerik.Windows.Controls.Chart.dll!Telerik.Charting.CartesianChartAreaModel.ApplyLayoutRounding() + 0x92 bytes
      Telerik.Windows.Controls.Chart.dll!Telerik.Charting.AxesChartAreaModel.ArrangeOverride(Telerik.Charting.RadRect rect) + 0x28 bytes
      Telerik.Windows.Controls.Chart.dll!Telerik.Charting.ChartNode.Arrange(Telerik.Charting.RadRect rect, bool shouldRoundLayout) + 0x15 bytes
      Telerik.Windows.Controls.Chart.dll!Telerik.Charting.ChartAreaModel.Arrange() + 0x41 bytes
      Telerik.Windows.Controls.Chart.dll!Telerik.Windows.Controls.RadChartBase.UpdateChartArea() + 0x24 bytes
      Telerik.Windows.Controls.Chart.dll!Telerik.Windows.Controls.RadChartBase.CallUpdateUI() + 0x6 bytes
      Telerik.Windows.Controls.Chart.dll!Telerik.Windows.Controls.RadChartBase.ArrangeOverride(System.Windows.Size finalSize) + 0x25 bytes
      System.Windows.dll!System.Windows.FrameworkElement.ArrangeOverride(System.IntPtr nativeTarget, double inWidth, double inHeight, out double outWidth, out double outHeight) + 0x43 bytes

    Dan
  2. Dan
    Dan avatar
    8 posts
    Member since:
    Jul 2011

    Posted 27 May 2012 Link to this post

    I've experimented a bit more. Here's what my chart looks like:

    <telerikChart:RadCartesianChart x:Name="_chart"
                                    Grid.Row="1"
                                    Width="616"
                                    Margin="0,12,12,12"
                                    Height="400"
                                    UseLayoutRounding="True">
        <telerikChart:RadCartesianChart.Behaviors>
            <telerikChart:ChartPanAndZoomBehavior ZoomMode="None"
                                                  PanMode="Horizontal"/>
        </telerikChart:RadCartesianChart.Behaviors>
        <telerikChart:RadCartesianChart.Grid>
            <telerikChart:CartesianChartGrid
                                             MajorLinesVisibility="Y"
                                             MajorXLinesRenderMode="All"
                                             Style="{StaticResource gridStyleDashed}" />
        </telerikChart:RadCartesianChart.Grid>
     
        <telerikChart:RadCartesianChart.VerticalAxis>
            <telerikChart:LinearAxis />
        </telerikChart:RadCartesianChart.VerticalAxis>
     
        <telerikChart:RadCartesianChart.HorizontalAxis>
            <telerikChart:DateTimeContinuousAxis LabelFitMode="Rotate"
                                                     LabelFormat="MM/dd/yy"
                                                     PlotMode="OnTicks"
                                                     Style="{StaticResource timeLineAxisStyleWithTicks}"/>
        </telerikChart:RadCartesianChart.HorizontalAxis>
     
        <telerikChart:BarSeries ValueBinding="Weight"
                                CategoryBinding="Date">
            <telerikChart:BarSeries.PointTemplate>
                <DataTemplate>
                    <Border Background="{StaticResource PhoneAccentBrush}"
                            BorderBrush="{StaticResource PhoneAccentBrush}"
                            BorderThickness="0"/>
                </DataTemplate>
            </telerikChart:BarSeries.PointTemplate>
        </telerikChart:BarSeries>
    </telerikChart:RadCartesianChart>

    It hits the exception if my codebehind sets the y axis range to what I determine are good numbers:

    LinearAxis verticalAxis = (LinearAxis)_chart.VerticalAxis;
    verticalAxis.Minimum = trends.MinWeightRange;
    verticalAxis.Maximum = trends.MaxWeightRange;

    I can work on a minimal repro if you don't have any ideas what's going wrong.
  3. DevCraft banner
  4. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 30 May 2012 Link to this post

    Hello Dan,

    I tested the XAML you provided with random values for min/max and a dummy data set however I was not able to reproduce the exception. Please post the data set and the min/max values with which the chart crashes. If it is now too much trouble, a minimal sample app with would be best.
    I am looking forward to your reply.

    Regards,
    Victor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Dan
    Dan avatar
    8 posts
    Member since:
    Jul 2011

    Posted 30 May 2012 Link to this post

    I'm having trouble getting a minimal repro. I'll keep working on it. From a bit of debugging from the crash, it looks like in CategoricalSeriesRoundLayoutContext.SnapPointToGridLine, point.numericalPlot.SnapTickIndex is -17, which is where the index out of range is coming from.

    Is there an easy way to debug against the source? I am having issues building the source as downloaded.
  6. Dan
    Dan avatar
    8 posts
    Member since:
    Jul 2011

    Posted 31 May 2012 Link to this post

    Ok, I tracked it down. The key is to have a data point that's out of the vertical range and is a multiple of the tick spacing. For example, if the range of the graph is 170.0 to 230.0 and you have a point on the graph at 0.0, NumericalAxisModel.GetSnapTickIndex will return -17 and then CategoricalSeriesRoundLayoutContext.SnapPointToGridLine will try to access ticks[-17]. I've verified that changing:

    if (point.numericalPlot.SnapTickIndex == -1 ||
        point.numericalPlot.SnapTickIndex >= point.numericalPlot.Axis.ticks.Count)
    {
        return;
    }

    to:

    if (point.numericalPlot.SnapTickIndex < 0 ||
        point.numericalPlot.SnapTickIndex >= point.numericalPlot.Axis.ticks.Count)
    {
        return;
    }

    fixes the problem. But, I don't know if it's the right fix. I've attached a sample project to my support ticket.
  7. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 31 May 2012 Link to this post

    Hello Dan,

    Thanks for the sample project. It demonstrates the exception perfectly. This is a bug indeed and it will be fixed in a future release. For now, the best solution is to filter your data points so that no point lies outside the minimum/maximum range of the axis. Using a LINQ statement to select a filtered data set should be pretty straightforward.

    If you have no problem modifying the source code of the chart the fix you suggested seems appropriate so you can do that instead and avoid the filtering step. Your Telerik points have been updated for the bug report.

    Please write again if you need further assistance. 

    Regards,
    Victor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
DevCraft banner