回答編集履歴
2
見直しキャンペーン中
test
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
[Axis.Interval プロパティ (System.Windows.Forms.DataVisualization.Charting) | Microsoft Docs](https://docs.microsoft.com/ja-jp/dotnet/api/system.windows.forms.datavisualization.charting.axis.interval?view=netframework-4.8)
|
6
6
|
|
7
7
|
これが知りたかったってことでしょうか?
|
8
|
-
しかし画像のような状態にするには、`Axis
|
8
|
+
しかし画像のような状態にするには、`AxisY.Maximum`をいじってますよね?(この画像もどこかから借りてきてる??)
|
9
9
|
|
10
10
|
特に何もしなければ左の軸の最大値が40になっていい感じに調整してくれましたが、あくまで最大値は変えたくないということでしょうか?
|
11
11
|
|
1
見直しキャンペーン中
test
CHANGED
@@ -1,349 +1,175 @@
|
|
1
1
|
[ChartArea.AxisY プロパティ (System.Windows.Forms.DataVisualization.Charting) | Microsoft Docs](https://docs.microsoft.com/ja-jp/dotnet/api/system.windows.forms.datavisualization.charting.chartarea.axisy?view=netframework-4.8)
|
2
|
-
|
3
|
-
|
4
2
|
|
5
3
|
[ChartArea.AxisY2 プロパティ (System.Windows.Forms.DataVisualization.Charting) | Microsoft Docs](https://docs.microsoft.com/ja-jp/dotnet/api/system.windows.forms.datavisualization.charting.chartarea.axisy2?view=netframework-4.8)
|
6
4
|
|
7
|
-
|
8
|
-
|
9
5
|
[Axis.Interval プロパティ (System.Windows.Forms.DataVisualization.Charting) | Microsoft Docs](https://docs.microsoft.com/ja-jp/dotnet/api/system.windows.forms.datavisualization.charting.axis.interval?view=netframework-4.8)
|
10
6
|
|
11
|
-
|
12
|
-
|
13
7
|
これが知りたかったってことでしょうか?
|
14
|
-
|
15
8
|
しかし画像のような状態にするには、`AxisX.Interval`をいじってますよね?(この画像もどこかから借りてきてる??)
|
16
|
-
|
17
|
-
|
18
9
|
|
19
10
|
特に何もしなければ左の軸の最大値が40になっていい感じに調整してくれましたが、あくまで最大値は変えたくないということでしょうか?
|
20
11
|
|
21
|
-
|
22
|
-
|
23
12
|
となると`Interval`をいじって、どちらかに合わすしかないですよね?
|
24
|
-
|
25
13
|
きれいに割り切れない場合は、当然`Maximum`か`Minimum`をいじるしかないですね(ラベルが3.3333とかじゃイヤすぎますし^^;
|
26
14
|
|
27
|
-
|
28
|
-
|
29
15
|
1. Chart1 できるだけ画像に合わせた場合
|
30
|
-
|
31
16
|
1. Chart2 これといって何もしなかった場合
|
32
|
-
|
33
17
|
1. Chart3 左の軸を右に合わせた場合
|
34
|
-
|
35
18
|
1. Chart4 右の軸を左に合わせた場合
|
36
19
|
|
37
|
-
|
38
|
-
|
39
|
-
```
|
20
|
+
```cs
|
40
|
-
|
41
21
|
using System.Drawing;
|
42
|
-
|
43
22
|
using System.Windows.Forms;
|
44
|
-
|
45
23
|
using System.Windows.Forms.DataVisualization.Charting;
|
46
24
|
|
47
|
-
|
48
|
-
|
49
25
|
namespace Questions370834
|
50
|
-
|
51
26
|
{
|
52
|
-
|
53
27
|
public partial class Form1 : Form
|
54
|
-
|
55
28
|
{
|
56
|
-
|
57
29
|
public Form1()
|
58
|
-
|
59
30
|
{
|
60
|
-
|
61
31
|
InitializeComponent();
|
62
32
|
|
63
|
-
|
64
|
-
|
65
33
|
Chart1();
|
66
|
-
|
67
34
|
Chart2();
|
68
|
-
|
69
35
|
Chart3();
|
70
|
-
|
71
36
|
Chart4();
|
72
|
-
|
73
37
|
}
|
74
38
|
|
75
|
-
|
76
|
-
|
77
39
|
private void Chart1()
|
78
|
-
|
79
40
|
{
|
80
|
-
|
81
41
|
chart1.Titles.Add("Chart1");
|
82
|
-
|
83
42
|
chart1.Series.Clear();
|
84
43
|
|
44
|
+
var series1 = new Series
|
45
|
+
{
|
46
|
+
BorderWidth = 2,
|
47
|
+
ChartType = SeriesChartType.StepLine,
|
48
|
+
Color = Color.Cyan,
|
49
|
+
IsVisibleInLegend = false,
|
50
|
+
};
|
51
|
+
var series2 = new Series
|
52
|
+
{
|
53
|
+
ChartType = SeriesChartType.Column,
|
54
|
+
Color = Color.Red,
|
55
|
+
IsVisibleInLegend = false,
|
56
|
+
YAxisType = AxisType.Secondary,
|
57
|
+
};
|
85
58
|
|
59
|
+
for (var i = 0; i < 15; i++)
|
60
|
+
{
|
61
|
+
series1.Points.Add(new DataPoint(i, 2.5 * (i + 1)));
|
62
|
+
series2.Points.Add(new DataPoint(i, 1.25 * (i + 1)));
|
63
|
+
}
|
64
|
+
|
65
|
+
chart1.ChartAreas[0].AxisX.Interval = 5;
|
66
|
+
chart1.ChartAreas[0].AxisY.Maximum = 50; // わざとこうしないと提示画像のようにならない
|
67
|
+
|
68
|
+
chart1.Series.Add(series2);
|
69
|
+
chart1.Series.Add(series1);
|
70
|
+
}
|
71
|
+
|
72
|
+
private void Chart2()
|
73
|
+
{
|
74
|
+
chart2.Titles.Add("Chart2");
|
75
|
+
chart2.Series.Clear();
|
86
76
|
|
87
77
|
var series1 = new Series
|
88
|
-
|
89
78
|
{
|
90
|
-
|
91
79
|
BorderWidth = 2,
|
92
|
-
|
93
80
|
ChartType = SeriesChartType.StepLine,
|
94
|
-
|
95
81
|
Color = Color.Cyan,
|
96
|
-
|
97
82
|
IsVisibleInLegend = false,
|
98
|
-
|
83
|
+
};
|
84
|
+
var series2 = new Series
|
85
|
+
{
|
86
|
+
ChartType = SeriesChartType.Column,
|
87
|
+
Color = Color.Red,
|
88
|
+
IsVisibleInLegend = false,
|
89
|
+
YAxisType = AxisType.Secondary,
|
99
90
|
};
|
100
91
|
|
92
|
+
for (var i = 0; i < 15; i++)
|
93
|
+
{
|
94
|
+
series1.Points.Add(new DataPoint(i, 2.5 * (i + 1)));
|
95
|
+
series2.Points.Add(new DataPoint(i, 1.25 * (i + 1)));
|
96
|
+
}
|
97
|
+
|
98
|
+
chart2.ChartAreas[0].AxisX.Interval = 5;
|
99
|
+
//chart2.ChartAreas[0].AxisY.Maximum = 50;
|
100
|
+
|
101
|
+
chart2.Series.Add(series2);
|
102
|
+
chart2.Series.Add(series1);
|
103
|
+
}
|
104
|
+
|
105
|
+
private void Chart3()
|
106
|
+
{
|
107
|
+
chart3.Titles.Add("Chart3");
|
108
|
+
chart3.Series.Clear();
|
109
|
+
|
110
|
+
var series1 = new Series
|
111
|
+
{
|
112
|
+
BorderWidth = 2,
|
113
|
+
ChartType = SeriesChartType.StepLine,
|
114
|
+
Color = Color.Cyan,
|
115
|
+
IsVisibleInLegend = false,
|
116
|
+
};
|
101
117
|
var series2 = new Series
|
102
|
-
|
103
118
|
{
|
104
|
-
|
105
119
|
ChartType = SeriesChartType.Column,
|
106
|
-
|
107
120
|
Color = Color.Red,
|
108
|
-
|
109
121
|
IsVisibleInLegend = false,
|
110
|
-
|
111
122
|
YAxisType = AxisType.Secondary,
|
112
|
-
|
113
123
|
};
|
114
124
|
|
125
|
+
for (var i = 0; i < 15; i++)
|
126
|
+
{
|
127
|
+
series1.Points.Add(new DataPoint(i, 2.5 * (i + 1)));
|
128
|
+
series2.Points.Add(new DataPoint(i, 1.25 * (i + 1)));
|
129
|
+
}
|
115
130
|
|
131
|
+
chart3.ChartAreas[0].AxisX.Interval = 5;
|
132
|
+
chart3.ChartAreas[0].AxisY.Interval = 12.5;
|
133
|
+
chart3.ChartAreas[0].AxisY.Maximum = 50;
|
134
|
+
|
135
|
+
chart3.Series.Add(series2);
|
136
|
+
chart3.Series.Add(series1);
|
137
|
+
}
|
138
|
+
|
139
|
+
private void Chart4()
|
140
|
+
{
|
141
|
+
chart4.Titles.Add("Chart4");
|
142
|
+
chart4.Series.Clear();
|
143
|
+
|
144
|
+
var series1 = new Series
|
145
|
+
{
|
146
|
+
BorderWidth = 2,
|
147
|
+
ChartType = SeriesChartType.StepLine,
|
148
|
+
Color = Color.Cyan,
|
149
|
+
IsVisibleInLegend = false,
|
150
|
+
};
|
151
|
+
var series2 = new Series
|
152
|
+
{
|
153
|
+
ChartType = SeriesChartType.Column,
|
154
|
+
Color = Color.Red,
|
155
|
+
IsVisibleInLegend = false,
|
156
|
+
YAxisType = AxisType.Secondary,
|
157
|
+
};
|
116
158
|
|
117
159
|
for (var i = 0; i < 15; i++)
|
118
|
-
|
119
160
|
{
|
120
|
-
|
121
161
|
series1.Points.Add(new DataPoint(i, 2.5 * (i + 1)));
|
122
|
-
|
123
162
|
series2.Points.Add(new DataPoint(i, 1.25 * (i + 1)));
|
124
|
-
|
125
163
|
}
|
126
164
|
|
127
|
-
|
128
|
-
|
129
|
-
chart1.ChartAreas[0].AxisX.Interval = 5;
|
130
|
-
|
131
|
-
chart1.ChartAreas[0].AxisY.Maximum = 50; // わざとこうしないと提示画像のようにならない
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
chart1.Series.Add(series2);
|
136
|
-
|
137
|
-
chart1.Series.Add(series1);
|
138
|
-
|
139
|
-
}
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
private void Chart2()
|
144
|
-
|
145
|
-
{
|
146
|
-
|
147
|
-
chart2.Titles.Add("Chart2");
|
148
|
-
|
149
|
-
chart2.Series.Clear();
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
var series1 = new Series
|
154
|
-
|
155
|
-
{
|
156
|
-
|
157
|
-
BorderWidth = 2,
|
158
|
-
|
159
|
-
ChartType = SeriesChartType.StepLine,
|
160
|
-
|
161
|
-
Color = Color.Cyan,
|
162
|
-
|
163
|
-
IsVisibleInLegend = false,
|
164
|
-
|
165
|
-
};
|
166
|
-
|
167
|
-
var series2 = new Series
|
168
|
-
|
169
|
-
{
|
170
|
-
|
171
|
-
ChartType = SeriesChartType.Column,
|
172
|
-
|
173
|
-
Color = Color.Red,
|
174
|
-
|
175
|
-
IsVisibleInLegend = false,
|
176
|
-
|
177
|
-
YAxisType = AxisType.Secondary,
|
178
|
-
|
179
|
-
};
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
for (var i = 0; i < 15; i++)
|
184
|
-
|
185
|
-
{
|
186
|
-
|
187
|
-
series1.Points.Add(new DataPoint(i, 2.5 * (i + 1)));
|
188
|
-
|
189
|
-
series2.Points.Add(new DataPoint(i, 1.25 * (i + 1)));
|
190
|
-
|
191
|
-
}
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
chart2.ChartAreas[0].AxisX.Interval = 5;
|
196
|
-
|
197
|
-
//chart2.ChartAreas[0].AxisY.Maximum = 50;
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
chart2.Series.Add(series2);
|
202
|
-
|
203
|
-
chart2.Series.Add(series1);
|
204
|
-
|
205
|
-
}
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
private void Chart3()
|
210
|
-
|
211
|
-
{
|
212
|
-
|
213
|
-
chart3.Titles.Add("Chart3");
|
214
|
-
|
215
|
-
chart3.Series.Clear();
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
var series1 = new Series
|
220
|
-
|
221
|
-
{
|
222
|
-
|
223
|
-
BorderWidth = 2,
|
224
|
-
|
225
|
-
ChartType = SeriesChartType.StepLine,
|
226
|
-
|
227
|
-
Color = Color.Cyan,
|
228
|
-
|
229
|
-
IsVisibleInLegend = false,
|
230
|
-
|
231
|
-
};
|
232
|
-
|
233
|
-
var series2 = new Series
|
234
|
-
|
235
|
-
{
|
236
|
-
|
237
|
-
ChartType = SeriesChartType.Column,
|
238
|
-
|
239
|
-
Color = Color.Red,
|
240
|
-
|
241
|
-
IsVisibleInLegend = false,
|
242
|
-
|
243
|
-
YAxisType = AxisType.Secondary,
|
244
|
-
|
245
|
-
};
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
for (var i = 0; i < 15; i++)
|
250
|
-
|
251
|
-
{
|
252
|
-
|
253
|
-
series1.Points.Add(new DataPoint(i, 2.5 * (i + 1)));
|
254
|
-
|
255
|
-
series2.Points.Add(new DataPoint(i, 1.25 * (i + 1)));
|
256
|
-
|
257
|
-
}
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
chart3.ChartAreas[0].AxisX.Interval = 5;
|
262
|
-
|
263
|
-
chart3.ChartAreas[0].AxisY.Interval = 12.5;
|
264
|
-
|
265
|
-
chart3.ChartAreas[0].AxisY.Maximum = 50;
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
chart3.Series.Add(series2);
|
270
|
-
|
271
|
-
chart3.Series.Add(series1);
|
272
|
-
|
273
|
-
}
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
private void Chart4()
|
278
|
-
|
279
|
-
{
|
280
|
-
|
281
|
-
chart4.Titles.Add("Chart4");
|
282
|
-
|
283
|
-
chart4.Series.Clear();
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
var series1 = new Series
|
288
|
-
|
289
|
-
{
|
290
|
-
|
291
|
-
BorderWidth = 2,
|
292
|
-
|
293
|
-
ChartType = SeriesChartType.StepLine,
|
294
|
-
|
295
|
-
Color = Color.Cyan,
|
296
|
-
|
297
|
-
IsVisibleInLegend = false,
|
298
|
-
|
299
|
-
};
|
300
|
-
|
301
|
-
var series2 = new Series
|
302
|
-
|
303
|
-
{
|
304
|
-
|
305
|
-
ChartType = SeriesChartType.Column,
|
306
|
-
|
307
|
-
Color = Color.Red,
|
308
|
-
|
309
|
-
IsVisibleInLegend = false,
|
310
|
-
|
311
|
-
YAxisType = AxisType.Secondary,
|
312
|
-
|
313
|
-
};
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
for (var i = 0; i < 15; i++)
|
318
|
-
|
319
|
-
{
|
320
|
-
|
321
|
-
series1.Points.Add(new DataPoint(i, 2.5 * (i + 1)));
|
322
|
-
|
323
|
-
series2.Points.Add(new DataPoint(i, 1.25 * (i + 1)));
|
324
|
-
|
325
|
-
}
|
326
|
-
|
327
|
-
|
328
|
-
|
329
165
|
chart4.ChartAreas[0].AxisX.Interval = 5;
|
330
|
-
|
331
166
|
chart4.ChartAreas[0].AxisY.Maximum = 50;
|
332
|
-
|
333
167
|
chart4.ChartAreas[0].AxisY2.Interval = 4;
|
334
168
|
|
335
|
-
|
336
|
-
|
337
169
|
chart4.Series.Add(series2);
|
338
|
-
|
339
170
|
chart4.Series.Add(series1);
|
340
|
-
|
341
171
|
}
|
342
|
-
|
343
172
|
}
|
344
|
-
|
345
173
|
}
|
346
|
-
|
347
174
|
```
|
348
|
-
|
349
175
|
![アプリ画像](21a9a1d480534a863e371b6c01602030.png)
|