ADO, Recordsets & DateTime

TeeChart for ActiveX, COM and ASP

ADO, Recordsets & DateTime

Postby tlb1971 » Thu Nov 09, 2017 8:49 pm

I have recently updated a version 5 application. It uses ASP pages and ADO. Here's a snippet of code:

Code: Select all
'DATE/TIME
AChart.Axis.Bottom.Increment = AChart.GetDateTimeStep(dtOneHour)
AChart.Axis.Bottom.Labels.DateTimeFormat = "hh:nn" '****version5 used AChart.Axis.Bottom.Labels.DateTimeFormat = "hh:mm"
      
AChart.AddSeries(scLine)
AChart.Series(0).Color = vbRed
AChart.Series(0).XValues.DateTime = True
AChart.Series(0).Datasource = Rs
AChart.Series(0).YValues.ValueSource="Value"
AChart.Series(0).LabelsSource="DateTime" '**** version5 used Chart.Series(0).XValues.ValueSource="DateTime"


I expect to have the DateTime on the X axis:

1. be divided into 1 hour segments via AChart.Axis.Bottom.Increment = AChart.GetDateTimeStep(dtOneHour)
2. display DateTime format of hours:minutes via AChart.Axis.Bottom.Labels.DateTimeFormat = "hh:nn"

But it does not display that way. Doesn't seem to be any formatting of the Y axis at all. Is there some order that is required? I feel like I've tried everything to no avail. I have the ASP source code as well as the results of the SQL query but the forum does not allow me to upload.
Attachments
Capture_Chart_DT.JPG
Capture_Chart_DT.JPG (110.24 KiB) Viewed 132 times
tlb1971
Newbie
Newbie
 
Posts: 6
Joined: Fri Oct 20, 2017 12:00 am

Re: ADO, Recordsets & DateTime

Postby Yeray » Fri Nov 10, 2017 8:37 am

Hello,

I see you are setting the "DateTime" field to the Series' LabelsSource:
Code: Select all
AChart.Series(0).LabelsSource="DateTime"


As you said, in v5 you used:
Code: Select all
AChart.Series(0).XValues.ValueSource="DateTime"


I'm not sure to understand why did you change this, but this seems to be the reason of the problem.
- Adding values to a series without specifying the X values, the X values array is populated with a succession of 0, 1, 2,... That's why there's the same horizontal distance between all the points in your result.
- By default, the axis Labels.Style is set to talAuto, and when the axis has a series with labels attached, these labels are used to draw the axis labels. The DateTimeFormat only is considered when displaying values in the axis, not when displaying the labels (strings).
Best Regards,

ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image ImagePlease read our Bug Fixing Policy
Yeray
Site Admin
Site Admin
 
Posts: 8193
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Re: ADO, Recordsets & DateTime

Postby tlb1971 » Mon Nov 20, 2017 4:33 pm

If I use AChart.Series(0).XValues.ValueSource="DateTime", my chart does not draw. The only way I get my chart to draw is using the AChart.Series(0).LabelsSource="DateTime" method. What am I missing?

I used it because that's what the ADOTeeChart.asp example used:

'Connect Series to Recordset
if RSt.RecordCount > 0 then
Chart.Series(0).Datasource = RSt
Chart.Series(0).LabelsSource="OrderNo"
Chart.Series(0).YValues.ValueSource="ItemTotal"
else
Chart.Series(0).Fillsamplevalues(10)
Chart.Header.Text(0)="ADO database returned no values - using random data"
end if


I could not find any examples using DateTime in the Y Axis. Are there any examples using DateTime as Y axis?

Finally, are you saying these functions are no longer supported even though they are in the help file:

AChart.Axis.Bottom.Automatic = False
AChart.Axis.Bottom.Increment = AChart.GetDateTimeStep(dtOneHour)
AChart.Axis.Bottom.Labels.DateTimeFormat = "hh:nn"


From the help file:
IAxisLabels.DateTimeFormat
IAxisLabels

property DateTimeFormat: WideString;

Type Library
TeeChartx

Description
Chart AxisLabels have a DateTimeFormat property. DateTimeFormat is a standard DateTime formatting string specifier. Chart Axis uses it to draw the axis labels.


What am I missing?
tlb1971
Newbie
Newbie
 
Posts: 6
Joined: Fri Oct 20, 2017 12:00 am

Re: ADO, Recordsets & DateTime

Postby Marc » Tue Nov 21, 2017 10:55 am

Hello,

Re.
1. be divided into 1 hour segments via AChart.Axis.Bottom.Increment = AChart.GetDateTimeStep(dtOneHour)
2. display DateTime format of hours:minutes via AChart.Axis.Bottom.Labels.DateTimeFormat = "hh:nn"


Yes. Those should work. If those lines are not working then there must be some other factor in the code impeding them.

This image is an example, simple VB demo (adapted from example demos shipped with TeeChart AX 2017):

datetime_example.png
datetime_example.png (117.22 KiB) Viewed 82 times


The example uses variably spaced x data at intervals of less than an hour. The asp code should work on this in exactly the same way. I've added the VB(6!) project to this post.

Re.
If I use AChart.Series(0).XValues.ValueSource="DateTime", my chart does not draw. The only way I get my chart to draw is using the AChart.Series(0).LabelsSource="DateTime" method. What am I missing?


"Datetime" is the name of the field, correct?
- If the "Datetime" field contains double values (datetime in double format) then it can be used with AChart.Series(0).XValues.ValueSource
- If the "Datetime" field contains strings then you can use it as the LabelsSource.

Regards,
Marc
Attachments
Multiline Axis Labels.zip
(3.85 KiB) Downloaded 5 times
Marc
Site Admin
Site Admin
 
Posts: 817
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona


Return to Activex

Who is online

Users browsing this forum: Google [Bot] and 4 guests