Page 1 of 1

X value 0 when it shouldn't

Posted: Sun Apr 16, 2006 6:59 pm
by 9337074
I used the code

procedure TMultiDBChart.DoClickSeries(Sender: TCustomChart; Series: TChartSeries; ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; x, y: Integer);
begin
strX := Series.XValueToText(Series.XValues[ValueIndex]));
strY := Series.YValueToText(Series.YValues[ValueIndex]));
end;

and set Chart1.Series1.XValues.DateTime := True.

The Y value is being assigned but the X value keeps coming up the Date 12/31/1899. Can you suggest something else I might be doing wrong? When I tried just getting the double value using the code dbValue := Series.XValue[ValueIndex], I get 0.

Posted: Tue Apr 18, 2006 10:00 am
by narcis
Hi McMClark,

This is most likely because of the way you are populating your series. See an excerpt from TDateTime type definition:

The integral part of a Delphi TDateTime value is the number of days that have passed since 12/30/1899. The fractional part of the TDateTime value is fraction of a 24 hour day that has elapsed.

Following are some examples of TDateTime values and their corresponding dates and times:

0 12/30/1899 12:00 am
2.75 1/1/1900 6:00 pm
-1.25 12/29/1899 6:00 am
35065 1/1/1996 12:00 am


It may help you populating your series obtaining the TDateTime values using Delphi's EncodeDate or EncodeDateTime functions.