Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MsChart - XY scatter - showing time interval problem?

Status
Not open for further replies.

tb2007

Programmer
Apr 2, 2005
33
YU
I have GPS device which send me speed data each second. I want to show data on MSChart, XY scatter.
User input is FirstDate and I calculate SecondDate = First date + 24 Hours

FirstDate= 18.07.2007 15:00:00
SecondDate= 19.07.2007 14:59:59
Than I convert 24 hours = 86400 sec.

I create array:
Redim arrvalues(1 to 86399, 1 to 2)
For i = 1 to 86399
arrValues(i, 1) = i / 3600 ‘ to find hour
arrValues(i, 2) = Speed(i)
Next i

Than I want to show chart:

With MSChart1
.ChartData = arrValues

.chartType = VtChChartType2dXY

.Plot.Axis(VtChAxisIdY).AxisScale.Type = VtChScaleTypeLinear
.Plot.Axis(VtChAxisIdX).AxisScale.Type = VtChScaleTypeLinear

.Plot.Axis(VtChAxisIdX).ValueScale.Auto = False
.Plot.UniformAxis = False
.Plot.Axis(VtChAxisIdX).AxisGrid.MajorPen.Style = 0
.Plot.Axis(VtChAxisIdX).AxisGrid.MinorPen.Style = 0
.Plot.Axis(VtChAxisIdX).ValueScale.Maximum = 24 ‘hours
.Plot.Axis(VtChAxisIdX).ValueScale.Minimum = 0
.Plot.Axis(VtChAxisIdX).ValueScale.MajorDivision = 24
.Plot.Axis(VtChAxisIdX).ValueScale.MinorDivision = 0


.Plot.Axis(VtChAxisIdY).ValueScale.Auto = False
.Plot.Axis(VtChAxisIdY).AxisGrid.MajorPen.Style = 0
.Plot.Axis(VtChAxisIdY).AxisGrid.MinorPen.Style = 0
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 100
.Plot.Axis(VtChAxisIdY).ValueScale.Minimum = 0
.Plot.Axis(VtChAxisIdY).ValueScale.MajorDivision = 10
.Plot.Axis(VtChAxisIdY).ValueScale.MinorDivision = 2

End With

What is the problem?

If I start from 18.07.2007 00:00:00 everything is fine, my x-axis goes from 0-24, I watch only one day.

But, if I start from 18.07.2007 15:00:00 I want my x-axis labels to be:

15 16 17 18 19 20 21 22 23 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

So I can see data from yesterday at 15 PM to today at 15 PM, actually I watch 24 hours period in 2 days.

Can anybody help me with this?
 
As I understand XY scatter first element of arrvalues(i,1) is X value and it is OK. But the problem is that this arrvalues(i,1) also determines labels for x-axis.
Is it possible to use arrvalues(i,1) for x-axis values, and somehow separately create labels for x-axis?
As far as I know it is not possible. How can I solve this?
 
I ran into the same problem. I have more of a work around than a solution.

Instead of using the x-axis for Date/Time, I used it for time elapsed since the reading ( now() - recordedTime ). Therefore, a reading taken exactly a day ago would have an x-value of 1 and a reading taken half a day ago would have an x-value of .5.

I then take the opposite of the result so the plot runs chronologically from left to right.

Lastly, I use a multiplier to see the results in units I want (24 for hours, 1440 for Minutes (24*60)).

Therefore, instead of plotting the date/time, I actually plot the time elapsed since reading.
 




Hi,

"Than I convert 24 hours = 86400 sec"

THEREFORE, your x-axis is NOT date/Time. Date/Time values are in units of DAYS.

What you want is the x-axis values to be
Code:
    '7.18.2007 will not fly!!!
    FirstDate = #7/18/2007 3:00:00 PM#
    SecondDate = #7/19/2007 2:59:59 PM#
    For I = 1 To 86399
        arrDates(I) = FirstDate + I / 24 / 3600 '
        arrSpeed(I) = Speed(i)
    Next I
.....


Skip,
[sub]
[glasses] When a wee mystic is on the loose..
It's a Small Medium at Large! [tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top