Skip to content

Update to Avalonia 12 and fix a number of issues - #76

Closed
izakusilov wants to merge 52 commits into
oxyplot:masterfrom
izakusilov:avalonia12
Closed

izakusilov wants to merge 52 commits into
oxyplot:masterfrom
izakusilov:avalonia12

Conversation

@izakusilov

Copy link
Copy Markdown

Update to Avalonia 12 and fix a number of issues

This PR moves OxyPlot.Avalonia to Avalonia 12 and OxyPlot.Core 2.2.0, fixes a number of bugs found along the way, and adds a headless test project. Every commit builds on its own; the work is split by topic so it can be reviewed commit by commit.

Avalonia 12 / OxyPlot 2.2.0

  • AvaloniaVersion 12.1.4, OxyPlotCoreVersion 2.2.0, package version 2.2.0.
  • OxyPlot.Avalonia now targets net8.0 (Avalonia 12 no longer ships netstandard2.0 assemblies).
  • IClipboard.SetTextAsync is an extension method in Avalonia 12 (Avalonia.Input.Platform).
  • Compiled bindings are on by default in Avalonia 12, so the tracker templates in Default.axaml declare x:DataType.
  • Avalonia.Diagnostics is gone in Avalonia 12, so the dev tools hooks were removed from the examples; the examples opt out of compiled bindings by default.
  • Bitmap.Save(Stream) is obsolete, the overload with PngBitmapEncoderOptions is used.
  • TrackerControl.LineDashArray is an AvaloniaList<double>, as expected by Shape.StrokeDashArray.

Fixes

Rendering and export

  • Shapes with NaN/infinite coordinates are skipped instead of failing the whole canvas layout pass.
  • Text is measured without the hard-coded 1000x1000 limit.
  • Image cropping uses CroppedBitmap instead of Clip.
  • The anti-aliasing check in DrawLineBalanced is computed once per line instead of once per point.
  • PNG export disposes the bitmap; SaveBitmap/ToBitmap throw descriptive exceptions and restore the live model afterwards.

Input

  • The context menu is opened through ContextRequested and is suppressed after dragging with the mouse.
  • Pointer capture is always released; losing the capture completes the active manipulation.
  • Mouse wheel delta works for touchpads (fractional steps).
  • PlotBase is focusable but not a tab stop.

Plot, series, axes and annotations

  • Plot.SyncLogicalTree handles Reset, Move and Replace; adding or removing elements updates the model data.
  • PlotBase.UpdateModel is virtual and Plot overrides it, so InvalidatePlot synchronizes in-place edits of the wrappers.
  • Properties that affect data (not only appearance) now refresh the data: IsVisible, BaseValue, IsStacked, StackGroup, heat map bounds, InterpolationAlgorithm, Mapping, Limit, GapWidth, date time axis settings, etc.
  • Missing property change handlers were added, duplicate ones removed.
  • Series.Foreground/FontFamily are only copied to the OxyPlot series when set explicitly (so labels follow Plot.TextColor, also in dark themes).
  • Default values match OxyPlot.Core (legend font sizes, LinearBarSeries, AngleAxis.Position, RectangleAnnotation bounds).
  • LogarithmicAxis.Base and FunctionAnnotation.Resolution are validated (invalid values made the core loop forever).
  • Default point/label lists are created per instance instead of being shared.
  • LinearColorAxis palette interpolation honors PaletteSize and no longer divides by zero.
  • Axis.MaximumMargin got the value of MinimumMargin; ExtraGridlines was registered under a different name.
  • Wrong property owners (AreaSeries.Color2, duplicate TwoColorAreaSeries.Fill), dead HeatMapSeries.LowColor/HighColor, untyped ScatterSeries.Mapping, missing LineStyle2/Lo/Hi, BoxWidth, MedianThickness and ColorAxisKey forwarding.

Breaking changes

  • TrackerControl.LineDashArray is an AvaloniaList<double>.
  • HeatMapSeries.LowColor and HeatMapSeries.HighColor were removed (they were not wired to anything).
  • Plot.TitleAlignmentProperty was renamed to Plot.TitleHorizontalAlignmentProperty.
  • Plot.PlotAreaBackground is an IBrush (was Brush).
  • PlotBase.UpdateModel is virtual.
  • ArgumentException for invalid LogarithmicAxis.Base / FunctionAnnotation.Resolution.
  • InvalidOperationException instead of NullReferenceException in SaveBitmap/ToBitmap without a model.
  • New default values: AngleAxis.Position, LinearBarSeries.BarWidth/StrokeThickness, legend font sizes, RectangleAnnotation bounds.

Tests

Source/OxyPlot.Avalonia.Tests is a new xUnit v3 project that shows controls in a headless Avalonia window (with Skia rendering) and covers the changes above. dotnet test Source/OxyPlot.Avalonia.sln runs it, and the Linux CI job now does so too.

Relationship to #74

#74 also moves the project to Avalonia 12. It is a minimal migration: it bumps the package versions, adds the Avalonia.Input.Platform using, adds x:DataType to the tracker templates and adapts the examples. This PR contains the same migration steps (first commit) and goes further, so it is both broader in scope and, I believe, more correct:

  • Broader. On top of the migration it fixes about 40 issues in rendering, input handling, model synchronization and property defaults, and adds an 83-test headless test suite that runs in CI. added support for avalonia 12 #74 does not touch the library behavior beyond compiling against Avalonia 12 and has no tests.
  • More correct.
    • TrackerControl.LineDashArray is changed to AvaloniaList<double>, the type Shape.StrokeDashArray uses in Avalonia 12; it is still List<double> in added support for avalonia 12 #74.
    • The obsolete Bitmap.Save(Stream) overload is replaced and the exported bitmap is disposed.
    • OxyPlot.Avalonia targets net8.0, the lowest framework Avalonia 12 supports, so .NET 8 applications can use the package; added support for avalonia 12 #74 targets net10.0 only.
    • Existing bugs that surface with Avalonia 12 and OxyPlot 2.2.0 are fixed (see the list above), for example the infinite loops on invalid LogarithmicAxis.Base/FunctionAnnotation.Resolution, the layout failure on non-finite shapes and the RectangleAnnotation default bounds that no longer match OxyPlot.Core 2.2.0.
  • Reviewable. Every commit builds on its own, and the commits are split by topic.

If the maintainers prefer, the first commit ("Update to Avalonia 12 and OxyPlot 2.2.0") is the equivalent of #74 and the remaining commits can be reviewed or merged separately.

@izakusilov

Copy link
Copy Markdown
Author

Closing in favor of smaller PRs that are easier to review.

@izakusilov izakusilov closed this Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant