Autoscale problem for TChart

Autoscale problem for TChart

Post by Jgen Bernt » Thu, 08 Feb 2007 20:39:07


Hi All

I have some big real-time data lineseries, where only parts of the series
are shown on the x-axis (e.g. the last minute). The points shown changes
every second.

When autoscale on the y-axis is true, the axis is scaled to the whole series
and not the part that is shown on the x-axis.

Is there an easy method for this or do I have to search through the series
for min and max?

Any help will be greatly appriciated, Jgen
 
 
 

Autoscale problem for TChart

Post by Narc Calve » Fri, 09 Feb 2007 00:54:10


Hi Jgen,

Do you need to keep non-visible points on your chart? If not you could
remove them as shown in the real-time charting article below.

http://www.yqcomputer.com/


--
Best Regards,

Narcis Calvet
Steema Support Central
http://www.yqcomputer.com/

"Important note: If you are a TeeChart registered customer, please post your
support questions at Steema's Support monitored Forums for customers:
http://www.yqcomputer.com/ for a prompter reply."

 
 
 

Autoscale problem for TChart

Post by Jgen Bernt » Fri, 09 Feb 2007 16:02:06

Hi Narc

I need to keep the points as the user can change between showing the last 1
minute, 5 minutes, 10,.... 120 minutes!

Regards
 
 
 

Autoscale problem for TChart

Post by Narc Calve » Sat, 10 Feb 2007 23:08:10

Hi Jgen,

Then you should use something like AdjustAxisScale method shown here:

procedure TForm1.FormCreate(Sender: TObject);
begin
InitializeChart();
end;

procedure TForm1.InitializeChart();
begin
Series1.FillSampleValues(200);
Chart1.MaxPointsPerPage:=50;
Chart1.Draw;
AdjustAxisScale(Series1, Series1.FirstDisplayedIndex,
Series1.VisibleCount,true);
end;

procedure TForm1.FindMinMax(v: TChartValueList; firstPoint, lastPoint:
Integer;
out min, max: Double);
var t : Integer;
begin
min := v.Items[firstPoint];
max := v.Items[firstPoint];

for t:=firstPoint+1 to lastPoint do
if v.Value[t] < min then min := v.Items[t]
else if v.Value[t] > max then max := v.Value[t];
end;

procedure TForm1.AdjustAxisScale(s: TChartSeries; firstPoint,
lastPoint: Integer; vertical: Boolean);
var max, min : double;
begin
FindMinMax(s.YValues,firstPoint,lastPoint,min, max);

if vertical then
s.GetVertAxis.SetMinMax(min,max)
else
s.GetHorizAxis.SetMinMax(min,max);

Chart1.Repaint;
end;

--
Best Regards,

Narcis Calvet
Steema Support Central
http://www.yqcomputer.com/

"Important note: If you are a TeeChart registered customer, please post your
support questions at Steema's Support monitored Forums for customers:
http://www.yqcomputer.com/ for a prompter reply."