回答編集履歴
1
見直しキャンペーン中
test
CHANGED
@@ -1,151 +1,77 @@
|
|
1
1
|
Chartコントロールは使ったことがないので何か間違いがあるかもしれませんが、それっぽく表示されているように思います。
|
2
2
|
|
3
3
|
![アプリ画像](8f2d5ede87cfcefacc9b509c568c847a.png)
|
4
|
-
|
5
|
-
```
|
4
|
+
```cs
|
6
|
-
|
7
5
|
using System;
|
8
|
-
|
9
6
|
using System.IO;
|
10
|
-
|
11
7
|
using System.Text;
|
12
|
-
|
13
8
|
using System.Windows.Forms;
|
14
|
-
|
15
9
|
using System.Windows.Forms.DataVisualization.Charting;
|
16
10
|
|
17
|
-
|
18
|
-
|
19
11
|
namespace Questions231716
|
20
|
-
|
21
12
|
{
|
22
|
-
|
23
13
|
public partial class Form1 : Form
|
24
|
-
|
25
14
|
{
|
26
|
-
|
27
15
|
public Form1()
|
28
|
-
|
29
16
|
{
|
30
|
-
|
31
17
|
InitializeComponent();
|
32
|
-
|
33
18
|
Dammy();
|
34
|
-
|
35
19
|
}
|
36
20
|
|
37
|
-
|
38
|
-
|
39
21
|
private void button1_Click(object sender, EventArgs e)
|
40
|
-
|
41
22
|
{
|
42
|
-
|
43
23
|
var list = File.ReadAllLines("test.csv");
|
44
24
|
|
45
|
-
|
46
|
-
|
47
25
|
var legend = "グラフ1";
|
48
|
-
|
49
26
|
chart1.Series.Clear();
|
50
27
|
|
51
|
-
|
52
|
-
|
53
28
|
// Minimum Maximum ちょっと微妙
|
54
|
-
|
55
29
|
chart1.ChartAreas[0].AxisX.Minimum = DateTime.MinValue.AddHours(12).ToOADate();
|
56
|
-
|
57
30
|
chart1.ChartAreas[0].AxisX.Maximum = DateTime.MinValue.AddHours(17).ToOADate();
|
58
|
-
|
59
31
|
chart1.ChartAreas[0].AxisX.Interval = 1;
|
60
|
-
|
61
32
|
chart1.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Hours;
|
62
|
-
|
63
33
|
chart1.ChartAreas[0].AxisX.IntervalOffsetType = DateTimeIntervalType.Hours;
|
64
|
-
|
65
34
|
chart1.ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm:ss";
|
66
35
|
|
67
|
-
|
68
|
-
|
69
36
|
chart1.ChartAreas[0].AxisY.Minimum = 1.5;
|
70
|
-
|
71
37
|
chart1.ChartAreas[0].AxisY.Maximum = 2.5;
|
72
38
|
|
73
|
-
|
74
|
-
|
75
39
|
chart1.Series.Add(legend);
|
76
|
-
|
77
40
|
chart1.Series[legend].ChartType = SeriesChartType.Line;
|
78
|
-
|
79
41
|
chart1.Series[legend].LegendText = legend;
|
80
|
-
|
81
42
|
chart1.Series[legend].XValueType = ChartValueType.Time;
|
82
|
-
|
83
43
|
chart1.Series[legend].IsVisibleInLegend = false;
|
84
|
-
|
85
44
|
chart1.Series[legend].IsValueShownAsLabel = false;
|
86
45
|
|
87
|
-
|
88
|
-
|
89
46
|
foreach(var line in list)
|
90
|
-
|
91
47
|
{
|
92
|
-
|
93
48
|
// ここも微妙だが日付は固定したほうが安全そう
|
94
|
-
|
95
49
|
var xValue = DateTime.Parse("0001/01/01 " + line.Substring(0, 8));
|
96
|
-
|
97
50
|
var yValue = line.Substring(12, 4);
|
98
51
|
|
52
|
+
var dp = new DataPoint();
|
53
|
+
dp.SetValueXY(xValue, yValue);
|
54
|
+
dp.IsValueShownAsLabel = false;
|
55
|
+
chart1.Series[legend].Points.Add(dp);
|
56
|
+
}
|
57
|
+
}
|
99
58
|
|
100
|
-
|
59
|
+
private void Dammy()
|
60
|
+
{
|
101
|
-
|
61
|
+
var r = new Random();
|
102
|
-
|
62
|
+
var sb = new StringBuilder();
|
103
|
-
|
63
|
+
var d = DateTime.MinValue.AddHours(12);
|
104
|
-
|
105
|
-
|
64
|
+
while(true)
|
106
|
-
|
65
|
+
{
|
107
|
-
|
66
|
+
d += TimeSpan.FromSeconds(r.Next(60, 600));
|
108
|
-
|
67
|
+
if(17 <= d.Hour) break;
|
68
|
+
sb.Append(d.ToString("HH:mm:ss"));
|
69
|
+
sb.Append(",00,");
|
70
|
+
sb.AppendLine((r.NextDouble() + 1.5).ToString("0.00"));
|
109
71
|
}
|
110
72
|
|
73
|
+
File.WriteAllText("test.csv", sb.ToString());
|
111
74
|
}
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
private void Dammy()
|
116
|
-
|
117
|
-
{
|
118
|
-
|
119
|
-
var r = new Random();
|
120
|
-
|
121
|
-
var sb = new StringBuilder();
|
122
|
-
|
123
|
-
var d = DateTime.MinValue.AddHours(12);
|
124
|
-
|
125
|
-
while(true)
|
126
|
-
|
127
|
-
{
|
128
|
-
|
129
|
-
d += TimeSpan.FromSeconds(r.Next(60, 600));
|
130
|
-
|
131
|
-
if(17 <= d.Hour) break;
|
132
|
-
|
133
|
-
sb.Append(d.ToString("HH:mm:ss"));
|
134
|
-
|
135
|
-
sb.Append(",00,");
|
136
|
-
|
137
|
-
sb.AppendLine((r.NextDouble() + 1.5).ToString("0.00"));
|
138
|
-
|
139
|
-
}
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
File.WriteAllText("test.csv", sb.ToString());
|
144
|
-
|
145
|
-
}
|
146
|
-
|
147
75
|
}
|
148
|
-
|
149
76
|
}
|
150
|
-
|
151
77
|
```
|