public TeamCntChart() { InitializeComponent(); //cartesianChart1 队伍过题数统计 ColumnSeries columnSeries = new ColumnSeries(); columnSeries.DataLabels = true; columnSeries.LabelPoint = point => point.Y + ""; columnSeries.Values = new ChartValues <ObservableValue>(); for (int i = 1; i <= OperateForm.problemCnt; ++i) { try { columnSeries.Values.Add(new ObservableValue(double.Parse(DBTool.getProblemTeamByCnt(i).ToString()))); } catch (Exception ex) { print("网络连接中断!"); Application.Exit(); } } cartesianChart1.Series.Clear(); columnSeries.Title = "team"; cartesianChart1.Series.Add(columnSeries); string[] labels1 = new string[OperateForm.problemCnt]; for (int i = 0; i < OperateForm.problemCnt; ++i) { labels1[i] = (i + 1).ToString(); } cartesianChart1.AxisX.Clear(); cartesianChart1.AxisX.Add(new Axis { Labels = labels1, 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 }); cartesianChart1.AxisY.Clear(); cartesianChart1.AxisY.Add(new Axis { LabelFormatter = value => value + " teams", Separator = new Separator() }); }
public void getCartesianChart() { //cartesianChart1 队伍过题数统计 ColumnSeries columnSeries = new ColumnSeries(); columnSeries.DataLabels = true; columnSeries.LabelPoint = point => point.Y + ""; columnSeries.Values = new ChartValues <ObservableValue>(); for (int i = 1; i <= OperateForm.problemCnt; ++i) { try { columnSeries.Values.Add(new ObservableValue(double.Parse(DBTool.getProblemTeamByCnt(i).ToString()))); } catch (Exception ex) { print("网络连接中断!"); Application.Exit(); } } cartesianChart1.Series.Clear(); columnSeries.Title = "team"; cartesianChart1.Series.Add(columnSeries); string[] labels1 = new string[OperateForm.problemCnt]; for (int i = 0; i < OperateForm.problemCnt; ++i) { labels1[i] = (i + 1).ToString(); } cartesianChart1.AxisX.Clear(); cartesianChart1.AxisX.Add(new Axis { Labels = labels1, 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 }); cartesianChart1.AxisY.Clear(); cartesianChart1.AxisY.Add(new Axis { LabelFormatter = value => value + " teams", Separator = new Separator() }); //cartesianChart2 题目提交分类统计 cartesianChart2.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>(); for (int j = 0; j < OperateForm.problemCnt; ++j) { try { if (OperateForm.result[i] != 4) { stackedColumnSeries.Values.Add(-double.Parse((DBTool.getTotResultByResultAndNum(OperateForm.result[i], j)).ToString())); } else { stackedColumnSeries.Values.Add(double.Parse((DBTool.getTotResultByResultAndNum(OperateForm.result[i], j)).ToString())); } } catch (Exception ex) { print("网络连接中断!"); Application.Exit(); } } cartesianChart2.Series.Add(stackedColumnSeries); } string[] labels2 = new string[OperateForm.problemCnt]; for (int i = 0; i < OperateForm.problemCnt; ++i) { labels2[i] = OperateForm.charMp[i]; } cartesianChart2.AxisX.Clear(); cartesianChart2.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 }); cartesianChart2.AxisY.Clear(); cartesianChart2.AxisY.Add(new Axis { LabelFormatter = value => value + "" }); }