X-Axis Time to microseconds

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
GuyPardoe
Posts: 2
Joined: Fri Jul 15, 2022 8:12 pm

X-Axis Time to microseconds

Post by GuyPardoe » Thu Aug 31, 2023 5:43 pm

In LightningChartUltimate (WPF), when setting the X-Axis to Time... are X-Axis labels able to show time in milliseconds or even microseconds?

In a project using LightningChartUltimate v8.4.1, I have a requirement to import and chart some data coming from CSV files. The X-Axis is DateTime data and includes resolution to microseconds.

The problem I'm having is no matter what I do, I can't get the chart's X-Axis to properly display any sub-second data. Everything smaller than a second displays as zeros. See image.

Looking at doc and other forum entries that are somewhat related, it seems like I should be able to display label values down to microseconds.

Here's the general approach I am taking:

Code: Select all

xAxis.AutoFormatLabels = false;
xAxis.ValueType = AxisValueType.DateTime;
//xAxis.ValueType = AxisValueType.Time;		//I tried Time and DateTime; no noticeable change
xAxis.LabelsTimeFormat = "HH:mm:ss.ffffff";
I read the first data row to get the earliest time that will be in the chart. (I created some console output as a sanity check and to pass along info here.)

Before SetDateOrigin is reset...

actualDateTime: 07:02:52.077011
actualDateTimeToAxisValue 425718172.077011
actualAxisValueToDateTime: 07:02:52.077011
XAxes[0].ValueType: DateTime
XAxes[0].LabelsTimeFormat: HH:mm:ss.ffffff
XAxes[0].DateOriginYear: 2010
XAxes[0].DateOriginMonth: 1
XAxes[0].DateOriginDay: 1
XAxes[0].DateTimeRange: 2010-01-01T00:00:00.0000000-05:00;2010-01-01T00:00:10.0000000-05:00

Then I set DateOrigin to the first/lowest value for the chart:

Code: Select all

_chart.ViewXY.XAxes[0].SetDateOrigin(firstDateTime);
After SetDateOrigin has been set...

actualDateTime: 07:02:52.077011
actualDateTimeToAxisValue 425718172.077011
actualAxisValueToDateTime: 07:02:52.077011
XAxes[0].ValueType: DateTime
XAxes[0].LabelsTimeFormat: HH:mm:ss.ffffff
XAxes[0].DateOriginYear: 2023
XAxes[0].DateOriginMonth: 6
XAxes[0].DateOriginDay: 29
XAxes[0].DateTimeRange: 2023-06-29T00:00:00.0000000-04:00;2023-06-29T00:00:10.0000000-04:00

Then I roll through the CSV (10 seconds of data), and add it to the chart. Actually there are a handful of yAxes in the chart (PointLineSeries), but that is not relevant to this issue.

Again, the X-Axis displays all zeros for sub-second values, even though I can see in the debugger that the data points have X values with resolution to microseconds. The rest of the chart looks as expected.

What am I missing?

As a secondary question... what is the difference between AxisValueType.DateTime and AxisValueType.Time, and when would I choose one over the other?

Thanks,
Attachments
MicrosecondsIssue.jpg
MicrosecondsIssue.jpg (25.2 KiB) Viewed 9441 times

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

Re: X-Axis Time to microseconds

Post by ArctionKestutis » Fri Sep 01, 2023 1:28 pm

I believe nothing is wrong with labels. XAxis or x-value precision is not the same as Major tick value.
As far as I could see in your picture, you have Major tick every 1 sec. Due to prevention of overlap for axis labels, you see labels every 2 second. So there is no point to show micro-seconds precision at this points. If you zoom-in, then you should see major ticks with decimal values.

If you want to control where major ticks and grid appear, then you should use Axis’ division properties. See User Manual chapter 6.2.6 Divisions.

If you need even more flexibility use CustomTicks (chapter 6.2.8).

If issue still not resolved, you can try sending your complete project to Support email address.

Hope this helps.
All the best,
Kestutis

GuyPardoe
Posts: 2
Joined: Fri Jul 15, 2022 8:12 pm

Re: X-Axis Time to microseconds

Post by GuyPardoe » Fri Sep 01, 2023 8:12 pm

Kestutis,
Thanks for the information. It is as you said. Zooming in gets to the smaller decimal values showing up.

By the way, I'm still confused about the difference between AxisValueType.DateTime and AxisValueType.Time. When would I choose one over the other?

Thanks,

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

Re: X-Axis Time to microseconds

Post by ArctionKestutis » Mon Sep 04, 2023 7:48 am

On the range less than a day, AxisValueType.DateTime and AxisValueType.Time are not different. That is, if automatic label formatting allowed (AutoFormatLabels property), both options with show HH:mm:ss formatting. However, difference become obvious then Axis range is days or longer. AxisValueType.Time is not intended to show date and, therefore, label will look bad.

The quickest way to test any property, is to open our Demo (Interactive Examples App) and select suitable/simple example. The open Properties Editor and change properties you interested in.

Hope this helps.

Post Reply