Hi,
I customize example fast line view to show my data with time scale, but in axes X just show 1 value - 00:00:43 in every time.
here my code:
void CFastLineView::CreateChart() { CXTPChartContent* pContent = m_wndChartControl.GetContent();
CXTPChartSeriesCollection* pCollection = pContent->GetSeries(); pCollection->RemoveAll();
if (pCollection) { for (int s = 0; s < SeriesCount[m_nSeriesCount]; s++) { CXTPChartSeries* pSeries = pCollection->Add(new CXTPChartSeries()); if (pSeries) { pSeries->SetName(_T("Series"));
CXTPChartFastLineSeriesStyle* pStyle = new CXTPChartFastLineSeriesStyle(); pSeries->SetStyle(pStyle);
pStyle->SetAntialiasing(m_bAntialiased);
pSeries->SetArgumentScaleType(xtpChartScaleTime); } } }
// Set the X and Y Axis title for the series. CXTPChartDiagram2D* pDiagram = DYNAMIC_DOWNCAST(CXTPChartDiagram2D, pCollection->GetAt(0)->GetDiagram()); ASSERT(pDiagram);
pDiagram->SetAllowZoom(TRUE);
pDiagram->GetAxisY()->GetRange()->SetMaxValue(1000.1); pDiagram->GetAxisY()->GetRange()->SetAutoRange(FALSE); pDiagram->GetAxisY()->SetAllowZoom(FALSE);
pDiagram->GetAxisX()->GetLabel()->GetFormat()->SetDateTimeCategory(xtpChartDateTimeCustom); pDiagram->GetAxisX()->GetLabel()->GetFormat()->SetDateTimeFormat(_T("ss:mm:hh \n mm:dd:yyy")); pDiagram->GetAxisX()->GetRange()->SetAutoRange(FALSE); pDiagram->GetAxisX()->GetRange()->SetMinValue(COleDateTime(2019, 10, 29, 13, 25, 0)); pDiagram->GetAxisX()->GetRange()->SetZoomLimit(10);
pDiagram->GetAxisX()->SetInterlaced(FALSE); pDiagram->GetAxisY()->SetInterlaced(FALSE);
pDiagram->GetPane()->GetFillStyle()->SetFillMode(xtpChartFillSolid); }
void CFastLineView::AddPoint() { CXTPChartContent* pContent = m_wndChartControl.GetContent();
CXTPChartSeriesCollection* pCollection = pContent->GetSeries();
int nCount = 0; int nTest = 1000; if (pCollection) { for (int s = 0; s < pCollection->GetCount(); s++) { CXTPChartSeries* pSeries = pCollection->GetAt(s); if (pSeries) { int nValue = 50;
nCount = pSeries->GetPoints()->GetCount();
if (nCount) nValue = (int)pSeries->GetPoints()->GetAt(nCount - 1)->GetValue(0);
nValue = rand()/30;
if (nValue < 0) nValue = 0; if (nValue > 1000) nValue = 1000;
pSeries->GetPoints()->Add(new CXTPChartSeriesPoint(m_dt, nValue)); m_dt += COleDateTimeSpan(0, 0, 0, 5); } } }
CXTPChartDiagram2D* pDiagram = DYNAMIC_DOWNCAST(CXTPChartDiagram2D, m_wndChartControl.GetContent()->GetPanels()->GetAt(0)); ASSERT(pDiagram);
CXTPChartAxisRange* pRange = pDiagram->GetAxisX()->GetRange(); pRange->SetMaxValue(m_dt); }
|
------------- Beyond Godlike
|