PDA

View Full Version : Variable type change for XValues in charted data



AAhrenst
04-30-2015, 10:56 AM
Experts,

I am running into an issue when charting XY scattered data with the X-Scale being in a hh:mm format.
Most of the time it is working fine but then once in a while some dataset would consistently be formatted into string i.e. "hh:mm" only after passing the data to the XValues despite the input array being defined as double.
These XValue will also plot but the problem is that the time data may have a value greater than 1 (ie. not the same day) hence other data sets where the XYalues does not have this issue will not match the same time scale.
Example multiple data sets may have a time range from 24.0 to 24.999 (1 full day) while data sets that are converted to string will plot as "00:00" to "23:99".
In short, the code I am using is following:

Dim VarX() as double
Dim VarY() as double
Dim ChartName As String
Dim Title As String
Dim No As Integer
Call SetXYDate(VarX, VarY) 'byref passing of two arrays which will redim and input the data

Sheets("Sheet1").ChartObjects(ChartName).Activate
ActiveChart.SeriesCollection.NewSeries
No = ActiveChart.SeriesCollection.Count
Title = GetTitle("something")
ActiveChart.FullSeriesCollection(No).Name = Title
ActiveChart.FullSeriesCollection(No).XValues = VarX
ActiveChart.FullSeriesCollection(No).Values = VarY

The data may be plotted of different charts but the x-scale for all set to be identical through another rutine. Does it have anything to do with the chart set-up. All are defined as Time format h:mm;@
Regardless, I know the issue only occurs when data passed to XValues are converted to string as mentioned above.
What am I doing wrong?
Thanks for the support