Search code examples
delphiteechart

Hide minutes in TChart components


How can I hide time (hour, minutes and sec) in TChart component? Need only Date format.

Set

Chart1.BottomAxis.DateTimeFormat := GetLocaleShortDateFormat(); {MMM/yy/dd}, 

but time is present in chart


Solution

  • An example how to use TeeChart.

    Add a TChart component and a TButton on a form, include unit Series and add this code on the button OnClick event:

    procedure TForm1.Button1Click(Sender: TObject);
    var
      S1: TLineSeries;
      i,j: integer;
    begin
      Chart1.View3D := false;
      Chart1.SeriesList.Clear;
      S1 := TLineSeries.Create(Self);
      S1.XValues.DateTime := True;  
      Chart1.BottomAxis.DateTimeFormat := 'MMM/YY/DD';  //Works with 'MMM/yy/dd' also
      Chart1.AddSeries(S1);
      for i := 0 to 10 do
        for j := 0 TO 23 do
        S1.AddXY(Trunc(Now) + i + j/24.0, Random(100)/10.0 + i*10.0);
    end;
    

    And this is the result: enter image description here

    I could not reproduce the behaviour in the question, with different settings of the DateTimeFormat.