Hello RMW,
I just thought I would report back with some of our findings as we have investigated this scaling issue you have run into. What you are seeing is actually a limitation of the precision that can be achieved with a double when you are adding such a large number (DateTime.Now) with such a small number (the increments between each of your data points - 1/108000). This is the root cause of the crunching that you have reported. While we will continue to work to simplify the implementation of cases such as yours, I thought I would expand on my prior suggestion. Below are two additional workarounds that will retain the year information, as well as provide results that contain none of the crunching you originally reported, which was present to some small extent in my previous workaround.
First, you could create your own new class that inherits from our FormatString class. In this class, you would only need to override one method of the base class, although overriding the constructor may be helpful as well. The only method you would need to override would be the FormatDouble method. What this would allow us to do is further reduce the value of the double that is used for the DefaultStart property, and then, when we format the string to be displayed on the labels, add in the remaining necessary double value to account for the year information. The implementation of this new class may look something like the following:
class CustomFormatString : FormatString
{
// override the base constructor, specifying that the format string mode is DateTime,
// and that the format string is "MMM-dd-yyyy h:mm:ss.fff" for all who implement this class
public CustomFormatString()
: base(FormatStringMode.DateTime, "MMM-dd-yyyy h:mm:ss.fff")
{
}
public override string FormatDouble(double value)
{
// Take the value of double that is passed in to be formatted, (the current day and time)
// and add the current year and month information back to it
return base.FormatDouble(value + (double)DataConverter.Convert(DateTime.Parse(DateTime.Now.Month +
"/1/" + DateTime.Now.Year.ToString()), typeof(double)));
}
}
You would then use this new custom FormatString class to specify the format string for the xAxis1.MajorDivisions.LabelFormat property. I have attached a modified version of your original example showing the full implementation of this idea.
Second, you could create custom divisions that would basically map to the current divisions of the x-axis. This way, you could start DefaultStart at 0, turn of the visibility of the default xAxis major division labels, and write the current DateTime string to the value field of each custom division. Please let me know if you have any questions, or if I can clarify anything for you!
NickB
National Instruments