-1

I am using Zedgraph and for x-axis, they require us to convert to OADate. I am plotting live stock chart and I want to show the last 60sec.

So I use zedGraphControl1.GraphPane.XAxis.Scale.Max and zedGraphControl1.GraphPane.XAxis.Scale.Min. For the Max value, I will set it to the latest time while for the Min value I plan to set to the latest time minus 60 secs (variable). I will store the 60sec in the type timespan. But the problem is that timespan does not have the function toOADate.

Scott
  • 21,211
  • 8
  • 65
  • 72
user3398315
  • 331
  • 6
  • 17

1 Answers1

0

Implement your own method!

all you need to know is 1 day = 24 hours 1 hour = 60 minutes 1 minute = 60 seconds 1 second = 1000 milliseconds

Example: let's say i have time t= 456722622 msec

struct TimeDetailed
    {
    public int millisec;
    public int seconds;
    public int minutes;
        public int hours;
        public int days;
    };

static TimeDetailed tConverted;
int t = 456722622;

public void function(int a)
{
int d,h,m,s;
d=h=m=s=0;

while(a >= 86400000) // milliseconds per day
{
a -= 86400000;
d++;
}
while(a >= 3600000) // milliseconds per hour
{
a -= 3600000;
h++;
}
while(a >= 60000) // milliseconds per minute
{
a -= 60000;
m++;
}
while(a >= 1000) // milliseconds per second
{
a -= 1000;
s++;
}

tConverted.days = d;
tConverted.hours = h;
tConverted.minutes = m;
tConverted.seconds = s;
tConverted.millisec = a;

}



  function(t);

the output is:

tConverted.days = 5
tConverted.hours = 6
tConverted.minutes = 52
tConverted.seconds = 2
tConverted.millisec = 622

Though I didn't test this code but you can similarly make one

chouaib
  • 2,763
  • 5
  • 20
  • 35