【(VC/MFC)绘图控件TeeChart问题】如何设置X轴显示时间(vs2010)
网上看到教程说m_Chart.Series(0).GetXValues().SetDateTime(true);可以使x轴显示时间但是在vs2010下并没有找到SetDa...
网上看到教程说
m_Chart.Series(0).GetXValues().SetDateTime(true);
可以使x轴显示时间
但是在vs2010下并没有找到SetDateTime这个函数,于是很蛋疼!用的是TeeChartv5.0
CSeries ChartSpeed = (CSeries)m_ChartTrend.Series(0);
ChartSpeed.get_XValues()后就没看到有那个函数!
如何设置为x轴显示时间?
CSeries ChartSpeed = (CSeries)m_ChartTrend.Series(0);
long i(0);
float pf[1];
//ces
COleDateTime oletime(2011,10,10,10,10,10);
COleDateTimeSpan oleSpantime(0,0,0,1);
ZeroMemory(g_fArraySpeed,sizeof(float)*16384);
for (i=0;i<m_nSpeedTrendDataLength;i++)
{
pf[0]=g_fArraySpeed[i];
SafeArrayPutElement(m_pSAy,&i,pf);
SafeArrayPutElement(m_pSAx,&i,&oletime);
oletime+=oleSpantime;
}
// (ChartSpeed.get_XValues())->SetDateTime(true);(这里没有SetDateTime这个函数)
ChartSpeed.Clear();
ChartSpeed.AddArray(m_nSpeedTrendDataLength,m_AY,m_AX); 展开
m_Chart.Series(0).GetXValues().SetDateTime(true);
可以使x轴显示时间
但是在vs2010下并没有找到SetDateTime这个函数,于是很蛋疼!用的是TeeChartv5.0
CSeries ChartSpeed = (CSeries)m_ChartTrend.Series(0);
ChartSpeed.get_XValues()后就没看到有那个函数!
如何设置为x轴显示时间?
CSeries ChartSpeed = (CSeries)m_ChartTrend.Series(0);
long i(0);
float pf[1];
//ces
COleDateTime oletime(2011,10,10,10,10,10);
COleDateTimeSpan oleSpantime(0,0,0,1);
ZeroMemory(g_fArraySpeed,sizeof(float)*16384);
for (i=0;i<m_nSpeedTrendDataLength;i++)
{
pf[0]=g_fArraySpeed[i];
SafeArrayPutElement(m_pSAy,&i,pf);
SafeArrayPutElement(m_pSAx,&i,&oletime);
oletime+=oleSpantime;
}
// (ChartSpeed.get_XValues())->SetDateTime(true);(这里没有SetDateTime这个函数)
ChartSpeed.Clear();
ChartSpeed.AddArray(m_nSpeedTrendDataLength,m_AY,m_AX); 展开
2个回答
展开全部
最近也在学习Teechart,看看这个,X轴显示的时间,Y轴显示的是随机数。
void CTestTeeChartDlg::InitChart()
{
m_ctrlChart.Series(0).Clear();
m_ctrlChart.GetPage().SetMaxPointsPerPage(1440);
COleDateTime CurTime = COleDateTime::GetCurrentTime();
COleDateTime tempTime ;
tempTime = CurTime;
CurTime.SetTime(0,0,0);
CurTime.SetDate(tempTime.GetYear(),tempTime.GetMonth(),tempTime.GetDay());
COleDateTimeSpan tmSpan = COleDateTimeSpan(0,0,1,0);
CString csTime ;
for(int i=0; i<80; i++)
{
csTime = CurTime.Format("%H:%M");
float fzVal = float(GetRandom(12000,28000)/100);
m_ctrlChart.Series(0).AddXY(i,fzVal,csTime,i);
CurTime += tmSpan;
}
m_ctrlChart.GetAxis().GetLeft().SetMinMax(100, 300);
}
希望对你有帮助。
void CTestTeeChartDlg::InitChart()
{
m_ctrlChart.Series(0).Clear();
m_ctrlChart.GetPage().SetMaxPointsPerPage(1440);
COleDateTime CurTime = COleDateTime::GetCurrentTime();
COleDateTime tempTime ;
tempTime = CurTime;
CurTime.SetTime(0,0,0);
CurTime.SetDate(tempTime.GetYear(),tempTime.GetMonth(),tempTime.GetDay());
COleDateTimeSpan tmSpan = COleDateTimeSpan(0,0,1,0);
CString csTime ;
for(int i=0; i<80; i++)
{
csTime = CurTime.Format("%H:%M");
float fzVal = float(GetRandom(12000,28000)/100);
m_ctrlChart.Series(0).AddXY(i,fzVal,csTime,i);
CurTime += tmSpan;
}
m_ctrlChart.GetAxis().GetLeft().SetMinMax(100, 300);
}
希望对你有帮助。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询