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

RadCartesianChart divide by zero exception

1 Answer 65 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
sean
Top achievements
Rank 1
sean asked on 24 Jan 2017, 02:58 PM

Hi I'm using the RadCartesianChart to plot multiple series of data.

When the data range is small, I receive a divide by zero exception.

01.<telerik:RadCartesianChart Name="GraphSeriesChart" Grid.Row="2" Margin="10" Background="LightGray" >
02. 
03.        <telerik:RadCartesianChart.Behaviors >
04.            <telerik:ChartPanAndZoomBehavior ZoomMode="Both" DragMode="Pan" PanMode="Both" />
05.        </telerik:RadCartesianChart.Behaviors>
06. 
07.        <telerik:RadCartesianChart.HorizontalAxis >
08.            <telerik:DateTimeCategoricalAxis LabelFormat="HH:mm:ss" MajorTickInterval="250" LabelFitMode="MultiLine" />
09.        </telerik:RadCartesianChart.HorizontalAxis>
10. 
11.        <telerik:RadCartesianChart.VerticalAxis >
12.            <telerik:LinearAxis HorizontalLocation="Left" Visibility="Visible" />
13.        </telerik:RadCartesianChart.VerticalAxis>
14. 
15.        <telerik:RadCartesianChart.SeriesProvider >
16.            <telerik:ChartSeriesProvider Source="{Binding TECSeriesSelected}" >
17.                <telerik:ChartSeriesProvider.SeriesDescriptors >
18.                    <telerik:CategoricalSeriesDescriptor ValuePath="Value" CategoryPath="Time" >
19.                    </telerik:CategoricalSeriesDescriptor>
20.                </telerik:ChartSeriesProvider.SeriesDescriptors>
21.            </telerik:ChartSeriesProvider>
22.        </telerik:RadCartesianChart.SeriesProvider>
23. 
24.        <telerik:RadCartesianChart.Grid >
25.            <telerik:CartesianChartGrid MajorLinesVisibility="XY" >
26.                <telerik:CartesianChartGrid.MajorXLineStyle >
27.                    <Style TargetType="Line" >
28.                        <Setter Property="Stroke" Value="Gray" />
29.                    </Style>
30.                </telerik:CartesianChartGrid.MajorXLineStyle>
31.                <telerik:CartesianChartGrid.MajorYLineStyle >
32.                    <Style TargetType="Line" >
33.                        <Setter Property="Stroke" Value="Gray" />
34.                    </Style>
35.                </telerik:CartesianChartGrid.MajorYLineStyle>
36.            </telerik:CartesianChartGrid>
37.        </telerik:RadCartesianChart.Grid>
38.    </telerik:RadCartesianChart>

 

01.TECSeriesSelected.Clear();
02. 
03.TECSeriesSelected.Add(new RadObservableCollection<DataPoint>(new DataPoint[3]));
04.TECSeriesSelected.Add(new RadObservableCollection<DataPoint>(new DataPoint[3]));
05. 
06.TECSeriesSelected[0][0] = new DataPoint();
07.TECSeriesSelected[0][0].Value = 0;
08.TECSeriesSelected[0][0].Time = new DateTime(0);
09. 
10.TECSeriesSelected[0][1] = new DataPoint();
11.TECSeriesSelected[0][1].Value = 0;
12.TECSeriesSelected[0][1].Time = new DateTime(10);
13. 
14.TECSeriesSelected[0][2] = new DataPoint();
15.TECSeriesSelected[0][2].Value = 0;
16.TECSeriesSelected[0][2].Time = new DateTime(20);
17. 
18.TECSeriesSelected[1][0] = new DataPoint();
19.TECSeriesSelected[1][0].Value = 2.75E-28F;
20.TECSeriesSelected[1][0].Time = new DateTime(0);
21. 
22.TECSeriesSelected[1][1] = new DataPoint();
23.TECSeriesSelected[1][1].Value = 2.75E-28F;
24.TECSeriesSelected[1][1].Time = new DateTime(10);
25. 
26.TECSeriesSelected[1][2] = new DataPoint();
27.TECSeriesSelected[1][2].Value = 2.75E-28F;
28.TECSeriesSelected[1][2].Time = new DateTime(20);

Is there a way to fix this issue?

1 Answer, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 27 Jan 2017, 02:51 PM
Hi Sean,

I can confirm that there is an issue related to the rendering of RadChartView when there are values equal to 0. I added the issue to our backlog and you can track its status by subscribing to the related public item. I added Telerik points to your account in appreciation for reporting the issue to us.

As a workaround, I could suggest you set the Minimum and Maximum properties of the Axis.

Hope this helps.

Regards,
Tanya
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
ChartView
Asked by
sean
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Share this question
or