C# 에서 MSchart는 의외로 다양한 입력형태를 제공하고 있다.
많은 편리함을 제공한다
- series.Points.AddXY123456789101112131415
private
void
SplineChartExample()
{
this
.chartControl.Series.Clear();
this
.chartControl.Titles.Add(
"Total Income"
);
Series series =
this
.chartControl.Series.Add(
"Total Income"
);
series.ChartType = SeriesChartType.Spline;
series.Points.AddXY(
"September"
,
100
);
series.Points.AddXY(
"Obtober"
,
300
);
series.Points.AddXY(
"November"
,
800
);
series.Points.AddXY(
"December"
,
200
);
series.Points.AddXY(
"January"
,
600
);
series.Points.AddXY(
"February"
,
400
);
}
- series.Points.AddXY123456789101112131415161718192021222324252627
public
void
GraphGenerate(Chart grph)
{ DateTime[] dtx;
double
[][] DyArr =
new
double
[
2
][];
#region Data Generate
////////////////////////////////////////////////////////
// Make Data
Random r =
new
Random();
DateTime start = DateTime.Parse(xtxt);
int
cnt =
int
.Parse(scnt);
dtx =
new
DateTime[cnt];
DyArr[
0
] =
new
double
[cnt];
DyArr[
1
] =
new
double
[cnt];
for
(
int
i =
0
; i < cnt; i++)
{
dtx[i] = start.AddMinutes(
5
*i);
DyArr[
0
][i] = Math.Sin(Math.PI *
0.1
* i)*r.Next(-
1
,
100
);
DyArr[
1
][i] = Math.Cos(Math.PI *
0.1
* i) * r.Next(-
10
,
50
);
}
#endregion
#region Draw Chart
for
(
int
i =
0
; i < cnt; i++)
{
sers[
0
].Points.AddXY(dtx[i], DyArr[
0
][i]);
sers[
1
].Points.AddXY(dtx[i], DyArr[
1
][i]);
}
#endregion
}
- series.Points.DataBindXY123456789101112131415161718192021222324
public
void
GraphGenerate(Chart grph)
{ DateTime[] dtx;
double
[][] DyArr =
new
double
[
2
][];
#region Data Generate
////////////////////////////////////////////////////////
// Make Data
Random r =
new
Random();
DateTime start = DateTime.Parse(xtxt);
int
cnt =
int
.Parse(scnt);
dtx =
new
DateTime[cnt];
DyArr[
0
] =
new
double
[cnt];
DyArr[
1
] =
new
double
[cnt];
for
(
int
i =
0
; i < cnt; i++)
{
dtx[i] = start.AddMinutes(
5
*i);
DyArr[
0
][i] = Math.Sin(Math.PI *
0.1
* i)*r.Next(-
1
,
100
);
DyArr[
1
][i] = Math.Cos(Math.PI *
0.1
* i) * r.Next(-
10
,
50
);
}
#endregion
#region Draw Chart
sers[
0
].Points.DataBindXY(dtx, DyArr[
0
]);
sers[
1
].Points.DataBindXY(dtx, DyArr[
1
]);
#endregion
}
'개발언어 > C#' 카테고리의 다른 글
C# ContextMenu에 separator 넣기 (0) | 2017.10.10 |
---|---|
C# 확장 메서드 구현 및 호출,Implement and Call a Custom Extension Method (0) | 2017.10.10 |
Random 난수 발생에 대한 검토 (0) | 2017.10.01 |
C# 과 VB.NET Context Menu 사용법 (0) | 2017.09.28 |
On Error Resume Next for C#? (0) | 2017.08.30 |