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
X axis scale
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.
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.
Re: X axis scale
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: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
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
http://www.steema.com