|
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);
}
}
|