Increment of x Axis

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Increment of x Axis

Post by moelski » Mon Jul 16, 2007 10:04 am

Hi !

We have a logging software which plots every second one point to the chart / to the series (we use fastline Series).
Everytime a new point is added to a series the chart is repainted. So the increment of the x axis is only one point.
Is there a way to increment the x axis with a custom percentage?

A simple example:
Lets say you have one FastLine Series with 100 datapoints. The X axis shows 0 at the left and 100 at the right. Now you add an addition datapoint to the series. The x axis only increments to 101 on the right side.
But it would be much more efficient if the x axis would increment to 120 instead of 101. If you do so the next 19 datapoints don´t need a complete repaint of the chart. You simple enhance the actual one.
If you have 120 datapoints you enhance the x axis again with 20%.

Is this possible with TeeChart?

Pep
Site Admin
Site Admin
Posts: 3299
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Jul 16, 2007 10:10 am

Hi Dominik,

this can be accomplished using the SetMinMax method, it will allow you to specify the min and max for the bottom axis after the point has been added.

moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Post by moelski » Mon Jul 16, 2007 10:17 am

Hi Pep,

thx !

But there is no automatism which will do this?

moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Post by moelski » Mon Jul 16, 2007 12:07 pm

Hi Pep,

I write some code in FormCreate:

Code: Select all

  Series1.GetHorizAxis.Automatic := False;
  Series1.GetHorizAxis.SetMinMax(0, 10);
Then I add datapoints with a timer:

Code: Select all

procedure TForm1.Timer1Timer(Sender: TObject);
var NewMax : Double;
begin
  inc(Count);

  if Count > Series1.GetHorizAxis.Maximum then begin
    NewMax := round(Chart1.Series[0].Count * 1.2);
    Series1.GetHorizAxis.SetMinMax(0, NewMax);
  end;

  Chart1.Series[0].AddXY(Count, Sin(Count / 30));
  Chart1.Series[1].AddXY(Count, Cos(Count / 30));
end;
The x Axis increments great :D

But I don´t understand why the chart is repainted every time a new datapoint is added. In the OnAfterDraw Event I put in some Debugcode and it is fired every time you add a datapoint.

Wouldn´t it be much faster if the chart will only be redrawn if the axis have to be recalculated?

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

Post by Yeray » Fri Jul 27, 2007 7:58 am

Hi Dominik,

The most usual wish is to show each new point added to a series. I don't understand what exactly you would like to achieve.

You would like to control OnAfterDraw calls? You can control chart repaints by:

Code: Select all

Chart1.AutoRepaint := False;
If what you want is to add some values in one time you can use the AddArray method:

Code: Select all

Series1.AddArray([2,3,5,7,1]);
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