카테고리 없음

[wpf] c# ZedGraph 사용하기 - x축 시간 형식으로 사용하는 방법

(ㅇㅅㅎ) 2021. 7. 14. 11:08
728x90
반응형

 ZedGraph에서 x축을 시간 형식으로 사용하는 방법은 다음과 같습니다.

GraphPane pane = graph.GraphPane;
LineItem lc1 = pane.AddCurve("datas", points, Color.Black, SymbolType.None);
lc1.Line.Width = 3.0f;
pane.Legend.IsVisible = false;

// x축 : 시간 순서로 사용할 경우
// Unit의 경우 AxisType이 Date일때만 사용함
pane.XAxis.Type = AxisType.Date;
pane.XAxis.Title.Text = "Time (HH:mm)";
pane.XAxis.Scale.Format = "HH:mm";
pane.XAxis.Scale.MajorUnit = DateUnit.Minute;
pane.XAxis.Scale.MinorUnit = DateUnit.Second;

// 데이터 추가
for(int i=0; i<10; i++)
{
	DateTime dt = DateTime.Now.AddMinutes(i);
	points.Add(new XDate(dt), i);
}

graph.AxisChange();
graph.Invalidate();

 

반응형