Change the increment step on X Date Axis

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
vasilis
Newbie
Newbie
Posts: 2
Joined: Mon Dec 28, 2020 12:00 am

Change the increment step on X Date Axis

Post by vasilis » Sat Nov 05, 2022 9:07 am

Hi,
I would like to change the increment step on X Axis
that has every single day from 2019 year.
Hence, the X axis has a Date Format & I would like
to have an one month step for each Bar on graph.
Thank you
Vasilis

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Change the increment step on X Date Axis

Post by Yeray » Mon Nov 07, 2022 3:30 pm

Hello Vasilis,

You could set the Increment to DateTimeStep[dtOneMonth]. Ie:
Project3_2022-11-07_16-29-35.png
Project3_2022-11-07_16-29-35.png (22.28 KiB) Viewed 5078 times

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
    d: TDateTime;
begin
  Chart1.View3D:=False;
  Chart1.Gradient.Visible:=False;
  Chart1.Color:=clWhite;
  Chart1.Walls.Back.Gradient.Visible:=False;
  Chart1.Walls.Back.Color:=clWhite;
  Chart1.Legend.Hide;

  with TBarSeries(Chart1.AddSeries(TBarSeries)) do
  begin
    Marks.Hide;
    XValues.DateTime:=True;

    d:=EncodeDate(2019, 1, 1);
    AddXY(d, 100+random*10);
    for i:=1 to 30*6 do
    begin
      AddXY(d, YValue[i-1]+random*10-5);
      d:=d+1;
    end;
  end;

  Chart1.Axes.Bottom.Increment:=DateTimeStep[dtOneMonth];
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply