Page 1 of 1
TeeChart 8.05: Fixed pixel interval between major ticks
Posted: Mon Apr 18, 2011 9:46 am
by 10054198
Hello,
is it possible to have a fixed pixel interval (say 150px) between horizontal major ticks? If the user resizes the form (and the chart within), labels are rearranged and sometimes look odd.
My goal is to place a label at each major tick every 150 pixels, so resizing the chart does not make the labels jump.
Regards,
Guido
Re: TeeChart 8.05: Fixed pixel interval between major ticks
Posted: Mon Apr 18, 2011 2:35 pm
by 10050769
Hello Guido,
I have made a simple example for you using OnGetAxesLabels:
Code: Select all
var
Form1: TForm1;
AntValue:Integer;
implementation
{$R *.dfm}
uses Series;
procedure TForm1.FormCreate(Sender: TObject);
var Series1:TLineSeries;
i:Integer;
begin
AntValue:=0;
Series1 := TLineSeries.Create(self);
Chart1.AddSeries(Series1);
Chart1.Align:=alClient;
For i:=0 to 10 do
Series1.AddXY(i,Random(100),IntToStr(i));
end;
procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
var Value:Integer;
begin
If ValueIndex<>-1 then
begin
If Sender = Chart1.Axes.Bottom then
begin
Value := Chart1.Axes.Bottom.CalcXPosValue(ValueIndex);
If (Value-AntValue>100) and (Value-AntValue<=150) then
LabelText:= 'XValue'+IntToStr(Value);
AntValue:=Value;
end;
end;
end;
In code you can see values are in determinate range that you can adjust as you want. Please could you tell us if previous code behave as you expected?
I hope will helps.
Thanks,