UCTestCurveChart.cs
5.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Test.UC
{
[ToolboxItem(false)]
public partial class UCTestCurveChart : UserControl
{
public UCTestCurveChart()
{
InitializeComponent();
}
private void UCTestCurveChart_Load(object sender, EventArgs e)
{
Random r = new Random();
this.ucCurve1.SetCurveText(new string[] { "周一", "周二", "周三", "周四", "周五", "周六", "周日" });
float[] data1 = new float[7];
float[] data2 = new float[7];
float[] data3 = new float[7];
for (int i = 0; i < data1.Length; i++)
{
data1[i] = r.Next(0, 100);
data2[i] = r.Next(0, 100);
data3[i] = r.Next(0, 100);
}
ucCurve1.SetLeftCurve("A", data1);
ucCurve1.SetLeftCurve("B", data2);
ucCurve1.SetLeftCurve("C", data3);
//辅助文字
ucCurve1.AddMarkText("A", 0, "周一数据", Color.Red);
ucCurve1.AddMarkText("A", 1, "周二数据");
ucCurve1.AddMarkText("B", 0, "周一数据");
ucCurve1.AddMarkText("B", 1, "周二数据");
ucCurve1.AddAuxiliaryLabel(new HZH_Controls.Controls.AuxiliaryLable()
{
LocationX = 0.8f,
Text = "不合格数:5",
TextBack = Brushes.Red,
TextBrush = Brushes.White
});
ucCurve1.AddLeftAuxiliary(20, Color.Red);
ucCurve2.SetLeftCurve("A", null, Color.Red);
ucCurve2.SetLeftCurve("B", null, Color.Orange);
ucCurve2.SetLeftCurve("C", null, Color.Blue);
ucCurve2.SetLeftCurve("D", null, Color.Green);
this.ucCurve3.SetCurveText(new string[] { "第一次模拟", "第二次模拟", "第三次模拟", "第四次模拟", "第五次模拟", "第六次模拟", "第七次模拟" });
float[] data31 = new float[6];
float[] data32 = new float[6];
float[] data33 = new float[6];
float[] data34 = new float[6];
float[] data35 = new float[6];
float[] data36 = new float[6];
for (int i = 0; i < data31.Length; i++)
{
data31[i] = r.Next(10 + i * 10, 40+i*10);
data32[i] = r.Next(10 + i * 10, 40+i*10);
data33[i] = r.Next(10 + i * 10, 40+i*10);
data34[i] = r.Next(10 + i * 10, 40+i*10);
data35[i] = r.Next(10 + i * 10, 40+i*10);
data36[i] = r.Next(10 + i * 10, 40+i*10);
}
ucCurve3.SetLeftCurve("语文", data31);
ucCurve3.SetLeftCurve("数学", data32);
ucCurve3.SetLeftCurve("英语", data33);
ucCurve3.SetLeftCurve("化学", data34);
ucCurve3.SetLeftCurve("生物", data35);
ucCurve3.SetLeftCurve("物理", data36);
for (int i = 0; i < data31.Length; i++)
{
ucCurve3.AddMarkText("语文", i, data31[i].ToString());
ucCurve3.AddMarkText("数学", i, data32[i].ToString());
ucCurve3.AddMarkText("英语", i, data33[i].ToString());
ucCurve3.AddMarkText("化学", i, data34[i].ToString());
ucCurve3.AddMarkText("生物", i, data35[i].ToString());
ucCurve3.AddMarkText("物理", i, data36[i].ToString());
}
}
int count_tick = 0;
private void timer1_Tick(object sender, EventArgs e)
{
count_tick++;
float random1 = (float)(Math.Sin(2 * Math.PI * count_tick / 30) * 0.5d + 0.5);
float random2 = (float)(Math.Sin(2 * Math.PI * count_tick / 50) * 0.5d + 0.5);
float random3 = (float)(Math.Cos(2 * Math.PI * count_tick / 80) * 0.5d + 0.5);
float random4 = (float)(Math.Cos(2 * Math.PI * count_tick / 10) * 0.5d + 0.5);
if (count_tick % 50 == 0)
{
ucCurve2.AddCurveData(
new string[] { "A", "B", "C", "D" },
new float[]
{
random1*10 + 80,
random2*20+50,
random3*20+30,
random4*10+20,
}, new string[] { "标签1", "标签2", "标签3", "标签4" }
);
}
else
{
ucCurve2.AddCurveData(
new string[] { "A", "B", "C", "D" },
new float[]
{
random1*10 + 80,
random2*20+50,
random3*20+30,
random4*10+20,
}
);
}
if (count_tick > 10000)
count_tick = 0;
}
}
}