在解决方案添加 ChartCtrl文件夹
然后在dlg.h的头文件添加包含ChartCtrl头文件
#include "ChartCtrl/ChartCtrl.h"
#include "ChartCtrl/ChartLabel.h"
#include "ChartCtrl/ChartTitle.h"
#include "ChartCtrl/ChartAxisLabel.h"
#include "ChartCtrl/ChartLineSerie.h"
在diglog初始化曲线
CChartStandardAxis* pBottomAxis =
m_ChartCtrl.CreateStandardAxis(CChartCtrl::BottomAxis);
pBottomAxis->SetMinMax(0, 300);
CChartStandardAxis* pLeftAxis =
m_ChartCtrl.CreateStandardAxis(CChartCtrl::LeftAxis);
pLeftAxis->SetMinMax(0, 130);
m_ChartCtrl.GetTitle()->AddString("温度曲线图");
m_ChartCtrl.SetBackGradient(RGB(255, 255, 255), RGB(150, 150, 255), gtVertical);
CChartAxisLabel *pLable = NULL;
CChartAxis *pAxis = NULL;
pAxis = m_ChartCtrl.GetLeftAxis();
if (pAxis)
{
pLable = pAxis->GetLabel();
}
if (pLable)
{
pLable->SetText("温度C°");
}
pAxis = m_ChartCtrl.GetBottomAxis();
pAxis->SetAutomatic(true);
if (pAxis)
{
pLable = pAxis->GetLabel();
}
if (pLable)
{
pLable->SetText("时间S");
}
m_ChartCtrl.RemoveAllSeries();
pLineSerie = m_ChartCtrl.CreateLineSerie();
pLineSerie->SetSeriesOrdering(poNoOrdering);//设置为无序
m_ChartCtrl.EnableRefresh(false);
k = rand() % 50 + rand()%100;
xx++;
pLineSerie->AddPoint(xx, k);
m_ChartCtrl.EnableRefresh(true);