[제품종류] IEC1000Lite
[개발환경] Visual Studio 2008 C#
=============== 질 문 ===============SmartDraw를 이용하여, 그래프를 표현하는 중 첨부파일과 같은 문제가 있어서 문의 드립니다.
최초 BackLayer 에서 X, Y축, GridLine를 그려준 뒤,
초기값에 맞도록 Y축 라벨값을 표시합니다.
이 후 동작에서 문제 없이 동작하다가 (첨부파일 좌측 이미지)
수신된 값이 현재 그래프 스케일에 맞지 않으면,
sChart.Chart.PutDataAllClear();
sChart.Erase();
sChart.BackLayer.Erase();
위 명령을 수행한 뒤 다시 수신된 값에 맞도록 BackLayer 를 다시 그립니다.
이후 그래프를 그리면 PenStyle(색상, 굵기)이 다르게 표시되는 문제가 있습니다. (첨부파일 우측 이미지)
잘못된 API 사용법 때문에 이런걸까요?
=============== 답 변 ===============
안녕하세요.
위의 경우처럼 표현되는 이유는 첨부해 주신 코드처럼 설정을 초기화 하신 후에 GridLine을 그려주기 위한 PenStyle 설정 값에 따라 그래프가 그려졌기 때문입니다.
말씀하신 것 과 같이 동작하기 위해서는 GridLine을 그린 뒤 Chart에 대한 PenStyle을 다시 적용해야 합니다. 적용 방법은 아래의 순서에 따라 코드를 적용해주시면 됩니다.
1. sChart에 대한 초기화 (PutDataAllClear, Erase, BackLayer. Erase)
2. GridLine 등의 Back Layer 그리기 (PenStyle 설정 후 그리드 등 그리기)
3. Chart.ChartChannelPenStyle 설정하여 차트에 대한 PenStyle 재설정
(smartDraw1.Chart.ChartChannelPenStyle = smartDraw_ChartChannelPenStyle1;)
4. PutData를 통한 데이터 입력
[예시 코드]
smartDraw1.Chart.PutDataAllClear();
smartDraw1.Erase();
smartDraw1.BackLayer.Erase();
smartDraw1.BackLayer.SetPenStyle(Color.Gray, 1);
// 그리드를 그리는 코드 ~ 생략 ~
smartDraw1.Chart.ChartChannelPenStyle = smartDraw_ChartChannelPenStyle1;
smartDraw1.Chart.SetChartConfig();
int iValue;
smartDraw1.Chart.PutData(iValue);
// or smartTimer1.Start();
// smartTimer를 사용하여 Chart를 그리고 있는 경우 Timer Start
해당 방법의 적용에 어려움이 있으시다면 070-7094-5002로 연락주시면 더 자세하게 안내해 드리도록 하겠습니다.
감사합니다.