OxyPlot.Axes.DateTimeAxis ArgumentOutOfRangeException and construtor vb.net

Dec 5, 2013 at 7:52 AM

First, really thanks for your job!!!

The method public static DateTime ToDateTime(double value) in OxyPlot.Axes.DateTimeAxis

produce an ArgumentOutOfRangeException when we zoom out at maximum

you could correct it wih this code
        /// <summary>
        /// Converts a numeric representation of the date (number of days after the time origin) to a DateTime structure.
        /// </summary>
        /// <param name="value">
        /// The number of days after the time origin.
        /// </param>
        /// <returns>
        /// A date/time structure.
        /// </returns>
        public static DateTime ToDateTime(double value)
            var result = new DateTime();

            if (double.IsNaN(value))
                return result;

            if (CanAddDays(timeOrigin, value-1))
               result= timeOrigin.AddDays(value - 1);
            return result;

        /// <summary>
        /// Determines whether this instance [can add days] the specified dt.
        /// </summary>
        /// <param name="dt">The dt.</param>
        /// <param name="days">The days.</param>
        /// <returns></returns>
        public static bool CanAddDays(DateTime dt, double days)
            double maxDaysToAdd = (DateTime.MaxValue - dt).TotalDays;
            double minDaysToAdd = (DateTime.MinValue - dt).TotalDays;
            return days <= maxDaysToAdd && days >= minDaysToAdd;
And one more thing : We have to comment the default constructor to use DateTimeAxis in vb.net

Thanks again

Dec 9, 2013 at 8:15 PM
Thanks, I never tried to zoom out that far.
I have applied some fixes that seems to help (some code in the CreateDateTickValues should also be modified).

What is the problem with the default constructor, I didn't understand.
Dec 10, 2013 at 9:03 AM
we have this error in vb.net

'.ctor' is ambiguous because multiple kinds of members with this name exist in class 'OxyPlot.DateTimeAxis'

so we have to comment the default constructor
Dec 10, 2013 at 10:29 AM
I see this has already been explained before... [discussion:394977]
Sorry, I didn't notice. I guess this applies to a lot of series constructors, too?
But I think the parameterless constructors should be chosen.
Changing this will also break a lot of code...
I added https://oxyplot.codeplex.com/workitem/10103
Dec 10, 2013 at 11:26 AM
Thanks a lot

you do a really great job!!!

I also use helixtoolkit to display robot trajectory in a 3D environnement!!

Thanks again.
Dec 10, 2013 at 11:34 AM
Even with parameterless constructors we can't instance the class

must have to comment like this in OxyPlot.Axes.DateTimeAxis
        //public DateTimeAxis()
        //    this.Position = AxisPosition.Bottom;
        //    this.IntervalType = DateTimeIntervalType.Auto;
        //    this.FirstDayOfWeek = DayOfWeek.Monday;
        //    this.CalendarWeekRule = CalendarWeekRule.FirstFourDayWeek;
Dec 11, 2013 at 10:32 AM
Can you show the VB.NET code that fails to compile when you don't comment out the constructor?
Dec 11, 2013 at 11:36 AM
Edited Dec 11, 2013 at 11:36 AM
    _dateAxis = New DateTimeAxis()
        With _dateAxis
            .Position = AxisPosition.Bottom
            .IntervalType = DateTimeIntervalType.Seconds
            .MajorGridlineStyle = LineStyle.Solid
            .Key = "AxisDate"
            .IsPanEnabled = False
        End With
Dec 12, 2013 at 6:48 AM
Thanks, but I could not reproduce the problem! That VB code compiled without any errors here!
Dec 12, 2013 at 6:54 AM

I use visual studio 2010 maybe it is the reason ?

really strange!

Dec 12, 2013 at 7:34 PM
I added a WPF/VB.NET example created in VS 2013 to Source\Examples\WPF.
Dec 27, 2013 at 6:13 PM
I don't seem to see an example that shows this works. Simply doing this in Visual Basic will cause compiler errors with the following error message:

Dim xAxis As DateTimeAxis = New DateTimeAxis()

'.ctor' is ambiguous because multiple kinds of members with this name exist in class 'OxyPlot.DateTimeAxis'

Any suggestions? I am unable the use any of the constructors for DateTimeAxis because of this issue
Jan 7, 2014 at 8:27 PM
Sorry, I have no experience with VB, but the VB example in Source\OxyPlot.WPF_VB.sln compiles without any errors here. I can also use
Dim xAxis As DateTimeAxis = New DateTimeAxis()` without getting any compiler errors.

Note that DateTimeAxis is in the OxyPlot.Axes namespace.