MFC中用teechart控件做了一个实时动态曲线显示的程序,程序修改前
在以下程序中,teechart控件能随着时间动态地将数据实时的用曲线显示出来。
BOOL CCodeAddCurve_1Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_TeeChart.Series(0).Clear();
m_TeeChart.Series(1).Clear();
m_TeeChart.Series(2).Clear();
InitChart();
SetTimer(1,1000,NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
其中,InitChart();如下:
void CCodeAddCurve_1Dlg::InitChart()
{
//设置X轴与Y轴的标题:
m_TeeChart.GetAxis().GetLeft().GetTitle().SetCaption("temperature");
m_TeeChart.GetAxis().GetBottom().GetTitle().SetCaption("time");
m_TeeChart.Series(0).FillSampleValues(50); //向第一个Line序列中添加数据
m_TeeChart.Series(1).FillSampleValues(50); //向第二个Line序列中添加数据
m_TeeChart.Series(2).FillSampleValues(50); //向第二个Line序列中添加数据
m_TeeChart.Series(0).SetColor(RGB(255, 0, 0)); // 设置第一条曲线的颜色为红色
m_TeeChart.Series(1).SetColor(RGB(0, 255, 0)); //设置第二条曲线的颜色为绿色
m_TeeChart.Series(2).SetColor(RGB(0, 100, 255)); //设置第三条曲线的颜色为蓝色
}
定时器函数:
void CCodeAddCurve_1Dlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CString str;
SYSTEMTIME st;
memset(&st, 0, sizeof(SYSTEMTIME));
GetLocalTime(&st);
str.Format("%02d:%02d",st.wMinute,st.wSecond);
m_TeeChart.Series(0).Add(75,str,1); // 此处900是人为设定的一个纵坐标输出值,lable是横坐标的输出值
m_TeeChart.Series(1).Add(60,str,1);
m_TeeChart.Series(2).Add(50,str,1);
m_TeeChart.GetAxis().GetBottom().Scroll(1.0,TRUE); // 将左侧的曲线移出界面
SetTimer(1,1000,NULL);
CDialog::OnTimer(nIDEvent);
}
但是若将以上程序做如下修改,teechart控件上就没有实时曲线显示了,哎…这是怎么回事额?不知道什么原因?
BOOL CCodeAddCurve_1Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_TeeChart.Series(0).Clear();
m_TeeChart.Series(1).Clear();
m_TeeChart.Series(2).Clear();
InitChart();
SetTimer(1,1000,NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
其中,InitChart();如下:
void CCodeAddCurve_1Dlg::InitChart()
{
CString str;
SYSTEMTIME st;
memset(&st, 0, sizeof(SYSTEMTIME));
GetLocalTime(&st);
str.Format("%02d:%02d",st.wMinute,st.wSecond);
//设置X轴与Y轴的标题:
m_TeeChart.GetAxis().GetLeft().GetTitle().SetCaption("temperature");
m_TeeChart.GetAxis().GetBottom().GetTitle().SetCaption("time");
m_TeeChart.Series(0).FillSampleValues(50); //向第一个Line序列中添加数据
m_TeeChart.Series(1).FillSampleValues(50); //向第二个Line序列中添加数据
m_TeeChart.Series(2).FillSampleValues(50); //向第二个Line序列中添加数据
m_TeeChart.Series(0).SetColor(RGB(255, 0, 0)); // 设置第一条曲线的颜色为红色
m_TeeChart.Series(1).SetColor(RGB(0, 255, 0)); //设置第二条曲线的颜色为绿色
m_TeeChart.Series(2).SetColor(RGB(0, 100, 255)); //设置第三条曲线的颜色为蓝色
m_TeeChart.Series(0).Add(75,str,1); // 此处900是人为设定的一个纵坐标输出值,lable是横坐标的输出值
m_TeeChart.Series(1).Add(60,str,1);
m_TeeChart.Series(2).Add(50,str,1);
}
定时器函数:
void CCodeAddCurve_1Dlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
m_TeeChart.GetAxis().GetBottom().Scroll(1.0,TRUE); // 将左侧的曲线移出界面
SetTimer(1,1000,NULL);
CDialog::OnTimer(nIDEvent);
}
麻烦各位帮小弟看看,为什么teechart界面上是空白的,没有曲线显示了,怎么会这样?????小弟感激不尽……
BOOL CCodeAddCurve_1Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_TeeChart.Series(0).Clear();
m_TeeChart.Series(1).Clear();
m_TeeChart.Series(2).Clear();
InitChart();
SetTimer(1,1000,NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
其中,InitChart();如下:
void CCodeAddCurve_1Dlg::InitChart()
{
//设置X轴与Y轴的标题:
m_TeeChart.GetAxis().GetLeft().GetTitle().SetCaption("temperature");
m_TeeChart.GetAxis().GetBottom().GetTitle().SetCaption("time");
m_TeeChart.Series(0).FillSampleValues(50); //向第一个Line序列中添加数据
m_TeeChart.Series(1).FillSampleValues(50); //向第二个Line序列中添加数据
m_TeeChart.Series(2).FillSampleValues(50); //向第二个Line序列中添加数据
m_TeeChart.Series(0).SetColor(RGB(255, 0, 0)); // 设置第一条曲线的颜色为红色
m_TeeChart.Series(1).SetColor(RGB(0, 255, 0)); //设置第二条曲线的颜色为绿色
m_TeeChart.Series(2).SetColor(RGB(0, 100, 255)); //设置第三条曲线的颜色为蓝色
}
定时器函数:
void CCodeAddCurve_1Dlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CString str;
SYSTEMTIME st;
memset(&st, 0, sizeof(SYSTEMTIME));
GetLocalTime(&st);
str.Format("%02d:%02d",st.wMinute,st.wSecond);
m_TeeChart.Series(0).Add(75,str,1); // 此处900是人为设定的一个纵坐标输出值,lable是横坐标的输出值
m_TeeChart.Series(1).Add(60,str,1);
m_TeeChart.Series(2).Add(50,str,1);
m_TeeChart.GetAxis().GetBottom().Scroll(1.0,TRUE); // 将左侧的曲线移出界面
SetTimer(1,1000,NULL);
CDialog::OnTimer(nIDEvent);
}
但是若将以上程序做如下修改,teechart控件上就没有实时曲线显示了,哎…这是怎么回事额?不知道什么原因?
BOOL CCodeAddCurve_1Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_TeeChart.Series(0).Clear();
m_TeeChart.Series(1).Clear();
m_TeeChart.Series(2).Clear();
InitChart();
SetTimer(1,1000,NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
其中,InitChart();如下:
void CCodeAddCurve_1Dlg::InitChart()
{
CString str;
SYSTEMTIME st;
memset(&st, 0, sizeof(SYSTEMTIME));
GetLocalTime(&st);
str.Format("%02d:%02d",st.wMinute,st.wSecond);
//设置X轴与Y轴的标题:
m_TeeChart.GetAxis().GetLeft().GetTitle().SetCaption("temperature");
m_TeeChart.GetAxis().GetBottom().GetTitle().SetCaption("time");
m_TeeChart.Series(0).FillSampleValues(50); //向第一个Line序列中添加数据
m_TeeChart.Series(1).FillSampleValues(50); //向第二个Line序列中添加数据
m_TeeChart.Series(2).FillSampleValues(50); //向第二个Line序列中添加数据
m_TeeChart.Series(0).SetColor(RGB(255, 0, 0)); // 设置第一条曲线的颜色为红色
m_TeeChart.Series(1).SetColor(RGB(0, 255, 0)); //设置第二条曲线的颜色为绿色
m_TeeChart.Series(2).SetColor(RGB(0, 100, 255)); //设置第三条曲线的颜色为蓝色
m_TeeChart.Series(0).Add(75,str,1); // 此处900是人为设定的一个纵坐标输出值,lable是横坐标的输出值
m_TeeChart.Series(1).Add(60,str,1);
m_TeeChart.Series(2).Add(50,str,1);
}
定时器函数:
void CCodeAddCurve_1Dlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
m_TeeChart.GetAxis().GetBottom().Scroll(1.0,TRUE); // 将左侧的曲线移出界面
SetTimer(1,1000,NULL);
CDialog::OnTimer(nIDEvent);
}
麻烦各位帮小弟看看,为什么teechart界面上是空白的,没有曲线显示了,怎么会这样?????小弟感激不尽……
...全文
相关推荐
MFC下TeeChart和HightSpeedChart动态绘制曲线图
文章地址:http://blog.csdn.net/czyt1988/article/details/20136895 《绘图控件第五讲——绘制动态曲线》 介绍MFC常用绘图控件TeeChart和CChartCtrl绘制动态曲线的方法
基于MFC串口编程和曲线图绘制(visual studio2008,Teechart绘图控件)的程序总结
前言今年刚进入公司按经理的要求为底盘测控机写了一个小小的console。这也是第一次教认真的完成整个程序的编写。程序不大,所用技术比较基础也不前卫,属于初级程序员的练手程序(知识的整理和搬运)。虽然如此,期间也由于一次选用的方案不正确而推掉重做了一次。要是有什么写的不对的地方请留言赐教,谢谢。 介绍以下是这次用到的主要知识内容: 1)MSCOMM串口控件编程; 2)Window API函数的串口编程
使用MFC的MSCOMM串口控件,Teechar控件绘制曲线图
** 一、将串口接受到的数据保存在一个队列当中,然后再显示到折线图上。 ** 效果图: 二、实现步骤 1、创建一个空白的MFC对话框:
VS2010中MFC利用TeeChart控件实现画三维图
该例程实现了VS2010下利用TeeChart控件绘制三维图
基于MFC的TeeChart控件
基于VC中MFC的图表控件,可以实现各种图标显示,大量效果选择,功能强大,界面精美,是表格显示的不二选择。


进程/线程/DLL
