support3.jpg (13596 bytes)    Steema SUPPORT

 

Steema Products Order About us Download Support

Scrolling Chart axes

 

Problem:
How to use TeeChart4 to display a real time "scrolling" chart ?

Solution:
The whole trick of "scrolling" is changing axis minimum and maximum so that the axis will show only the "latest" values. Also, when showing only the latest data, points that are "too old" (i.e. are out of the range) can be deleted. The best event for changing axis min/max values and removing old points is Series OnAfterAdd event:
double range=DateTimeStep[dtOneMinute]; // show only last minute

void __fastcall TForm1::Series1AfterAdd(TChartSeries *Sender, 
int ValueIndex)
{
  Sender->GetHorizAxis->Automatic=false; // we'll do the work
  
   // max is the latest value
  Sender->GetHorizAxis->Maximum=Sender->XValues->MaxValue; 
  
  //min is max-range
  Sender->GetHorizAxis->Minimum=Sender->GetHorizAxis->Maximum-range;
  
  // we also want to delete points that fall out 
of range i.e. are less than minimum
  while ((Sender->Count()>0) 
    && (Sender->XValues->Value[0] < Sender->GetHorizAxis->Minimum))
 {
  Sender->Delete(0);
  }
}

disc.gif (8563 bytes)

disc.gif (8563 bytes)

Download Delphi source code Download CBuilder source code
Home Products Order About us Downloads Support
Copyright information. E-MAIL info@steema.com.   Privacy Policy
All other brands and product names are trademarks or registered trademarks of their respective owners.