From b96df1448e1d8c461feba99f5b6e10306ecb3c96 Mon Sep 17 00:00:00 2001 From: izakusilov Date: Sat, 24 Oct 2026 13:49:01 +0000 Subject: [PATCH 1/4] Refresh data when properties that affect data change --- .../Annotations/FunctionAnnotation.cs | 2 ++ .../Annotations/PolylineAnnotation.cs | 1 + Source/OxyPlot.Avalonia/Axes/CategoryAxis.cs | 1 + Source/OxyPlot.Avalonia/Axes/DateTimeAxis.cs | 3 +++ .../Series/BarSeries/BarSeriesBase.cs | 8 +++++--- Source/OxyPlot.Avalonia/Series/DataPointSeries.cs | 1 + Source/OxyPlot.Avalonia/Series/HeatMapSeries.cs | 13 ++++++++----- Source/OxyPlot.Avalonia/Series/LineSeries.cs | 7 ++++++- Source/OxyPlot.Avalonia/Series/Series.cs | 4 +++- .../OxyPlot.Avalonia/Series/TwoColorAreaSeries.cs | 3 ++- 10 files changed, 32 insertions(+), 11 deletions(-) diff --git a/Source/OxyPlot.Avalonia/Annotations/FunctionAnnotation.cs b/Source/OxyPlot.Avalonia/Annotations/FunctionAnnotation.cs index c22a010..1b85bcf 100644 --- a/Source/OxyPlot.Avalonia/Annotations/FunctionAnnotation.cs +++ b/Source/OxyPlot.Avalonia/Annotations/FunctionAnnotation.cs @@ -48,6 +48,8 @@ static FunctionAnnotation() TextVerticalAlignmentProperty.Changed.AddClassHandler(AppearanceChanged); TypeProperty.Changed.AddClassHandler(DataChanged); + EquationProperty.Changed.AddClassHandler(DataChanged); + ResolutionProperty.Changed.AddClassHandler(DataChanged); } /// diff --git a/Source/OxyPlot.Avalonia/Annotations/PolylineAnnotation.cs b/Source/OxyPlot.Avalonia/Annotations/PolylineAnnotation.cs index 33772d0..c544e24 100644 --- a/Source/OxyPlot.Avalonia/Annotations/PolylineAnnotation.cs +++ b/Source/OxyPlot.Avalonia/Annotations/PolylineAnnotation.cs @@ -47,6 +47,7 @@ static PolylineAnnotation() TextVerticalAlignmentProperty.Changed.AddClassHandler(AppearanceChanged); InterpolationAlgorithmProperty.Changed.AddClassHandler(DataChanged); + MinimumSegmentLengthProperty.Changed.AddClassHandler(DataChanged); PointsProperty.Changed.AddClassHandler(DataChanged); } diff --git a/Source/OxyPlot.Avalonia/Axes/CategoryAxis.cs b/Source/OxyPlot.Avalonia/Axes/CategoryAxis.cs index 1cca98d..09242bd 100644 --- a/Source/OxyPlot.Avalonia/Axes/CategoryAxis.cs +++ b/Source/OxyPlot.Avalonia/Axes/CategoryAxis.cs @@ -53,6 +53,7 @@ static CategoryAxis() MinimumPaddingProperty.OverrideMetadata(typeof(CategoryAxis), new StyledPropertyMetadata(0.0)); MaximumPaddingProperty.OverrideMetadata(typeof(CategoryAxis), new StyledPropertyMetadata(0.0)); MajorStepProperty.OverrideMetadata(typeof(CategoryAxis), new StyledPropertyMetadata(1.0)); + GapWidthProperty.Changed.AddClassHandler(DataChanged); IsTickCenteredProperty.Changed.AddClassHandler(DataChanged); ItemsProperty.Changed.AddClassHandler(DataChanged); LabelFieldProperty.Changed.AddClassHandler(DataChanged); diff --git a/Source/OxyPlot.Avalonia/Axes/DateTimeAxis.cs b/Source/OxyPlot.Avalonia/Axes/DateTimeAxis.cs index d635017..010b649 100644 --- a/Source/OxyPlot.Avalonia/Axes/DateTimeAxis.cs +++ b/Source/OxyPlot.Avalonia/Axes/DateTimeAxis.cs @@ -60,6 +60,9 @@ static DateTimeAxis() CalendarWeekRuleProperty.Changed.AddClassHandler(DataChanged); FirstDayOfWeekProperty.Changed.AddClassHandler(DataChanged); MinorIntervalTypeProperty.Changed.AddClassHandler(DataChanged); + IntervalTypeProperty.Changed.AddClassHandler(DataChanged); + FirstDateTimeProperty.Changed.AddClassHandler(DataChanged); + LastDateTimeProperty.Changed.AddClassHandler(DataChanged); } /// diff --git a/Source/OxyPlot.Avalonia/Series/BarSeries/BarSeriesBase.cs b/Source/OxyPlot.Avalonia/Series/BarSeries/BarSeriesBase.cs index 6440597..dd92994 100644 --- a/Source/OxyPlot.Avalonia/Series/BarSeries/BarSeriesBase.cs +++ b/Source/OxyPlot.Avalonia/Series/BarSeries/BarSeriesBase.cs @@ -85,15 +85,17 @@ public class BarSeriesBase : CategorizedSeries static BarSeriesBase() { TrackerFormatStringProperty.OverrideMetadata(typeof(BarSeriesBase), new StyledPropertyMetadata(OxyPlot.Series.BarSeries.DefaultTrackerFormatString)); - BaseValueProperty.Changed.AddClassHandler(AppearanceChanged); + // BaseValue, IsStacked and StackGroup change the range of values, which the core + // recalculates only when the data is updated + BaseValueProperty.Changed.AddClassHandler(DataChanged); ColorFieldProperty.Changed.AddClassHandler(DataChanged); FillColorProperty.Changed.AddClassHandler(AppearanceChanged); - IsStackedProperty.Changed.AddClassHandler(AppearanceChanged); + IsStackedProperty.Changed.AddClassHandler(DataChanged); LabelFormatStringProperty.Changed.AddClassHandler(AppearanceChanged); LabelMarginProperty.Changed.AddClassHandler(AppearanceChanged); LabelPlacementProperty.Changed.AddClassHandler(AppearanceChanged); NegativeFillColorProperty.Changed.AddClassHandler(AppearanceChanged); - StackGroupProperty.Changed.AddClassHandler(AppearanceChanged); + StackGroupProperty.Changed.AddClassHandler(DataChanged); StrokeColorProperty.Changed.AddClassHandler(AppearanceChanged); StrokeThicknessProperty.Changed.AddClassHandler(AppearanceChanged); ValueFieldProperty.Changed.AddClassHandler(DataChanged); diff --git a/Source/OxyPlot.Avalonia/Series/DataPointSeries.cs b/Source/OxyPlot.Avalonia/Series/DataPointSeries.cs index b18f665..8ea9eec 100644 --- a/Source/OxyPlot.Avalonia/Series/DataPointSeries.cs +++ b/Source/OxyPlot.Avalonia/Series/DataPointSeries.cs @@ -123,6 +123,7 @@ static DataPointSeries() CanTrackerInterpolatePointsProperty.Changed.AddClassHandler(AppearanceChanged); DataFieldXProperty.Changed.AddClassHandler(DataChanged); DataFieldYProperty.Changed.AddClassHandler(DataChanged); + MappingProperty.Changed.AddClassHandler(DataChanged); } } } \ No newline at end of file diff --git a/Source/OxyPlot.Avalonia/Series/HeatMapSeries.cs b/Source/OxyPlot.Avalonia/Series/HeatMapSeries.cs index 6e752ee..621f518 100644 --- a/Source/OxyPlot.Avalonia/Series/HeatMapSeries.cs +++ b/Source/OxyPlot.Avalonia/Series/HeatMapSeries.cs @@ -65,11 +65,14 @@ static HeatMapSeries() { TrackerFormatStringProperty.OverrideMetadata(typeof(HeatMapSeries), new StyledPropertyMetadata(OxyPlot.Series.HeatMapSeries.DefaultTrackerFormatString)); DataProperty.Changed.AddClassHandler(DataChanged); - X0Property.Changed.AddClassHandler(AppearanceChanged); - X1Property.Changed.AddClassHandler(AppearanceChanged); - Y0Property.Changed.AddClassHandler(AppearanceChanged); - Y1Property.Changed.AddClassHandler(AppearanceChanged); - TrackerFormatStringProperty.Changed.AddClassHandler(AppearanceChanged); + + // The core computes the series bounds in UpdateMaxMin, that is, only when the data is updated: + // otherwise the axes are not rescaled to the new coordinates. + X0Property.Changed.AddClassHandler(DataChanged); + X1Property.Changed.AddClassHandler(DataChanged); + Y0Property.Changed.AddClassHandler(DataChanged); + Y1Property.Changed.AddClassHandler(DataChanged); + ColorAxisKeyProperty.Changed.AddClassHandler(AppearanceChanged); } /// diff --git a/Source/OxyPlot.Avalonia/Series/LineSeries.cs b/Source/OxyPlot.Avalonia/Series/LineSeries.cs index 93d436d..dcc8df3 100644 --- a/Source/OxyPlot.Avalonia/Series/LineSeries.cs +++ b/Source/OxyPlot.Avalonia/Series/LineSeries.cs @@ -144,7 +144,12 @@ static LineSeries() MarkerTypeProperty.Changed.AddClassHandler(AppearanceChanged); MinimumSegmentLengthProperty.Changed.AddClassHandler(AppearanceChanged); StrokeThicknessProperty.Changed.AddClassHandler(AppearanceChanged); - CanTrackerInterpolatePointsProperty.Changed.AddClassHandler(AppearanceChanged); + LabelFormatStringProperty.Changed.AddClassHandler(AppearanceChanged); + LabelMarginProperty.Changed.AddClassHandler(AppearanceChanged); + LineLegendPositionProperty.Changed.AddClassHandler(AppearanceChanged); + + // The core recalculates the smoothed points only when the data is updated + InterpolationAlgorithmProperty.Changed.AddClassHandler(DataChanged); } /// diff --git a/Source/OxyPlot.Avalonia/Series/Series.cs b/Source/OxyPlot.Avalonia/Series/Series.cs index 8f95b98..86e08f0 100644 --- a/Source/OxyPlot.Avalonia/Series/Series.cs +++ b/Source/OxyPlot.Avalonia/Series/Series.cs @@ -64,7 +64,9 @@ public abstract class Series : ItemsControl /// static Series() { - IsVisibleProperty.Changed.AddClassHandler(AppearanceChanged); + // The core loads the data and computes the axis ranges only for visible series and only + // when the data is updated. Therefore showing and hiding a series is a data change. + IsVisibleProperty.Changed.AddClassHandler(DataChanged); BackgroundProperty.Changed.AddClassHandler(AppearanceChanged); ColorProperty.Changed.AddClassHandler(AppearanceChanged); TitleProperty.Changed.AddClassHandler(AppearanceChanged); diff --git a/Source/OxyPlot.Avalonia/Series/TwoColorAreaSeries.cs b/Source/OxyPlot.Avalonia/Series/TwoColorAreaSeries.cs index 5c0223c..c8195f1 100644 --- a/Source/OxyPlot.Avalonia/Series/TwoColorAreaSeries.cs +++ b/Source/OxyPlot.Avalonia/Series/TwoColorAreaSeries.cs @@ -196,7 +196,8 @@ static TwoColorAreaSeries() Fill2Property.Changed.AddClassHandler(AppearanceChanged); MarkerFill2Property.Changed.AddClassHandler(AppearanceChanged); MarkerStroke2Property.Changed.AddClassHandler(AppearanceChanged); - LimitProperty.Changed.AddClassHandler(AppearanceChanged); + // The core splits the points into the parts above and below the limit in UpdateData, not while rendering + LimitProperty.Changed.AddClassHandler(DataChanged); Dashes2Property.Changed.AddClassHandler(AppearanceChanged); LineStyle2Property.Changed.AddClassHandler(AppearanceChanged); } From 4b709ead82a93aa6e42266ac6e2bb7986288f3c8 Mon Sep 17 00:00:00 2001 From: izakusilov Date: Sat, 24 Oct 2026 13:49:01 +0000 Subject: [PATCH 2/4] Add missing property change handlers --- Source/OxyPlot.Avalonia/Axes/Axis.cs | 2 ++ Source/OxyPlot.Avalonia/Axes/LinearAxis.cs | 10 ++++++++++ Source/OxyPlot.Avalonia/Series/PieSeries.cs | 1 + 3 files changed, 13 insertions(+) diff --git a/Source/OxyPlot.Avalonia/Axes/Axis.cs b/Source/OxyPlot.Avalonia/Axes/Axis.cs index a2c595a..172f055 100644 --- a/Source/OxyPlot.Avalonia/Axes/Axis.cs +++ b/Source/OxyPlot.Avalonia/Axes/Axis.cs @@ -1599,6 +1599,8 @@ static Axis() FontWeightProperty.Changed.AddClassHandler(AppearanceChanged); IntervalLengthProperty.Changed.AddClassHandler(AppearanceChanged); IsAxisVisibleProperty.Changed.AddClassHandler(AppearanceChanged); + IsPanEnabledProperty.Changed.AddClassHandler(AppearanceChanged); + IsZoomEnabledProperty.Changed.AddClassHandler(AppearanceChanged); KeyProperty.Changed.AddClassHandler(DataChanged); LabelFormatterProperty.Changed.AddClassHandler(AppearanceChanged); LayerProperty.Changed.AddClassHandler(AppearanceChanged); diff --git a/Source/OxyPlot.Avalonia/Axes/LinearAxis.cs b/Source/OxyPlot.Avalonia/Axes/LinearAxis.cs index 7dcfbdf..43fb1cf 100644 --- a/Source/OxyPlot.Avalonia/Axes/LinearAxis.cs +++ b/Source/OxyPlot.Avalonia/Axes/LinearAxis.cs @@ -31,6 +31,16 @@ public class LinearAxis : Axis /// public static readonly StyledProperty FractionUnitSymbolProperty = AvaloniaProperty.Register(nameof(FractionUnitSymbol)); + /// + /// Initializes static members of the class. + /// + static LinearAxis() + { + FormatAsFractionsProperty.Changed.AddClassHandler(AppearanceChanged); + FractionUnitProperty.Changed.AddClassHandler(AppearanceChanged); + FractionUnitSymbolProperty.Changed.AddClassHandler(AppearanceChanged); + } + /// /// Initializes a new instance of the class. /// diff --git a/Source/OxyPlot.Avalonia/Series/PieSeries.cs b/Source/OxyPlot.Avalonia/Series/PieSeries.cs index 0974308..60c39a1 100644 --- a/Source/OxyPlot.Avalonia/Series/PieSeries.cs +++ b/Source/OxyPlot.Avalonia/Series/PieSeries.cs @@ -154,6 +154,7 @@ static PieSeries() TickRadialLengthProperty.Changed.AddClassHandler(AppearanceChanged); TickHorizontalLengthProperty.Changed.AddClassHandler(AppearanceChanged); TickLabelDistanceProperty.Changed.AddClassHandler(AppearanceChanged); + ExplodedDistanceProperty.Changed.AddClassHandler(AppearanceChanged); LabelFieldProperty.Changed.AddClassHandler(DataChanged); ValueFieldProperty.Changed.AddClassHandler(DataChanged); ColorFieldProperty.Changed.AddClassHandler(DataChanged); From ae9b0e5863a413275008cc789c77556cda4788c5 Mon Sep 17 00:00:00 2001 From: izakusilov Date: Sat, 24 Oct 2026 13:49:01 +0000 Subject: [PATCH 3/4] Remove duplicate property change handlers --- Source/OxyPlot.Avalonia/Annotations/ArrowAnnotation.cs | 1 - Source/OxyPlot.Avalonia/Annotations/EllipseAnnotation.cs | 1 - Source/OxyPlot.Avalonia/Annotations/FunctionAnnotation.cs | 3 --- Source/OxyPlot.Avalonia/Annotations/LineAnnotation.cs | 3 --- Source/OxyPlot.Avalonia/Annotations/PointAnnotation.cs | 2 -- Source/OxyPlot.Avalonia/Annotations/PolygonAnnotation.cs | 1 - Source/OxyPlot.Avalonia/Annotations/PolylineAnnotation.cs | 3 --- Source/OxyPlot.Avalonia/Annotations/RectangleAnnotation.cs | 1 - Source/OxyPlot.Avalonia/Annotations/TextAnnotation.cs | 3 --- Source/OxyPlot.Avalonia/Axes/AngleAxis.cs | 2 -- Source/OxyPlot.Avalonia/Axes/DateTimeAxis.cs | 1 - Source/OxyPlot.Avalonia/Axes/MagnitudeAxis.cs | 1 - Source/OxyPlot.Avalonia/Series/BarSeries/BarSeriesBase.cs | 1 - Source/OxyPlot.Avalonia/Series/BoxPlotSeries.cs | 1 - Source/OxyPlot.Avalonia/Series/PieSeries.cs | 1 - Source/OxyPlot.Avalonia/Series/TwoColorAreaSeries.cs | 1 - Source/OxyPlot.Avalonia/Series/XYAxisSeries.cs | 1 - 17 files changed, 27 deletions(-) diff --git a/Source/OxyPlot.Avalonia/Annotations/ArrowAnnotation.cs b/Source/OxyPlot.Avalonia/Annotations/ArrowAnnotation.cs index fbd441f..a1f8259 100644 --- a/Source/OxyPlot.Avalonia/Annotations/ArrowAnnotation.cs +++ b/Source/OxyPlot.Avalonia/Annotations/ArrowAnnotation.cs @@ -74,7 +74,6 @@ public class ArrowAnnotation : TextualAnnotation static ArrowAnnotation() { TextColorProperty.OverrideDefaultValue(MoreColors.Automatic); - TextColorProperty.Changed.AddClassHandler(AppearanceChanged); ArrowDirectionProperty.Changed.AddClassHandler(DataChanged); ColorProperty.Changed.AddClassHandler(AppearanceChanged); diff --git a/Source/OxyPlot.Avalonia/Annotations/EllipseAnnotation.cs b/Source/OxyPlot.Avalonia/Annotations/EllipseAnnotation.cs index 1250aae..7d34eb3 100644 --- a/Source/OxyPlot.Avalonia/Annotations/EllipseAnnotation.cs +++ b/Source/OxyPlot.Avalonia/Annotations/EllipseAnnotation.cs @@ -32,7 +32,6 @@ public class EllipseAnnotation : ShapeAnnotation static EllipseAnnotation() { TextColorProperty.OverrideDefaultValue(MoreColors.Automatic); - TextColorProperty.Changed.AddClassHandler(AppearanceChanged); XProperty.Changed.AddClassHandler(DataChanged); YProperty.Changed.AddClassHandler(DataChanged); diff --git a/Source/OxyPlot.Avalonia/Annotations/FunctionAnnotation.cs b/Source/OxyPlot.Avalonia/Annotations/FunctionAnnotation.cs index 1b85bcf..e354c1a 100644 --- a/Source/OxyPlot.Avalonia/Annotations/FunctionAnnotation.cs +++ b/Source/OxyPlot.Avalonia/Annotations/FunctionAnnotation.cs @@ -41,11 +41,8 @@ public class FunctionAnnotation : PathAnnotation static FunctionAnnotation() { TextColorProperty.OverrideDefaultValue(MoreColors.Automatic); - TextColorProperty.Changed.AddClassHandler(AppearanceChanged); TextHorizontalAlignmentProperty.OverrideDefaultValue(HorizontalAlignment.Right); - TextHorizontalAlignmentProperty.Changed.AddClassHandler(AppearanceChanged); TextVerticalAlignmentProperty.OverrideDefaultValue(VerticalAlignment.Top); - TextVerticalAlignmentProperty.Changed.AddClassHandler(AppearanceChanged); TypeProperty.Changed.AddClassHandler(DataChanged); EquationProperty.Changed.AddClassHandler(DataChanged); diff --git a/Source/OxyPlot.Avalonia/Annotations/LineAnnotation.cs b/Source/OxyPlot.Avalonia/Annotations/LineAnnotation.cs index 8fbe274..7dab3aa 100644 --- a/Source/OxyPlot.Avalonia/Annotations/LineAnnotation.cs +++ b/Source/OxyPlot.Avalonia/Annotations/LineAnnotation.cs @@ -70,11 +70,8 @@ public class LineAnnotation : PathAnnotation static LineAnnotation() { TextColorProperty.OverrideDefaultValue(MoreColors.Automatic); - TextColorProperty.Changed.AddClassHandler(AppearanceChanged); TextHorizontalAlignmentProperty.OverrideDefaultValue(HorizontalAlignment.Right); - TextHorizontalAlignmentProperty.Changed.AddClassHandler(AppearanceChanged); TextVerticalAlignmentProperty.OverrideDefaultValue(VerticalAlignment.Top); - TextVerticalAlignmentProperty.Changed.AddClassHandler(AppearanceChanged); TypeProperty.Changed.AddClassHandler(DataChanged); InterceptProperty.Changed.AddClassHandler(DataChanged); diff --git a/Source/OxyPlot.Avalonia/Annotations/PointAnnotation.cs b/Source/OxyPlot.Avalonia/Annotations/PointAnnotation.cs index d3750e5..890e870 100644 --- a/Source/OxyPlot.Avalonia/Annotations/PointAnnotation.cs +++ b/Source/OxyPlot.Avalonia/Annotations/PointAnnotation.cs @@ -49,9 +49,7 @@ public class PointAnnotation : ShapeAnnotation static PointAnnotation() { TextColorProperty.OverrideDefaultValue(MoreColors.Automatic); - TextColorProperty.Changed.AddClassHandler(AppearanceChanged); TextVerticalAlignmentProperty.OverrideDefaultValue(VerticalAlignment.Top); - TextVerticalAlignmentProperty.Changed.AddClassHandler(AppearanceChanged); XProperty.Changed.AddClassHandler(DataChanged); YProperty.Changed.AddClassHandler(DataChanged); diff --git a/Source/OxyPlot.Avalonia/Annotations/PolygonAnnotation.cs b/Source/OxyPlot.Avalonia/Annotations/PolygonAnnotation.cs index 7482425..991a4c4 100644 --- a/Source/OxyPlot.Avalonia/Annotations/PolygonAnnotation.cs +++ b/Source/OxyPlot.Avalonia/Annotations/PolygonAnnotation.cs @@ -39,7 +39,6 @@ public class PolygonAnnotation : ShapeAnnotation static PolygonAnnotation() { TextColorProperty.OverrideDefaultValue(MoreColors.Automatic); - TextColorProperty.Changed.AddClassHandler(AppearanceChanged); LineJoinProperty.Changed.AddClassHandler(AppearanceChanged); LineStyleProperty.Changed.AddClassHandler(AppearanceChanged); diff --git a/Source/OxyPlot.Avalonia/Annotations/PolylineAnnotation.cs b/Source/OxyPlot.Avalonia/Annotations/PolylineAnnotation.cs index c544e24..529c951 100644 --- a/Source/OxyPlot.Avalonia/Annotations/PolylineAnnotation.cs +++ b/Source/OxyPlot.Avalonia/Annotations/PolylineAnnotation.cs @@ -40,11 +40,8 @@ public class PolylineAnnotation : PathAnnotation static PolylineAnnotation() { TextColorProperty.OverrideDefaultValue(MoreColors.Automatic); - TextColorProperty.Changed.AddClassHandler(AppearanceChanged); TextHorizontalAlignmentProperty.OverrideDefaultValue(HorizontalAlignment.Right); - TextHorizontalAlignmentProperty.Changed.AddClassHandler(AppearanceChanged); TextVerticalAlignmentProperty.OverrideDefaultValue(VerticalAlignment.Top); - TextVerticalAlignmentProperty.Changed.AddClassHandler(AppearanceChanged); InterpolationAlgorithmProperty.Changed.AddClassHandler(DataChanged); MinimumSegmentLengthProperty.Changed.AddClassHandler(DataChanged); diff --git a/Source/OxyPlot.Avalonia/Annotations/RectangleAnnotation.cs b/Source/OxyPlot.Avalonia/Annotations/RectangleAnnotation.cs index 6c9f0a1..1258f7c 100644 --- a/Source/OxyPlot.Avalonia/Annotations/RectangleAnnotation.cs +++ b/Source/OxyPlot.Avalonia/Annotations/RectangleAnnotation.cs @@ -42,7 +42,6 @@ public class RectangleAnnotation : ShapeAnnotation static RectangleAnnotation() { TextColorProperty.OverrideDefaultValue(MoreColors.Automatic); - TextColorProperty.Changed.AddClassHandler(AppearanceChanged); MaximumXProperty.Changed.AddClassHandler(DataChanged); MaximumYProperty.Changed.AddClassHandler(DataChanged); diff --git a/Source/OxyPlot.Avalonia/Annotations/TextAnnotation.cs b/Source/OxyPlot.Avalonia/Annotations/TextAnnotation.cs index 7f19a3e..1be94e2 100644 --- a/Source/OxyPlot.Avalonia/Annotations/TextAnnotation.cs +++ b/Source/OxyPlot.Avalonia/Annotations/TextAnnotation.cs @@ -50,11 +50,8 @@ public class TextAnnotation : TextualAnnotation static TextAnnotation() { TextColorProperty.OverrideDefaultValue(MoreColors.Automatic); - TextColorProperty.Changed.AddClassHandler(AppearanceChanged); TextHorizontalAlignmentProperty.OverrideDefaultValue(HorizontalAlignment.Right); - TextHorizontalAlignmentProperty.Changed.AddClassHandler(AppearanceChanged); TextVerticalAlignmentProperty.OverrideDefaultValue(VerticalAlignment.Top); - TextVerticalAlignmentProperty.Changed.AddClassHandler(AppearanceChanged); BackgroundProperty.Changed.AddClassHandler(AppearanceChanged); OffsetProperty.Changed.AddClassHandler(AppearanceChanged); diff --git a/Source/OxyPlot.Avalonia/Axes/AngleAxis.cs b/Source/OxyPlot.Avalonia/Axes/AngleAxis.cs index b81521c..dffdf32 100644 --- a/Source/OxyPlot.Avalonia/Axes/AngleAxis.cs +++ b/Source/OxyPlot.Avalonia/Axes/AngleAxis.cs @@ -41,8 +41,6 @@ static AngleAxis() IsZoomEnabledProperty.OverrideMetadata(typeof(AngleAxis), new StyledPropertyMetadata(false)); StartAngleProperty.Changed.AddClassHandler(AppearanceChanged); EndAngleProperty.Changed.AddClassHandler(AppearanceChanged); - PositionProperty.Changed.AddClassHandler(AppearanceChanged); - TickStyleProperty.Changed.AddClassHandler(AppearanceChanged); } /// diff --git a/Source/OxyPlot.Avalonia/Axes/DateTimeAxis.cs b/Source/OxyPlot.Avalonia/Axes/DateTimeAxis.cs index 010b649..fc1b115 100644 --- a/Source/OxyPlot.Avalonia/Axes/DateTimeAxis.cs +++ b/Source/OxyPlot.Avalonia/Axes/DateTimeAxis.cs @@ -56,7 +56,6 @@ public class DateTimeAxis : Axis static DateTimeAxis() { PositionProperty.OverrideDefaultValue(AxisPosition.Bottom); - PositionProperty.Changed.AddClassHandler(AppearanceChanged); CalendarWeekRuleProperty.Changed.AddClassHandler(DataChanged); FirstDayOfWeekProperty.Changed.AddClassHandler(DataChanged); MinorIntervalTypeProperty.Changed.AddClassHandler(DataChanged); diff --git a/Source/OxyPlot.Avalonia/Axes/MagnitudeAxis.cs b/Source/OxyPlot.Avalonia/Axes/MagnitudeAxis.cs index 5a428ca..de0ef92 100644 --- a/Source/OxyPlot.Avalonia/Axes/MagnitudeAxis.cs +++ b/Source/OxyPlot.Avalonia/Axes/MagnitudeAxis.cs @@ -25,7 +25,6 @@ static MagnitudeAxis() MajorGridlineStyleProperty.OverrideDefaultValue(LineStyle.Solid); MinorGridlineStyleProperty.OverrideDefaultValue(LineStyle.Solid); PositionProperty.OverrideDefaultValue(AxisPosition.None); - PositionProperty.Changed.AddClassHandler(AppearanceChanged); IsPanEnabledProperty.OverrideDefaultValue(false); IsZoomEnabledProperty.OverrideDefaultValue(false); } diff --git a/Source/OxyPlot.Avalonia/Series/BarSeries/BarSeriesBase.cs b/Source/OxyPlot.Avalonia/Series/BarSeries/BarSeriesBase.cs index dd92994..ace86d3 100644 --- a/Source/OxyPlot.Avalonia/Series/BarSeries/BarSeriesBase.cs +++ b/Source/OxyPlot.Avalonia/Series/BarSeries/BarSeriesBase.cs @@ -99,7 +99,6 @@ static BarSeriesBase() StrokeColorProperty.Changed.AddClassHandler(AppearanceChanged); StrokeThicknessProperty.Changed.AddClassHandler(AppearanceChanged); ValueFieldProperty.Changed.AddClassHandler(DataChanged); - TrackerFormatStringProperty.Changed.AddClassHandler(AppearanceChanged); } /// diff --git a/Source/OxyPlot.Avalonia/Series/BoxPlotSeries.cs b/Source/OxyPlot.Avalonia/Series/BoxPlotSeries.cs index 4882dbf..a667491 100644 --- a/Source/OxyPlot.Avalonia/Series/BoxPlotSeries.cs +++ b/Source/OxyPlot.Avalonia/Series/BoxPlotSeries.cs @@ -103,7 +103,6 @@ static BoxPlotSeries() StrokeProperty.Changed.AddClassHandler(AppearanceChanged); StrokeThicknessProperty.Changed.AddClassHandler(AppearanceChanged); WhiskerWidthProperty.Changed.AddClassHandler(AppearanceChanged); - TrackerFormatStringProperty.Changed.AddClassHandler(AppearanceChanged); } /// diff --git a/Source/OxyPlot.Avalonia/Series/PieSeries.cs b/Source/OxyPlot.Avalonia/Series/PieSeries.cs index 60c39a1..4674afa 100644 --- a/Source/OxyPlot.Avalonia/Series/PieSeries.cs +++ b/Source/OxyPlot.Avalonia/Series/PieSeries.cs @@ -159,7 +159,6 @@ static PieSeries() ValueFieldProperty.Changed.AddClassHandler(DataChanged); ColorFieldProperty.Changed.AddClassHandler(DataChanged); IsExplodedFieldProperty.Changed.AddClassHandler(DataChanged); - TrackerFormatStringProperty.Changed.AddClassHandler(AppearanceChanged); } /// diff --git a/Source/OxyPlot.Avalonia/Series/TwoColorAreaSeries.cs b/Source/OxyPlot.Avalonia/Series/TwoColorAreaSeries.cs index c8195f1..a6829fa 100644 --- a/Source/OxyPlot.Avalonia/Series/TwoColorAreaSeries.cs +++ b/Source/OxyPlot.Avalonia/Series/TwoColorAreaSeries.cs @@ -192,7 +192,6 @@ protected override void SynchronizeProperties(OxyPlot.Series.Series series) static TwoColorAreaSeries() { - FillProperty.Changed.AddClassHandler(AppearanceChanged); Fill2Property.Changed.AddClassHandler(AppearanceChanged); MarkerFill2Property.Changed.AddClassHandler(AppearanceChanged); MarkerStroke2Property.Changed.AddClassHandler(AppearanceChanged); diff --git a/Source/OxyPlot.Avalonia/Series/XYAxisSeries.cs b/Source/OxyPlot.Avalonia/Series/XYAxisSeries.cs index 269429e..d1aa95c 100644 --- a/Source/OxyPlot.Avalonia/Series/XYAxisSeries.cs +++ b/Source/OxyPlot.Avalonia/Series/XYAxisSeries.cs @@ -34,7 +34,6 @@ static XYAxisSeries() TrackerFormatStringProperty.OverrideMetadata(typeof(XYAxisSeries), new StyledPropertyMetadata(OxyPlot.Series.XYAxisSeries.DefaultTrackerFormatString)); XAxisKeyProperty.Changed.AddClassHandler(AppearanceChanged); YAxisKeyProperty.Changed.AddClassHandler(AppearanceChanged); - TrackerFormatStringProperty.Changed.AddClassHandler(AppearanceChanged); } /// From d64c3f3bd97e87459b2fdedd7e339ef6556db65f Mon Sep 17 00:00:00 2001 From: izakusilov Date: Sat, 24 Oct 2026 13:49:01 +0000 Subject: [PATCH 4/4] Do not override plot text color and font with inherited series values --- Source/OxyPlot.Avalonia/Series/Series.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/OxyPlot.Avalonia/Series/Series.cs b/Source/OxyPlot.Avalonia/Series/Series.cs index 86e08f0..3f4091a 100644 --- a/Source/OxyPlot.Avalonia/Series/Series.cs +++ b/Source/OxyPlot.Avalonia/Series/Series.cs @@ -68,6 +68,8 @@ static Series() // when the data is updated. Therefore showing and hiding a series is a data change. IsVisibleProperty.Changed.AddClassHandler(DataChanged); BackgroundProperty.Changed.AddClassHandler(AppearanceChanged); + ForegroundProperty.Changed.AddClassHandler(AppearanceChanged); + FontFamilyProperty.Changed.AddClassHandler(AppearanceChanged); ColorProperty.Changed.AddClassHandler(AppearanceChanged); TitleProperty.Changed.AddClassHandler(AppearanceChanged); RenderInLegendProperty.Changed.AddClassHandler(AppearanceChanged); @@ -260,8 +262,12 @@ protected virtual void SynchronizeProperties(OxyPlot.Series.Series s) s.TrackerKey = TrackerKey; s.TrackerFormatString = TrackerFormatString; s.IsVisible = IsVisible; - s.Font = FontFamily.ToString(); - s.TextColor = Foreground.ToOxyColor(); + + // Foreground and FontFamily are inherited from the window and the theme. They are copied only if + // they are set on the series itself, otherwise the labels follow Plot.TextColor and Plot.DefaultFont, + // like those of the axes, and do not turn white on a white background in a dark theme. + s.Font = IsSet(FontFamilyProperty) ? FontFamily.ToString() : null; + s.TextColor = IsSet(ForegroundProperty) ? Foreground.ToOxyColor() : OxyColors.Automatic; s.EdgeRenderingMode = EdgeRenderingMode; }