Limiting chart display to 100 of 1000 points in a series?

TeeChart for ActiveX, COM and ASP
Post Reply
JediOutcast
Newbie
Newbie
Posts: 4
Joined: Wed Jan 20, 2016 12:00 am

Limiting chart display to 100 of 1000 points in a series?

Post by JediOutcast » Tue Oct 04, 2016 11:08 pm

Thanks Marc Meumann for helping me on my last issue.
I've made good of progress but have a new issue.
I need a little help.
I cant get my chart to only display the last 100 out of 1000 samples in a series.
Is this possible? It almost works. I may just need a way to force the chart to display correctly after 100 points then after every time I delete an XY point in the series.
If I limit the series to 100 samples the display updates perfectly filing left to right then wrapping, old data drops off the left and new data is added on the right, a sliding window of the current data. But I then cant page through any of the old data after a run.
I'd like to have 1000 samples in my Series(0) then only display the latest 100 samples but be able to page every 100 samples a page back to the beginning after a program has run.
It scales the left y axis fine.
If will fill the chart up to 100 samples fine left to right then it stops updating the chart at all, until it reaches 1000 then start to update the chart again
Do I have to turn off automatic settings in the chart properties?
Or are thiere other settings, like number of items to display from a series?
If you see any other issues let me know.
Here's the code:

Code: Select all

void CRunFlowmeterPage::Add_ChartData( uint32 iCount, flt64 fVolume )
{    
    double dTargetRange = (m_fUpSpecLim - m_fLowSpecLim);
    double dMin = m_fLowSpecLim;
    double dMax = m_fUpSpecLim;
    double dMargin =  .1 * (dMax - dMin);  // 10% of delta spec limit range

    long  lMaxSeriesCount = 300;        // max series count or elements in series
    long  lMaxVsiblePoints = 100;       // max visible points and points per page

    double dTotCount = m_Chart1.Series(0).GetCount();

    // Limit number of samples to save use Delete for moving window:
    if( dTotCount > lMaxSeriesCount )
    {
       m_Chart1.Series(0).Delete(0);
       m_Chart1.Series(1).Delete(0);
       m_Chart1.Series(2).Delete(0);
       m_Chart1.Series(3).Delete(0);
       m_Chart1.Series(4).Delete(0);
    }

    // Add data to chart series:
    CString strLabel;
    strLabel.Format( _T("%d"), iCount );
    m_Chart1.Series(0).AddXY( (double)iCount, fVolume, strLabel, (unsigned long)iCount );
    
    m_Chart1.Series(1).AddXY( (double)iCount, dMax, strLabel, (unsigned long)iCount );
    m_Chart1.Series(2).AddXY( (double)iCount, dMin, strLabel, (unsigned long)iCount );
    m_Chart1.Series(3).AddXY( (double)iCount, m_fUpAdjustLim, strLabel, (unsigned long)iCount );
    m_Chart1.Series(4).AddXY( (double)iCount, m_fLowAdjustLim, strLabel, (unsigned long)iCount );

    // Link the navigator OCX to the chart to scroll pages:
    // Limit num data points per page page(or done in resource properties):
    m_PageNav1.SetChartLink(m_Chart1.GetChartLink());
    m_Chart1.GetPage().SetMaxPointsPerPage(lMaxVsiblePoints);

    // Check and enable running average function series display:
    m_Chart1.Series(5).CheckDataSource();

    // Scale the left axis to Spec limits + 10%
    m_Chart1.GetAxis().GetLeft().SetMinimum( dMin - dMargin );
    m_Chart1.GetAxis().GetLeft().SetMaximum( dMax + dMargin );

    // Scale the bottom axis to the latest 100 samples: 
    // Limit number of samples to display x axis:
    if( dTotCount > lMaxVsiblePoints )
    {
        //m_Chart1.GetAxis().GetBottom().SetMinMax( dTotCount - lMaxVsiblePoints, (dTotCount + lMaxVsiblePoints) );

        m_Chart1.GetAxis().GetBottom().SetMinimum( dTotCount - lMaxVsiblePoints);
        m_Chart1.GetAxis().GetBottom().SetMaximum( dTotCount );
      
        //m_Chart1.GetPage().SetCurrent( m_Chart1.GetPage().GetCount() ); // use page count to set
    }
    else
        m_Chart1.GetAxis().GetBottom().SetMinMax( 1, dTotCount );

    m_Chart1.Series(0).RefreshSeries();
    m_Chart1.RefreshData();

    //m_Chart1.Series(0).MaxVisibleValue(lMaxVsiblePoints); // crash?
    //m_Chart1.Series(0).VisibleCount() = lMaxVsiblePoints;
 }
OK now it works up until 1000 then stops updating, i re compiled with the refreshseries and refresh data function calls.
Cant I just display one page worth of data at a time. Forcing page change resets to one piece of data though.

Maybe its the order Im doing things, like maybe refresh series then set axis?
Looks like I dont understand this function: m_Chart1.GetAxis().GetBottom().SetMinMax()

Maybe this will work:

Code: Select all

        if( dTotCount > lMaxVsiblePoints )
        {
            m_Chart1.GetAxis().GetBottom().SetMinMax( (iCount - lMaxVsiblePoints), iCount );
        }
        else
        {
            // While series is filling:
            m_Chart1.GetAxis().GetBottom().SetMinMax( 1, iCount );
        }
Have to think about this...

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Limiting chart display to 100 of 1000 points in a series?

Post by Yeray » Wed Oct 05, 2016 8:10 am

Hello,

I see you are manually setting the bottom axis scale (SetMinimum&SetMaximum / SetMinMax) but you also use Pagination (SetMaxPointsPerPage).
The Pagination may give problems with the manually set axis scales. I can't say it for sure without looking at the whole application but in your case I think you shouldn't use Pagination.

If you still find problems with it, please try to arrange a simple example project we can run as-is to reproduce the problem here.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply