This question is locked. New answers and comments are not allowed.
Hi
I have a grid and chart with the same data.
When the data is all zero, an exception occurred but the grid is fine and the chart isn't.
In addition y-axis of the chart does not show.
The exception says that Value does not fall within the expected range.
The attached file contains the exception and normal case.
Codes are:
If you want more information, please tell me.
Thanks in advance and sorry for my English.
I have a grid and chart with the same data.
When the data is all zero, an exception occurred but the grid is fine and the chart isn't.
In addition y-axis of the chart does not show.
The exception says that Value does not fall within the expected range.
The attached file contains the exception and normal case.
Codes are:
// The data with all zeroresult = e.Result;#region All Zero Testresult.Clear();for (int j = 1; j <= 2; j++){for (int i = 0; i < 7; i++){ result.Add(new SQLExecStatsAnalItemsRetData { LEV = (i + 1).ToString() ,VALUE = "0" ,VALUE_RATE = "0" ,TOTAL = "0" ,TOTAL_RATE = "0" ,INSTANTSHOT_NO = (j + 100).ToString() });}}#endregion// Xaxis#region All Zero TestxAxis = new string[] { "101", "102" };instantShotInfo["101"] = "2010-11-11";instantShotInfo["102"] = "2010-12-11";#endregion// Set the data for chartfor (int i = 0; i < xAxis.Length; i++){ tmpResultForChart = new List<double>(); for (int j = 0; j < result.Count; j++) { if ((result[j].INSTANTSHOT_NO).Equals(xAxis[i])) { tmpResultForChart.Add(Convert.ToDouble(result[j].TOTAL_RATE)); } } resultForChart[xAxis[i]] = tmpResultForChart;}for (int i = 0; i < xAxis.Length; i++){ List<double> tmp = resultForChart[xAxis[i]]; dataSeries1.Add(new DataPoint() { YValue = tmp[0], XCategory = xAxis[i] }); dataSeries2.Add(new DataPoint() { YValue = tmp[1], XCategory = xAxis[i] }); dataSeries3.Add(new DataPoint() { YValue = tmp[2], XCategory = xAxis[i] }); dataSeries4.Add(new DataPoint() { YValue = tmp[3], XCategory = xAxis[i] }); dataSeries5.Add(new DataPoint() { YValue = tmp[4], XCategory = xAxis[i] }); dataSeries6.Add(new DataPoint() { YValue = tmp[5], XCategory = xAxis[i] }); dataSeries7.Add(new DataPoint() { YValue = tmp[6], XCategory = xAxis[i] });}// Chart propertieschtResult.MinWidth = 1200;chtResult.Height = 330;chtResult.Background = new SolidColorBrush(Colors.White);chtResult.BorderBrush = new SolidColorBrush(Colors.Transparent);chtResult.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;chtResult.DefaultView.ChartArea.DataSeries.Clear();chtResult.DefaultView.ChartArea.SmartLabelsEnabled = false;chtResult.DefaultView.ChartArea.FontSize = 10;chtResult.DefaultView.ChartLegend.Header = string.Empty;chtResult.DefaultView.ChartLegend.FontSize = 10;chtResult.DefaultView.ChartLegend.LegendItemMarkerShape = MarkerShape.Circle;chtResult.DefaultView.ChartArea.AxisX.LayoutMode = AxisLayoutMode.Inside;chtResult.DefaultView.ChartArea.AxisX.LabelRotationAngle = -30;chtResult.DefaultView.ChartArea.AxisY.MinValue = 0;chtResult.DefaultView.ChartArea.AxisY.MaxValue = 100;chtResult.DefaultView.ChartArea.AxisY.ExtendDirection = AxisExtendDirection.Smart;chtResult.DefaultView.ChartArea.AxisY.DefaultLabelFormat = numberFormatString;CustomGridLine fifty = new CustomGridLine();fifty.Visibility = System.Windows.Visibility.Visible;fifty.StrokeThickness = 1;fifty.Opacity = 30;fifty.Stroke = new SolidColorBrush(Colors.Red);fifty.YIntercept = 50;chtResult.DefaultView.ChartArea.Annotations.Add(fifty);Border border = new Border();border.BorderThickness = new Thickness(2);border.CornerRadius = new CornerRadius(5);border.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 173, 216, 230));border.Child = new TextBlock(){ Text = MaeStrings.esains_CHART_TITLE, Margin = new Thickness(7, 3, 7, 3), FontSize = 12};chtResult.DefaultView.ChartTitle.Content = border;chtResult.DefaultView.ChartTitle.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;If you want more information, please tell me.
Thanks in advance and sorry for my English.