oxyplot icon indicating copy to clipboard operation
oxyplot copied to clipboard

TimeSpanAxis throwing FormatException

Open brainsprinter opened this issue 12 years ago • 3 comments

Clicking on the marker is throwing "FormatException".The problem occurs in the ExampleBrowser also. To reproduce the problem just open ExampleBrowser -> TimeSpanAxis example, click on any marker.

Exception details:

System.FormatException was unhandled by user code HResult=-2146233033 Message=Input string was not in a correct format. Source=mscorlib StackTrace: at System.Globalization.TimeSpanFormat.FormatCustomized(TimeSpan value, String format, DateTimeFormatInfo dtfi) at System.Globalization.TimeSpanFormat.Format(TimeSpan value, String format, IFormatProvider formatProvider) at System.TimeSpan.ToString(String format, IFormatProvider formatProvider) at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args) at System.String.Format(IFormatProvider provider, String format, Object[] args) at OxyPlot.StringHelper.Format(IFormatProvider provider, String formatString, Object item, Object[] values) in c:\projects\oxyplot\Source\OxyPlot\Utilities\StringHelper.cs:line 65 at OxyPlot.PlotElement.Format(String formatString, Object item, Object[] values) in c:\projects\oxyplot\Source\OxyPlot\PlotModel\PlotElement.cs:line 163 at OxyPlot.Series.DataPointSeries.GetNearestPoint(ScreenPoint point, Boolean interpolate) in c:\projects\oxyplot\Source\OxyPlot\Series\DataPointSeries.cs:line 109 at OxyPlot.Series.LineSeries.GetNearestPoint(ScreenPoint point, Boolean interpolate) in c:\projects\oxyplot\Source\OxyPlot\Series\LineSeries.cs:line 343 at OxyPlot.Series.Series.HitTestOverride(HitTestArguments args) in c:\projects\oxyplot\Source\OxyPlot\Series\Series.cs:line 141 at OxyPlot.UIElement.HitTest(HitTestArguments args) in c:\projects\oxyplot\Source\OxyPlot\Graphics\UIElement.cs:line 64 at OxyPlot.Model.d__0.MoveNext() in c:\projects\oxyplot\Source\OxyPlot\Graphics\Model.cs:line 72 at OxyPlot.Model.HandleMouseDown(Object sender, OxyMouseDownEventArgs e) in c:\projects\oxyplot\Source\OxyPlot\Graphics\Model.MouseEvents.cs:line 88 at OxyPlot.ControllerBase.HandleMouseDown(IView view, OxyMouseDownEventArgs args) in c:\projects\oxyplot\Source\OxyPlot\Graphics\ControllerBase.cs:line 82 at OxyPlot.Wpf.PlotView.OnMouseDown(MouseButtonEventArgs e) in c:\projects\oxyplot\Source\OxyPlot.Wpf\PlotView.cs:line 588 at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e) at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel) at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) InnerException:

brainsprinter avatar Dec 01 '14 11:12 brainsprinter

Just encountered this. It is because the default TrackerFormatString is "{0}\n{1}: {2:0.###}" which does not work with TimeSpan. The workaround is to set any other proper TrackerFormatString like "{0}\n{1}:{2}" to the series

archeg avatar Dec 01 '14 11:12 archeg

It works, thanks.

brainsprinter avatar Dec 01 '14 11:12 brainsprinter

#320

objorke avatar Jan 10 '15 14:01 objorke