X-Axis has extra dates

My X-Axis is formatted for dates. The data from my stringlist displays correctly however I have a 12/30/1899 date on the x-axis at the first data point. How do I remove this date?

Also .... to the left of my first point the chart shows other dates without data points AND to the right of my last data point the chart shows other dates with no data points. How do I fix this issue?

I use Rangeto & RangeFrom to display the data, but scrolling shows the extra dates. I am using candlsticks.

From your description, it would appear there was already series data with a null value inserted before you added the values with dates. Did you try to first clear the data points before adding the ones with defined dates?

I was able to clear the extra dates with the following commands
  AdvChartView1.Panes[0].Series[0].ClearPoints;
  AdvChartView1.Panes[0].Series[1].ClearPoints;
  AdvChartView1.Panes[0].Series[2].ClearPoints;

However, the 12/30/1899 date still displays at my first point. How do I remove this 1899 date?

I have retested this here but I cannot see this.

Test code applied on a default TAdvChartView:


var
  dt: TDateTime;
  i: Integer;
begin

  dt := Now;

  AdvChartView1.BeginUpdate;

  AdvChartView1.Panes[0].Series[0].XAxis.MinorUnitTimeFormat := 'dd/mm';
  AdvChartView1.Panes[0].Series[0].XAxis.MajorUnitTimeFormat := 'dd/mm';

  AdvChartView1.Panes[0].XAxis.UnitType := utDay;
  AdvChartView1.Panes[0].Series[0].ClearPoints;

  for i := 0 to 10 do
  begin
    AdvChartView1.Panes[0].Series[0].AddSinglePoint(random(10), dt);
    dt := dt + 1;
  end;
  AdvChartView1.EndUpdate;
end;

This shows the first date as today, i.e. July, 12

What are you doing different?

The documentation is very incomplete so I set many settings in the iDE. I am not starting with a default chart.

This is my code with your suggestions. The 12/30/1899 problem is still on the chart. I tried to attach a screenshot but your system will not allow me to do so.

Why do I get an undeclared identifier utDay?

procedure TFormChart.DisplayChart;
var High,Low,Open,Close : double;
    sDate               : string;
    i                   : integer;
begin
  AdvChartView1.BeginUpdate;
  AdvChartView1.Panes[0].Series[0].XAxis.MinorUnitTimeFormat:= 'dd/mm/yyyy';
  AdvChartView1.Panes[0].Series[0].XAxis.MajorUnitTimeFormat:= 'dd/mm/yyyy';
//AdvChartView1.Panes[0].XAxis.UnitType:= utDay;   //utDay is undeclared identifier
  AdvChartView1.Panes[0].Series[0].ClearPoints;
  AdvChartView1.PaneByID[0].Series[0].LegendText:=sSymbol;
  AdvChartView1.PaneByID[0].Series[1].LegendText:='TURNS';
  AdvChartView1.PaneByID[0].Series[0].ValueFormat:= '%.2f';
  AdvChartView1.EndUpdate;

  for i:=1 to (StringGridData.RowCount-1) do    //-offset) do    //skip first line 0
  begin
    sDate:= StringGridData.Cells[0,i];
    Open:= StrToFloat(StringGridData.Cells[2,i]);
    High:= StrToFloat(StringGridData.Cells[3,i]);
    Low:=  StrToFloat(StringGridData.Cells[4,i]);
    Close:=StrToFloat(StringGridData.Cells[5,i]);
    AdvChartView1.PaneByID[0].Series[0].AddMultiPoints(High,Low,Open,Close,sDate);
  end;

end;

Please add the unit AdvChart to your uses list. This unit has the definition for utDay.


utDay issue has been solved. The 12/30/1899 date remains.
My dates are oriented vertically but the 12/30/1899 date displays horizontally at my first data point.
This may be a clue.

Please isolate this issue and provide a sample source app with which we can reproduce your problem here, as we cannot see this problem here. Contact us by email and provide such sample source project and step by step instructions to allow to reproduce this.