Page 1 of 1

Change the increment step on X Date Axis

Posted: Sat Nov 05, 2022 9:07 am
by 16590249
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

Re: Change the increment step on X Date Axis

Posted: Mon Nov 07, 2022 3:30 pm
by yeray
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 5202 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;