public void getcartesianChart3() { DateTime NOW = DateTime.Now; if (DateTime.Compare(NOW, OperateForm.end_time) > 0) { NOW = OperateForm.end_time; } if (DateTime.Compare(NOW, OperateForm.start_time) < 0) { NOW = OperateForm.start_time; } TimeSpan timeSpan = NOW - OperateForm.start_time; int len = (int)double.Parse(timeSpan.TotalMinutes.ToString()); len = Math.Min(300, len); len = Math.Max(0, len); len /= 10; cartesianChart3.Series.Clear(); for (int i = 0; i < 4; ++i) { StackedColumnSeries stackedColumnSeries = new StackedColumnSeries(); stackedColumnSeries.StackMode = StackMode.Values; stackedColumnSeries.DataLabels = false; stackedColumnSeries.Title = OperateForm.resultName[i]; stackedColumnSeries.Values = new ChartValues <double>(); DateTime st = OperateForm.start_time; DateTime nx = new DateTime(); for (int j = 0; j < len; ++j) { nx = st.AddMinutes(10); try { if (OperateForm.result[i] != 4) { stackedColumnSeries.Values.Add(-double.Parse(DBTool.getTotSubmitByStEdAndResult(st.ToString(), nx.ToString(), OperateForm.result[i]).ToString())); } else { stackedColumnSeries.Values.Add(double.Parse(DBTool.getTotSubmitByStEdAndResult(st.ToString(), nx.ToString(), OperateForm.result[i]).ToString())); } } catch (Exception ex) { print("网络连接中断!"); Application.Exit(); } st = nx; } cartesianChart3.Series.Add(stackedColumnSeries); } string[] labels2 = new string[len]; for (int i = 0; i < len; ++i) { labels2[i] = ((i + 1) * 10).ToString(); } cartesianChart3.AxisX.Clear(); cartesianChart3.AxisX.Add(new Axis { Labels = labels2, Separator = new Separator // force the separator step to 1, so it always display all labels { Step = 1, IsEnabled = false //disable it to make it invisible. }, LabelsRotation = 0 }); cartesianChart3.AxisY.Clear(); cartesianChart3.AxisY.Add(new Axis { LabelFormatter = value => value + "" }); }
public void getcartesianChart() { ChartValues <double> AC_Values = new ChartValues <double>(); ChartValues <double> Submit_Values = new ChartValues <double>(); DateTime NOW = DateTime.Now; DateTime last_time; if (DateTime.Compare(NOW, OperateForm.end_time) > 0) { NOW = OperateForm.end_time; } if (DateTime.Compare(NOW, OperateForm.start_time) < 0) { NOW = OperateForm.start_time; } last_time = NOW; TimeSpan timeSpan = NOW - OperateForm.start_time; DateTime st = OperateForm.start_time; DateTime nx = new DateTime(); int len = (int)double.Parse(timeSpan.TotalMinutes.ToString()); len = Math.Min(300, len); len = Math.Max(0, len); AC_Values.Add(0); Submit_Values.Add(0); for (int i = 0; i < len; i += 1) { nx = st.AddMinutes(1); try { AC_Values.Add(double.Parse(DBTool.getTotSubmitByStEdAndResult(st.ToString(), nx.ToString(), 4).ToString())); Submit_Values.Add(double.Parse(DBTool.getTotSubmitByStEd(st.ToString(), nx.ToString()).ToString())); } catch (Exception ex) { print("网络连接中断!"); Application.Exit(); } st = nx; } cartesianChart1.Series.Clear(); cartesianChart1.Series.Add(new LineSeries { Values = AC_Values, StrokeThickness = 2, StrokeDashArray = new System.Windows.Media.DoubleCollection(new double[] { 2 }), Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(107, 185, 69)), Fill = System.Windows.Media.Brushes.Transparent, LineSmoothness = 0, PointGeometrySize = 1, Title = "AC", }); cartesianChart1.Series.Add(new LineSeries { Values = Submit_Values, StrokeThickness = 2, Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(28, 142, 196)), Fill = System.Windows.Media.Brushes.Transparent, LineSmoothness = 1, PointGeometrySize = 1, PointForeground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(34, 46, 49)), Title = "Submit" }); cartesianChart1.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(34, 46, 49)); cartesianChart1.AxisX.Add(new Axis { IsMerged = true, Separator = new Separator { Step = 20, StrokeThickness = 1, StrokeDashArray = new System.Windows.Media.DoubleCollection(new double[] { 2 }), Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(64, 79, 86)) } }); cartesianChart1.AxisY.Add(new Axis { IsMerged = true, Separator = new Separator { StrokeThickness = 1.5, StrokeDashArray = new System.Windows.Media.DoubleCollection(new double[] { 4 }), Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(64, 79, 86)) } }); }