.TimeString with day count > 1 month without day rollover?

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
plotter
Posts: 41
Joined: Thu Apr 06, 2017 2:29 am

.TimeString with day count > 1 month without day rollover?

Post by plotter » Thu Jun 08, 2017 11:13 pm

Hello Arction Support:
I am finally back into plotting :D
I need to present the elapsed time range between 2 cursors, I currently am using this to present the time range.

Code: Select all

DeltaX2X1.Text = _chart.ViewXY.XAxes[0].TimeString(cursorX2.ValueAtXAxis - cursorX1.ValueAtXAxis, "dd:HH:mm:ss.ffff");
It fails to present the proper day count when range is more than 1 month, and when I add the Month format specifier, it always calculates the day count as 31 (because a 1 month range assumes January's 31 day count? i presume)

How can I present an accurate elapsed time range that can span several months?
I would love to be able to use something like "ddd:HH:mm:ss.ffff"...
(to display 1 year and 4 days would be 369:12:21:14.2034)

Thanks,
Heather

plotter
Posts: 41
Joined: Thu Apr 06, 2017 2:29 am

Re: .TimeString with day count > 1 month without day rollove

Post by plotter » Thu Jun 08, 2017 11:34 pm

I am currently solving it with:

$"{Math.Floor((cursorX2.ValueAtXAxis - cursorX1.ValueAtXAxis) / 86400)} " + _chart.ViewXY.XAxes[0].TimeString(cursorX2.ValueAtXAxis - cursorX1.ValueAtXAxis, "HH:mm:ss.ffff");

I guess I was really wondering if the TimeString has the ability to format this directly ?

Thanks

ArctionKestutis
Posts: 552
Joined: Mon Mar 14, 2016 9:22 am

Re: .TimeString with day count > 1 month without day rollove

Post by ArctionKestutis » Fri Jun 09, 2017 11:37 am

Hello Heather,

You could set Axis type with

Code: Select all

            xAxis.ValueType = AxisValueType.DateTime;
Now all the values on the xAxis assumed to be in seconds. And offset of time is controlled by DateOrigin properties, e.g.

Code: Select all

            xAxis.DateOriginYear = 2011;
            xAxis.DateOriginMonth = 1;
            xAxis.DateOriginDay = 1;
The dates follow real calendar (whatever month has 28, 30 or 31 days).

If you want to convert DateTime values to axis values, use

Code: Select all

            double xValue = xAxis.DateTimeToAxisValue(DateTime dateTime);
If you want opposite conversion use

Code: Select all

           DateTime dateTime = xAxis.AxisValueToDateTime(double axisValue);
Hope this helps.
All the best

Post Reply