Page 1 of 2
Diagram with microseconds resolution
Posted: Tue Jan 10, 2012 5:10 pm
by 15659960
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
Re: Diagram with microseconds resolution
Posted: Thu Jan 12, 2012 10:30 am
by 10050769
Hello FT_GIAG,
We are investigating your problem and we try to answer you asap.
Thanks,
Re: Diagram with microseconds resolution
Posted: Thu Jan 12, 2012 3:29 pm
by 10050769
Hello FT_GIAG,
I recommend that take a look in
thread. If it doesn't help you, please let me know.
Thanks,
Re: Diagram with microseconds resolution
Posted: Thu Jan 12, 2012 5:07 pm
by 15659960
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
Re: Diagram with microseconds resolution
Posted: Mon Jan 16, 2012 1:10 pm
by 10050769
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,
Re: Diagram with microseconds resolution
Posted: Mon Jan 16, 2012 5:08 pm
by 15659960
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
Re: Diagram with microseconds resolution
Posted: Wed Jan 18, 2012 12:56 pm
by 10050769
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,
Re: Diagram with microseconds resolution
Posted: Thu Jan 19, 2012 2:47 pm
by 15659960
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
Re: Diagram with microseconds resolution
Posted: Tue Jan 24, 2012 12:16 pm
by 15659960
Hello Sandra
Do you have any new information about my requests?
Regards
Florian
Re: Diagram with microseconds resolution
Posted: Wed Jan 25, 2012 10:03 am
by 10050769
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,
Re: Diagram with microseconds resolution
Posted: Wed Jan 25, 2012 11:28 am
by 15659960
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
Re: Diagram with microseconds resolution
Posted: Wed Jan 25, 2012 11:50 am
by 10050769
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,
Re: Diagram with microseconds resolution
Posted: Wed Jan 25, 2012 3:44 pm
by 15659960
Did you mean
this thread?
Re: Diagram with microseconds resolution
Posted: Wed Jan 25, 2012 4:01 pm
by 10050769
Hello Florian,
Yes, sorry seems I don't add the correct URL. I have modified the previous post.
Thanks for the information.
Re: Diagram with microseconds resolution
Posted: Thu Jan 26, 2012 9:51 am
by 15659960
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