Diagram with microseconds resolution

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
FT_GIAG
Newbie
Newbie
Posts: 12
Joined: Fri Aug 05, 2011 12:00 am

Diagram with microseconds resolution

Post by FT_GIAG » Tue Jan 10, 2012 5:10 pm

Hi

We have some customers who have some data with a resolution of one microsecond, and we d'like to create diagrams for them.
But there, the problems started: When we use the Series.Add(DateTime, double) method, the microseconds are rounded to the next millisecond. There would be the workaround to make my own ToOADate() method, which I did, only to find two new problems. The first one is that if I have steps of exactly one microsecond, the spaces between the points are not equally distributed. The second problem is the labels: I explicitly set them to display microseconds ("ffffff"), but it still only prints milliseconds, everything smaller is always zero.
I made a small sample, so you can reproduce these issues easily. (I used the TeeChart version 4.1.2012.01032, .Net 3.5).
In addition I added some screenshots...

Thanks for fixing these issues.

Florian
Attachments
rounded.png
Comparison between custom and standard ToOADate() method
rounded.png (56.22 KiB) Viewed 20177 times
uneqallyDistributed.png
unequally distributed space
uneqallyDistributed.png (47.06 KiB) Viewed 20158 times
Microseconds.zip
Sample application
(39.5 KiB) Downloaded 728 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Diagram with microseconds resolution

Post by Sandra » Thu Jan 12, 2012 10:30 am

Hello FT_GIAG,

We are investigating your problem and we try to answer you asap.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Diagram with microseconds resolution

Post by Sandra » Thu Jan 12, 2012 3:29 pm

Hello FT_GIAG,

I recommend that take a look in thread. If it doesn't help you, please let me know.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

FT_GIAG
Newbie
Newbie
Posts: 12
Joined: Fri Aug 05, 2011 12:00 am

Re: Diagram with microseconds resolution

Post by FT_GIAG » Thu Jan 12, 2012 5:07 pm

Hello Sandra

I looked at this thread. Unfortunately, I don't see much resemblance. I did as in demo All Features\Welcome !\Axes\Labels\Showing milliseconds instructed (I even used it as base for my sample-application).
I believe the problem for not displaying the microseconds at the bottom axis to be within the DateTime.FromOADate() method. Some indication, that this method rounds to the nearest millisecond can be found at http://social.msdn.microsoft.com/Forums ... 0a07c7a571. To verify that, I adapted the sample and got the expected results: everything smaller than one ms is ignored by this method...

Code: Select all

private static readonly long _OAStartTicks = DateTime.FromOADate(0).Ticks;

public Form1()
{
	InitializeComponent();
	ConvertOADate(40906.75); // both methods create the same Tick-Value
	ConvertOADate(40906.75 + 10.0 / TimeSpan.TicksPerDay); // Add 1 us --> they don't agree anymore
	ConvertOADate(40906.75 + 100.0 / TimeSpan.TicksPerDay); // Add 10 us --> they don't agree anymore
	ConvertOADate(40906.75 + 1000.0 / TimeSpan.TicksPerDay); // Add 100 us --> they don't agree anymore
	ConvertOADate(40906.75 + 10000.0 / TimeSpan.TicksPerDay); // Add 1 ms --> it's the same again
}

private void ConvertOADate(double value)
{
	DateTime dt = DateTime.FromOADate(value);
	DateTime dt2 = new DateTime(_OAStartTicks + (long)Math.Round(value * TimeSpan.TicksPerDay));
	if (dt.Ticks != dt2.Ticks)
		MessageBox.Show("DateTime values are not equal");
	else
		MessageBox.Show("DateTime values are equal");
}
Regards
Florian
Last edited by FT_GIAG on Thu Jan 19, 2012 4:35 pm, edited 1 time in total.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Diagram with microseconds resolution

Post by Sandra » Mon Jan 16, 2012 1:10 pm

Hello Florian

I have checked it and I have get same result as you. I understand that it isn't a problem of TeeChart,so, it occurs because DateTime precision is a precision of a double and microseconds need a precision of a long. Thanks for information, it will be helpful for other clients.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

FT_GIAG
Newbie
Newbie
Posts: 12
Joined: Fri Aug 05, 2011 12:00 am

Re: Diagram with microseconds resolution

Post by FT_GIAG » Mon Jan 16, 2012 5:08 pm

Hello Sandra

It's not completely true. The .Net DateTime type has a precision of 100 ns, which is just about enough for my purposes. As far as I can tell, the problem lies within the OADate and mainly the default conversion from DateTime to OADate and vice versa.

Unfortunately, none of this information brings me any closer to a solution to my problems...

Regards
Florian

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Diagram with microseconds resolution

