Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Chart Control
  New Posts New Posts RSS Feed - Fast line view with time scale
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Fast line view with time scale

 Post Reply Post Reply
Author
Message
PhonG View Drop Down
Newbie
Newbie


Joined: 03 June 2011
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote PhonG Quote  Post ReplyReply Direct Link To This Post Topic: Fast line view with time scale
    Posted: 29 October 2019 at 3:46am
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:

Quote 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.