Overflow exception when zooming in.

wl_joep 2 years ago in Bugs • updated 2 years ago 2

For some examples, when zooming in too much, an OverflowException occurs. This seems to have to do with rendering rectangles (GraphicsRenderContext.DrawRectangle). For an example, zoom in on the RectangleAnnotation examples.


   at System.Drawing.Graphics.CheckErrorStatus(Int32 status)   at System.Drawing.Graphics.FillRectangle(Brush brush, Single x, Single y, Single width, Single height)
   at OxyPlot.WindowsForms.GraphicsRenderContext.DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, Double thickness) in OxyPlot.WindowsForms\GraphicsRenderContext.cs:line 216
   at OxyPlot.RenderingExtensions.DrawClippedRectangle(IRenderContext rc, OxyRect clippingRectangle, OxyRect rect, OxyColor fill, OxyColor stroke, Double thickness) in OxyPlot\Rendering\RenderContext\RenderingExtensions.cs:line 366
   at OxyPlot.Annotations.RectangleAnnotation.Render(IRenderContext rc) in OxyPlot\Annotations\RectangleAnnotation.cs:line 84
   at OxyPlot.PlotModel.RenderAnnotations(IRenderContext rc, AnnotationLayer layer) in OxyPlot\PlotModel\PlotModel.Rendering.cs:line 347
   at OxyPlot.PlotModel.RenderOverride(IRenderContext rc, Double width, Double height) in OxyPlot\PlotModel\PlotModel.Rendering.cs:line 113

A comparable exception occurs for AreaSeries when it tries to draw Polygons. It doesn't occur for LineSeries.

As a workaround, I used the MinimumRange property on the axis to restrict the "zoom level".