Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
25e3de1
Update to Avalonia 12 and OxyPlot 2.2.0
izakusilov Oct 24, 2026
6d34b41
Remove unused fields from PlotBase
izakusilov Oct 24, 2026
a09672e
Use AvaloniaList for TrackerControl.LineDashArray
izakusilov Oct 24, 2026
a1da4b7
Fix TrackerControl corner radius and border updates
izakusilov Oct 24, 2026
be6c54c
Apply default styles to derived plot controls
izakusilov Oct 24, 2026
f1ce49e
Use black text in the tracker template
izakusilov Oct 24, 2026
49e46b1
Fix zoom rectangle border thickness
izakusilov Oct 24, 2026
8afb699
Skip shapes with non-finite coordinates
izakusilov Oct 24, 2026
ae42a6f
Measure text without size limit
izakusilov Oct 24, 2026
113022f
Fix image cropping in CanvasRenderContext
izakusilov Oct 24, 2026
0d4e522
Compute anti-aliasing mode once per line
izakusilov Oct 24, 2026
871c35b
Dispose bitmap after exporting to PNG
izakusilov Oct 24, 2026
e44032e
Validate model and size in SaveBitmap and ToBitmap
izakusilov Oct 24, 2026
e875d8d
Catch clipboard errors in SetClipboardText
izakusilov Oct 24, 2026
966ea8a
Use the control dispatcher in PlotBase
izakusilov Oct 24, 2026
fdda72c
Clear the plot when the model is removed
izakusilov Oct 24, 2026
5691838
Make PlotBase focusable
izakusilov Oct 24, 2026
caa48fa
Fix mouse wheel delta for touchpads
izakusilov Oct 24, 2026
fc34471
Fix context menu and pointer capture handling
izakusilov Oct 24, 2026
279faac
Synchronize the model when InvalidatePlot is called on a plot
izakusilov Oct 24, 2026
ccf8fa4
Fix logical tree and model update when plot elements change
izakusilov Oct 24, 2026
5a33ab5
Apply TitleHorizontalAlignment to the model
izakusilov Oct 24, 2026
f40f8a6
Accept any brush as PlotAreaBackground
izakusilov Oct 24, 2026
2e5a5c2
Refresh data when properties that affect data change
izakusilov Oct 24, 2026
a34b570
Add missing property change handlers
izakusilov Oct 24, 2026
a245074
Remove duplicate property change handlers
izakusilov Oct 24, 2026
f87471f
Do not override plot text color and font with inherited series values
izakusilov Oct 24, 2026
b0c9064
Match default values of legend, linear bar series and angle axis with…
izakusilov Oct 24, 2026
976f450
Use infinite default bounds for RectangleAnnotation
izakusilov Oct 24, 2026
aaefee3
Set default values in metadata instead of constructors
izakusilov Oct 24, 2026
74cc154
Validate LogarithmicAxis.Base and FunctionAnnotation.Resolution
izakusilov Oct 24, 2026
8974e6a
Create default lists per instance
izakusilov Oct 24, 2026
daa2d11
Fix LinearColorAxis palette generation
izakusilov Oct 24, 2026
2e97d74
Fix Axis.MaximumMargin and ExtraGridlines registration
izakusilov Oct 24, 2026
a338880
Fix property owners in area series
izakusilov Oct 24, 2026
6604322
Remove unused HeatMapSeries colors and forward ColorAxisKey
izakusilov Oct 24, 2026
c2bfa49
Type ScatterSeries.Mapping and make ColorAxisKey a styled property
izakusilov Oct 24, 2026
a307cbe
Forward secondary line styles of two and three color line series
izakusilov Oct 24, 2026
0d9a0e1
Forward BoxWidth and MedianThickness to BoxPlotSeries
izakusilov Oct 24, 2026
37746ef
Keep marker and outlier outlines null instead of empty arrays
izakusilov Oct 24, 2026
c2cc074
Ignore foreign items in bar and box plot series
izakusilov Oct 24, 2026
a669690
Do not override text alignment of TextAnnotation
izakusilov Oct 24, 2026
be4ee69
Add headless test project
izakusilov Oct 24, 2026
85166bf
Add plot tests
izakusilov Oct 24, 2026
3602d66
Add axis tests
izakusilov Oct 24, 2026
4ec6151
Add annotation tests
izakusilov Oct 24, 2026
76fe086
Add series tests
izakusilov Oct 24, 2026
151b0c1
Add tracker tests
izakusilov Oct 24, 2026
fb9744c
Add input tests
izakusilov Oct 24, 2026
8ce09e8
Add export tests
izakusilov Oct 24, 2026
6cdf23e
Add render context tests
izakusilov Oct 24, 2026
bf14cce
Run tests in CI
izakusilov Oct 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
dotnet add package OxyPlot.Avalonia
```

The package targets Avalonia 12 and requires .NET 8 or later.

### Usage

To use the library, add the following to your `App.xaml`:
Expand All @@ -23,7 +25,7 @@ To use the library, add the following to your `App.xaml`:
<!-- Add the line below to get OxyPlot UI theme applied. -->
<StyleInclude Source="resm:OxyPlot.Avalonia.Themes.Default.xaml?assembly=OxyPlot.Avalonia"/>

<!-- Add the line below to get OxyPlot UI theme applied in Avalonia 11. -->
<!-- Add the line below to get OxyPlot UI theme applied in Avalonia 11 and 12. -->
<StyleInclude Source="avares://OxyPlot.Avalonia/Themes/Default.axaml"/>
</Application.Styles>
</Application>
Expand Down
4 changes: 2 additions & 2 deletions Source/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<AvaloniaVersion>11.0.0</AvaloniaVersion>
<OxyPlotCoreVersion>2.1.2</OxyPlotCoreVersion>
<AvaloniaVersion>12.1.4</AvaloniaVersion>
<OxyPlotCoreVersion>2.2.0</OxyPlotCoreVersion>
</PropertyGroup>
</Project>
6 changes: 0 additions & 6 deletions Source/Examples/Avalonia/AvaloniaExamples/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,5 @@ static void Main(string[] args)
.StartWithClassicDesktopLifetime(args);
}

public static void AttachDevTools(Window window)
{
#if DEBUG
DevToolsExtensions.AttachDevTools(window);
#endif
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>WinExe</OutputType>
<AvaloniaUseCompiledBindingsByDefault>false</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>
<ItemGroup>
<AvaloniaResource Include="Images\*" />
Expand All @@ -11,6 +12,5 @@
<ProjectReference Include="..\..\..\OxyPlot.Avalonia\OxyPlot.Avalonia.csproj" />
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Themes.Simple" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public partial class MainWindow : Avalonia.Controls.Window
public MainWindow()
{
this.InitializeComponent();
App.AttachDevTools(this);
}

private void InitializeComponent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public MainWindow()

this.InitializeComponent();

App.AttachDevTools(this);
}

private void InitializeComponent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public PlotViewDataTemplateWindow()
private void InitializeComponent()
{
Avalonia.Markup.Xaml.AvaloniaXamlLoader.Load(this);
App.AttachDevTools(this);
}

private static Random r = new Random(13);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public MainWindow()
{
this.InitializeComponent();
this.DataContext = new { Model1 = new ViewModel { Title = "Plot1" }, Model2 = new ViewModel { Title = "Plot2" } };
App.AttachDevTools(this);
}

private void InitializeComponent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public MainWindow2()
{
this.InitializeComponent();
this.DataContext = new { Models = new List<ViewModel> { new ViewModel { Title = "Plot1" }, new ViewModel { Title = "Plot2" } } };
App.AttachDevTools(this);
}

private void InitializeComponent()
Expand Down
2 changes: 0 additions & 2 deletions Source/Examples/Avalonia/AvaloniaExamples/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ namespace AvaloniaExamples
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Diagnostics;
using Avalonia.Interactivity;

/// <summary>
Expand All @@ -35,7 +34,6 @@ public MainWindow()
InitializeComponent();
ListBox.ItemsSource = this.Examples = this.GetExamples(this.GetType().Assembly).OrderBy(e => e.Title).ToArray();
this.DataContext = this;
DevToolsExtensions.AttachDevTools(this);
}

private void InitializeComponent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<AvaloniaUseCompiledBindingsByDefault>false</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Themes.Simple" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
<PackageReference Include="OxyPlot.Core" Version="$(OxyPlotCoreVersion)" />
<PackageReference Include="OxyPlot.ExampleLibrary" Version="$(OxyPlotCoreVersion)" />
</ItemGroup>
Expand Down
3 changes: 0 additions & 3 deletions Source/Examples/Avalonia/ExampleBrowser/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ public partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}

private void InitializeComponent()
Expand Down
6 changes: 0 additions & 6 deletions Source/Examples/Avalonia/MemoryTest/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,5 @@ static void Main(string[] args)
.StartWithClassicDesktopLifetime(args);
}

public static void AttachDevTools(Window window)
{
#if DEBUG
DevToolsExtensions.AttachDevTools(window);
#endif
}
}
}
1 change: 0 additions & 1 deletion Source/Examples/Avalonia/MemoryTest/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public partial class MainWindow : Window
public MainWindow()
{
this.InitializeComponent();
App.AttachDevTools(this);
}

private void InitializeComponent()
Expand Down
2 changes: 1 addition & 1 deletion Source/Examples/Avalonia/MemoryTest/MemoryTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<AvaloniaUseCompiledBindingsByDefault>false</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="11.0.0" />
<ProjectReference Include="..\..\..\OxyPlot.Avalonia\OxyPlot.Avalonia.csproj" />
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Themes.Simple" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
</ItemGroup>
</Project>
1 change: 0 additions & 1 deletion Source/Examples/Avalonia/MemoryTest/Window1.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public Window1()

InitializeComponent();

App.AttachDevTools(this);
}

private void InitializeComponent()
Expand Down
1 change: 0 additions & 1 deletion Source/Examples/Avalonia/MemoryTest/Window2.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public Window2()
}

InitializeComponent();
App.AttachDevTools(this);

DataContext = Plots;
}
Expand Down
2 changes: 0 additions & 2 deletions Source/Examples/Avalonia/SimpleDemo/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

using Avalonia;
using Avalonia.Controls;
using Avalonia.Diagnostics;
using Avalonia.Markup.Xaml;

namespace SimpleDemo
Expand All @@ -25,7 +24,6 @@ public partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();
this.AttachDevTools();
}

private void InitializeComponent()
Expand Down
2 changes: 1 addition & 1 deletion Source/Examples/Avalonia/SimpleDemo/SimpleDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<AvaloniaUseCompiledBindingsByDefault>false</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="11.0.0" />
<ProjectReference Include="..\..\..\OxyPlot.Avalonia\OxyPlot.Avalonia.csproj" />
<PackageReference Include="Serilog.Sinks.Trace" Version="2.1.0" />
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Themes.Simple" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
</ItemGroup>
</Project>
168 changes: 168 additions & 0 deletions Source/OxyPlot.Avalonia.Tests/AnnotationTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
using Avalonia.Headless.XUnit;
using Avalonia.Media;
using OxyPlot;
using OxyPlot.Avalonia;
using AvaloniaHorizontalAlignment = Avalonia.Layout.HorizontalAlignment;
using AvaloniaVerticalAlignment = Avalonia.Layout.VerticalAlignment;
using CoreAnnotations = OxyPlot.Annotations;
using CoreAxes = OxyPlot.Axes;
using ShapePath = Avalonia.Controls.Shapes.Path;

namespace OxyPlot.Avalonia.Tests;

/// <summary>
/// Tests of the annotation controls: default values, copying to the core and rendering without failures.
/// </summary>
public class AnnotationTests
{
[AvaloniaFact]
public void RectangleAnnotation_HorizontalBand_DrawsAcrossPlotArea()
{
var plot = PlotWithAxes();
plot.Annotations.Add(new RectangleAnnotation { MinimumY = 4, MaximumY = 6 });

// Show used to throw InvalidOperationException from Measure: the rectangle went to infinity
var window = Ui.Show(plot);

var plotArea = plot.ActualModel.PlotArea;
var band = Assert.Single(
Ui.PlotCanvas(plot).Children.OfType<ShapePath>(),
p => p.Fill != null && p.Data is RectangleGeometry);
var rect = ((RectangleGeometry)band.Data!).Rect;
Assert.Equal(plotArea.Width, rect.Width, 3);
Assert.True(rect.Height > 0 && rect.Height < plotArea.Height);
window.Close();
}

[AvaloniaFact]
public void RectangleAnnotation_Defaults_AreInfiniteAsInCore()
{
var annotation = new RectangleAnnotation();

Assert.Equal(double.NegativeInfinity, annotation.MinimumX);
Assert.Equal(double.PositiveInfinity, annotation.MaximumX);
Assert.Equal(double.NegativeInfinity, annotation.MinimumY);
Assert.Equal(double.PositiveInfinity, annotation.MaximumY);
}

[AvaloniaFact]
public void RectangleAnnotation_LegacyMinMaxValues_BecomeInfiniteInModel()
{
// the previous values double.MinValue/MaxValue still mean "no bound"
var annotation = new RectangleAnnotation
{
MinimumX = double.MinValue,
MaximumX = double.MaxValue,
MinimumY = 1,
MaximumY = 2,
};

var model = Assert.IsType<CoreAnnotations.RectangleAnnotation>(annotation.CreateModel());

Assert.Equal(double.NegativeInfinity, model.MinimumX);
Assert.Equal(double.PositiveInfinity, model.MaximumX);
Assert.Equal(1, model.MinimumY);
Assert.Equal(2, model.MaximumY);
}

[AvaloniaFact]
public void EllipseAnnotation_WithoutSize_DoesNotBreakLayout()
{
var plot = PlotWithAxes();
plot.Annotations.Add(new EllipseAnnotation { X = 5, Y = 5 });

var window = Ui.Show(plot);

Assert.True(plot.ActualModel.PlotArea.Width > 0);
window.Close();
}

[AvaloniaFact]
public void TextAnnotation_WithoutPosition_DoesNotBreakLayout()
{
var plot = PlotWithAxes();
plot.Annotations.Add(new TextAnnotation { Text = "label" });

var window = Ui.Show(plot);

Assert.True(plot.ActualModel.PlotArea.Width > 0);
window.Close();
}

[AvaloniaFact]
public void PlotView_CoreEllipseAnnotationWithoutSize_DoesNotBreakLayout()
{
// the core itself builds an ellipse with a NaN size, so the protection is needed in the render context
var model = Ui.ModelWithAxes();
model.Annotations.Add(new CoreAnnotations.EllipseAnnotation { X = 5, Y = 5 });
var view = new PlotView { Model = model };

var window = Ui.Show(view);

Assert.True(model.PlotArea.Width > 0);
window.Close();
}

[AvaloniaTheory]
[InlineData(0)]
[InlineData(-1)]
public void FunctionAnnotation_NonPositiveResolution_Throws(int value)
{
// the core divides the range by Resolution and steps to the bound: the loop would never end
Assert.Throws<ArgumentException>(() => new FunctionAnnotation { Resolution = value });
}

[AvaloniaFact]
public void PolygonAnnotation_TwoInstances_HaveSeparatePointLists()
{
var first = new PolygonAnnotation();
var second = new PolygonAnnotation();

first.Points.Add(new DataPoint(1, 1));

Assert.NotSame(first.Points, second.Points);
Assert.Empty(second.Points);
}

[AvaloniaFact]
public void PolylineAnnotation_TwoInstances_HaveSeparatePointLists()
{
var first = new PolylineAnnotation();
var second = new PolylineAnnotation();

first.Points.Add(new DataPoint(1, 1));

Assert.NotSame(first.Points, second.Points);
Assert.Empty(second.Points);
}

[AvaloniaFact]
public void TextAnnotation_TextAlignment_ReachesModelInsteadOfLayoutAlignment()
{
// the layout alignment of the control must not replace the text alignment
var annotation = new TextAnnotation
{
Text = "label",
TextHorizontalAlignment = AvaloniaHorizontalAlignment.Left,
TextVerticalAlignment = AvaloniaVerticalAlignment.Bottom,
HorizontalAlignment = AvaloniaHorizontalAlignment.Right,
VerticalAlignment = AvaloniaVerticalAlignment.Top,
};

var model = Assert.IsType<CoreAnnotations.TextAnnotation>(annotation.CreateModel());

Assert.Equal(HorizontalAlignment.Left, model.TextHorizontalAlignment);
Assert.Equal(VerticalAlignment.Bottom, model.TextVerticalAlignment);
}

/// <summary>
/// A plot with linear axes 0..10 on which the annotations get screen coordinates.
/// </summary>
private static Plot PlotWithAxes()
{
var plot = new Plot();
plot.Axes.Add(new LinearAxis { Position = CoreAxes.AxisPosition.Bottom, Minimum = 0, Maximum = 10 });
plot.Axes.Add(new LinearAxis { Position = CoreAxes.AxisPosition.Left, Minimum = 0, Maximum = 10 });
return plot;
}
}
Loading