DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Date/Time scaling in script doesn't seem to work

I'm trying this code to alter my axis' scaling based on a previous event search. I'm getting an error when I try "oMy2DAxisSystem.XAxis.Scaling.Begin" = <Date> saying "Numeric value necessary". So it seems that I'm not actually able to change the property "oMy2DAxisSystem.XAxis.Scaling.Type"

 

Set o2DAxisXScaling = oMy2DAxisSystem.XAxis.Scaling
oMy2DAxisSystem.XAxis.Scaling.AutoScalingType = eAxisAutoScalingBeginEndManual
o2DAxisXScaling.Type = e2DxScalingDateTime
oMy2DAxisSystem.XAxis.Scaling.Begin = CDate(Data.Root.ChannelGroups(1).Channels("DateTime").Values(indexbeginning))
oMy2DAxisSystem.XAxis.Scaling.End = CDate(Data.Root.ChannelGroups(1).Channels("DateTime").Values(indexend))

0 Kudos
Message 1 of 5
(3,159 Views)

Mattrad, 

 

Going by the Help documentation, it looks like that function is expecting a numeric value which signifies a certain type of scaling. Take a look at the link below, and see if that clears things up. 

 

Property: Type for 2DAxisXScaling

 

Thanks, 

aprillest

0 Kudos
Message 2 of 5
(3,125 Views)

The error occurs on this line:

 

oMy2DAxisSystem.XAxis.Scaling.Begin = CDate(Data.Root.ChannelGroups(1).Channels("DateTime").Values(indexbeginning))

 

not when setting the type.

0 Kudos
Message 3 of 5
(3,104 Views)

I tried to replace e2DxScalingDateTime with 0, but It changes nothing. I'm pretty sure they are both 0.

0 Kudos
Message 4 of 5
(3,103 Views)

Hi mattrad,

 

You have to assign the corresponding DBL values to the X axis scaling that DIAdem displays as datetimes.  Luckily, there's an easy "DValues" property you can use instead of the usual "Values" property to request the DBL representation of a datetime channel's value.  I also added an explicit datetime format string, in case that's helpful:

 

indexbeginning = 25
indexend = 40
Set DateTimeChannel = Data.Root.ChannelGroups(1).Channels("DateTime")
Set oMy2DAxisSystem = Report.ActiveSheet.Objects("2DAxis1")
Set o2DAxisXScaling = oMy2DAxisSystem.XAxis.Scaling
oMy2DAxisSystem.XAxis.Scaling.AutoScalingType = eAxisAutoScalingBeginEndManual
o2DAxisXScaling.Type = e2DxScalingDateTime
oMy2DAxisSystem.XAxis.Numbers.Format = "#mm/dd/yyyy"
oMy2DAxisSystem.XAxis.Scaling.Begin = DateTimeChannel.DValues(indexbeginning)
oMy2DAxisSystem.XAxis.Scaling.End   = DateTimeChannel.DValues(indexend)
Call Report.Refresh()

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 5 of 5
(3,073 Views)