Post by Sandra » Wed Jan 18, 2012 12:56 pm

Hello FT_GIAG,

Sorry, you are right, I generalized too quickly and the problem is that as you said method OADate() round nearest millisecond. I have found more information about it and I suggest you take a look here, concretely in the "The "fffffff" Custom Format Specifier", where explain that he precision of date and time values depends on the resolution of the system clock and it can be related with your problem, too. If I find more information about it , I inform you.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

FT_GIAG
Newbie
Newbie
Posts: 12
Joined: Fri Aug 05, 2011 12:00 am

Re: Diagram with microseconds resolution

Post by FT_GIAG » Thu Jan 19, 2012 2:47 pm

Hello Sandra

I don't think that it has anything to do with that, beaus the "ffffff" custom format specifier in itself works just fine.

Code: Select all

var formattedDateTime = string.Format("{0:dd.MM.yyyy HH:mm:ss.ffffff}", new DateTime(799998999912354811L));
With this you get a result something like 05.02.2536 18:26:31.235481 which is accurate to one ms...

Have you any more information about my other question? Are you doing anything to support not only OADate but ticks for Dates? Or is there already anything and I'm just not seeing it? It would be great if you could do this, because we really need it!

Thanks
Florian

FT_GIAG
Newbie
Newbie
Posts: 12
Joined: Fri Aug 05, 2011 12:00 am

Re: Diagram with microseconds resolution

Post by FT_GIAG » Tue Jan 24, 2012 12:16 pm

Hello Sandra

Do you have any new information about my requests?

Regards
Florian

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Diagram with microseconds resolution

Post by Sandra » Wed Jan 25, 2012 10:03 am

Hello Florian,

Sorry for the delay. I think you can try use Custom labels as do in next simple example:

Code: Select all

        private void InitializeChart()
        {
            Steema.TeeChart.Styles.Line line1 = new Line(tChart2.Chart);
            line1.FillSampleValues(5);
            tChart2.Axes.Bottom.Labels.Items.Clear();
            long value1 =799998999912354811L; 
            for (int i = 0; i < line1.Count; i++)
            {
                var formattedDateTime = string.Format("{0:dd.MM.yyyy\nHH:mm:ss.ffffff}", new DateTime(value1));
                value1 = value1 + 100000000000000000L;
                tChart2.Axes.Bottom.Labels.Items.Add(line1.XValues[i], formattedDateTime);
             
            }
          
            tChart2.GetAxisLabel += new GetAxisLabelEventHandler(tChart2_GetAxisLabel);
        }
Can you tell us if previous code help you to find a good solution about your problem with representation of microseconds?
The first one is that if I have steps of exactly one microsecond, the spaces between the points are not equally distributed.
Sorry, I forgot answer this. We will work with it and we inform you asap.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

FT_GIAG
Newbie
Newbie
Posts: 12
Joined: Fri Aug 05, 2011 12:00 am

Re: Diagram with microseconds resolution

Post by FT_GIAG » Wed Jan 25, 2012 11:28 am

Hello Sandra

I'm sorry, but this isn't a viable way for us. True, the labels show the microseconds, but we would have to do the "positioning" of the labels ourselves. Otherwise, we get something like this.

Regards
Florian
Attachments
labels.png
labels.png (10.06 KiB) Viewed 20066 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Diagram with microseconds resolution

Post by Sandra » Wed Jan 25, 2012 11:50 am

Hello Florian,

I recomend you take a look in this thread, where is tried to give a solution of overlap labels,when you use custom labels.

I hope will helps.

Thank,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

FT_GIAG
Newbie
Newbie
Posts: 12
Joined: Fri Aug 05, 2011 12:00 am

Re: Diagram with microseconds resolution

Post by FT_GIAG » Wed Jan 25, 2012 3:44 pm

Did you mean this thread?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Diagram with microseconds resolution

Post by Sandra » Wed Jan 25, 2012 4:01 pm

Hello Florian,

Yes, sorry seems I don't add the correct URL. I have modified the previous post.

Thanks for the information.
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

FT_GIAG
Newbie
Newbie
Posts: 12
Joined: Fri Aug 05, 2011 12:00 am

Re: Diagram with microseconds resolution

Post by FT_GIAG » Thu Jan 26, 2012 9:51 am

Hi Sandra

Yes, we could do something like that, but we probably would end up implementing the whole "positioning" (whether to show or not etc.) logic all over... On your part, it probably is "just" substituting the DateTime.ToOADate() method with a custom one... (I now, there is no such thing as just in programming :wink:)
The other thing is: without the actual resolution of one microsecond, we will not use this feature. And since you have not given me any suggestion how to work around that, I guess (hope) this will be included in the next release! So I am prepared to wait for that.

Thanks
Florian

Post Reply