Page 1 of 1

Increment of x Axis

Posted: Mon Jul 16, 2007 10:04 am
by 9349911
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?

Posted: Mon Jul 16, 2007 10:10 am
by Pep
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.

Posted: Mon Jul 16, 2007 10:17 am
by 9349911
Hi Pep,

thx !

But there is no automatism which will do this?

Posted: Mon Jul 16, 2007 12:07 pm
by 9349911
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?

Posted: Fri Jul 27, 2007 7:58 am
by yeray
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]);