TeeChart 8.05: Fixed pixel interval between major ticks

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
OCS
Newbie
Newbie
Posts: 13
Joined: Wed Sep 02, 2009 12:00 am

TeeChart 8.05: Fixed pixel interval between major ticks

Post by OCS » Mon Apr 18, 2011 9:46 am

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

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: TeeChart 8.05: Fixed pixel interval between major ticks

Post by Sandra » Mon Apr 18, 2011 2:35 pm

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply