X axis scale

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Herman
Newbie
Newbie
Posts: 56
Joined: Tue Dec 07, 2004 5:00 am

X axis scale

Post by Herman » Fri Jan 14, 2005 3:21 am

I feed line series with 500 point.
So the tchart bottom axis is from 0 to 500.
now I want to change the x axis without affecting the series.
i want it to display 0 to 80 in x axis. How to do it?

I try to set the min max. But it only display 0 to 80 point, not all point.

Thank you

Herman

ungos
Newbie
Newbie
Posts: 12
Joined: Mon Oct 04, 2004 4:00 am
Location: Czech Republic
Contact:

Post by ungos » Fri Jan 14, 2005 6:30 am

I found no method to realize it without modifying data. But you can use following trick:

1. Add new helper serie (e.g. FastLine) with NO data to the chart
2. Set maximum and minimum of bottom axis to 0 and 80.
3. Assign TOP axis as horizontal axis of original serie
4. Hide TOP axis (Visible := False)

This procudure results in visual effect what you want, but you cannot use top axis further.

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Re: X axis scale

Post by Marjan » Fri Jan 14, 2005 7:57 am

9235196 wrote:now I want to change the x axis without affecting the series.
i want it to display 0 to 80 in x axis. How to do it?
Herman
You want to rescale axis values, but don't want to change series values ? If yes, then all you must do is use chart OnGetAxisLabel event, and rescale each axis label. Something like this might do the trick:

Code: Select all

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
  Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
var tmp: Double;
begin
  if Sender = Chart1.Axes.Bottom then
  begin
    // 1. retrieve axis "value" and translate it to double
    tmp := StrToFloat(LabelText);
    // 2. rescale axis label value.
    // In your case, scale factor is 80/500 = 0.16
    tmp := tmp * 0.16;
    // 3. transform label value back to string
    LabelText := FormatFloat(Sender.AxisValuesFormat,tmp);
  end;
end;
Marjan Slatinek,
http://www.steema.com

Post Reply