OxyPlot.Axes.DateTimeAxis ArgumentOutOfRangeException and construtor vb.net
This discussion was imported from CodePlex
cedrelo wrote at 2013-12-05 08:52:
Hi,
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
Thanks again
Cedre
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
Cedre
objo wrote at 2013-12-09 21:15:
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.
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.
cedrelo wrote at 2013-12-10 10:03:
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
'.ctor' is ambiguous because multiple kinds of members with this name exist in class 'OxyPlot.DateTimeAxis'
so we have to comment the default constructor
objo wrote at 2013-12-10 11:29:
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
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
cedrelo wrote at 2013-12-10 12:26:
Thanks a lot
you do a really great job!!!
I also use helixtoolkit to display robot trajectory in a 3D environnement!!
Thanks again.
you do a really great job!!!
I also use helixtoolkit to display robot trajectory in a 3D environnement!!
Thanks again.
cedrelo wrote at 2013-12-10 12:34:
Even with parameterless constructors we can't instance the class
must have to comment like this in OxyPlot.Axes.DateTimeAxis
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;
//}
objo wrote at 2013-12-11 11:32:
Can you show the VB.NET code that fails to compile when you don't comment out the constructor?
cedrelo wrote at 2013-12-11 12:36:
_dateAxis = New DateTimeAxis()
With _dateAxis
.Position = AxisPosition.Bottom
.IntervalType = DateTimeIntervalType.Seconds
.MajorGridlineStyle = LineStyle.Solid
.Key = "AxisDate"
.IsPanEnabled = False
End With
PlotModel.Axes.Add(_dateAxis)
objo wrote at 2013-12-12 07:48:
Thanks, but I could not reproduce the problem! That VB code compiled without any errors here!
cedrelo wrote at 2013-12-12 07:54:
??
I use visual studio 2010 maybe it is the reason ?
really strange!
Thanks
I use visual studio 2010 maybe it is the reason ?
really strange!
Thanks
objo wrote at 2013-12-12 20:34:
I added a WPF/VB.NET example created in VS 2013 to Source\Examples\WPF.
sdille wrote at 2013-12-27 19:13:
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:
code:
Dim xAxis As DateTimeAxis = New DateTimeAxis()
error:
'.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
code:
Dim xAxis As DateTimeAxis = New DateTimeAxis()
error:
'.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
objo wrote at 2014-01-07 21:27:
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.
Dim xAxis As DateTimeAxis = New DateTimeAxis()` without getting any compiler errors.
Note that DateTimeAxis is in the OxyPlot.Axes namespace.
Сервис поддержки клиентов работает на платформе UserEcho