Diagram with microseconds resolution
Diagram with microseconds resolution
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
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
-
- Comparison between custom and standard ToOADate() method
- rounded.png (56.22 KiB) Viewed 20339 times
-
- unequally distributed space
- uneqallyDistributed.png (47.06 KiB) Viewed 20320 times
-
- Microseconds.zip
- Sample application
- (39.5 KiB) Downloaded 735 times
Re: Diagram with microseconds resolution
Hello FT_GIAG,
We are investigating your problem and we try to answer you asap.
Thanks,
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 |
Instructions - How to post in this forum |
Re: Diagram with microseconds resolution
Hello FT_GIAG,
I recommend that take a look in thread. If it doesn't help you, please let me know.
Thanks,
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 |
Instructions - How to post in this forum |
Re: Diagram with microseconds resolution
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...
Regards
Florian
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");
}
Florian
Last edited by FT_GIAG on Thu Jan 19, 2012 4:35 pm, edited 1 time in total.
Re: Diagram with microseconds resolution
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,
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 |
Instructions - How to post in this forum |
Re: Diagram with microseconds resolution
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
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
Re: Diagram with microseconds resolution
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,
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 |
Instructions - How to post in this forum |
Re: Diagram with microseconds resolution
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.
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
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));
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
Re: Diagram with microseconds resolution
Hello Sandra
Do you have any new information about my requests?
Regards
Florian
Do you have any new information about my requests?
Regards
Florian
Re: Diagram with microseconds resolution
Hello Florian,
Sorry for the delay. I think you can try use Custom labels as do in next simple example:
Can you tell us if previous code help you to find a good solution about your problem with representation of microseconds?
Thanks,
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);
}
Sorry, I forgot answer this. We will work with it and we inform you asap.The first one is that if I have steps of exactly one microsecond, the spaces between the points are not equally distributed.
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Diagram with microseconds resolution
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
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 (10.06 KiB) Viewed 20228 times
Re: Diagram with microseconds resolution
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,
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 |
Instructions - How to post in this forum |
Re: Diagram with microseconds resolution
Did you mean this thread?
Re: Diagram with microseconds resolution
Hello Florian,
Yes, sorry seems I don't add the correct URL. I have modified the previous post.
Thanks for the information.
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 |
Instructions - How to post in this forum |
Re: Diagram with microseconds resolution
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 )
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
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 )
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