From 2b6789f0a5221f982590d3653498f758f2861310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Tue, 9 Aug 2022 22:40:32 -0500 Subject: [PATCH] revert fix for #518 --- src/LiveChartsCore/Axis.cs | 20 +++---------------- src/LiveChartsCore/Drawing/Align.cs | 15 ++++---------- src/LiveChartsCore/Drawing/IGeometry.cs | 3 +-- .../Kernel/Sketches/ICartesianAxis.cs | 8 -------- .../Drawing/Geometries/Geometry.cs | 9 ++++++--- 5 files changed, 14 insertions(+), 41 deletions(-) diff --git a/src/LiveChartsCore/Axis.cs b/src/LiveChartsCore/Axis.cs index 4f239c646..1d989e76a 100644 --- a/src/LiveChartsCore/Axis.cs +++ b/src/LiveChartsCore/Axis.cs @@ -62,7 +62,6 @@ public abstract class Axis private double _minStep = 0; private double _labelsRotation; - private Align _labelsAlignment = Align.Auto; private LvcRectangle _labelsDesiredSize = new(), _nameDesiredSize = new(); private TTextGeometry? _nameGeometry; private AxisPosition _position = AxisPosition.Start; @@ -138,9 +137,6 @@ public abstract class Axis /// public double LabelsRotation { get => _labelsRotation; set { _labelsRotation = value; OnPropertyChanged(); } } - /// - public Align LabelsAlignment { get => _labelsAlignment; set { _labelsAlignment = value; OnPropertyChanged(); } } - /// public double TextSize { get => _textSize; set { _textSize = value; OnPropertyChanged(); } } @@ -351,11 +347,6 @@ public override void Measure(Chart chart) var measured = new HashSet>(); - var actualAlignment = _labelsAlignment; - if (actualAlignment == Align.Auto) actualAlignment = _position == AxisPosition.Start ? Align.End : Align.Start; - var ao = actualAlignment == Align.Start ? -1 : (actualAlignment == Align.End ? 1 : 0); - if (_orientation == AxisOrientation.X) ao *= -1; - for (var i = start; i <= max; i += s) { if (i < min) continue; @@ -484,17 +475,12 @@ public override void Measure(Chart chart) if (LabelsPaint is not null && visualSeparator.Label is not null) LabelsPaint.AddGeometryToPaintTask(cartesianChart.Canvas, visualSeparator.Label); - if (LabelsPaint is not null && visualSeparator.Label is not null) + if (visualSeparator.Label is not null) { visualSeparator.Label.Text = label; visualSeparator.Label.Padding = _padding; - - var rls = visualSeparator.Label.Measure(LabelsPaint); - var aox = _orientation == AxisOrientation.Y ? _xo - rls.Width * 0.5f : 0; - var aoy = _orientation == AxisOrientation.X ? _yo - rls.Height * 0.5f : 0; - - visualSeparator.Label.X = x + ao * aox; - visualSeparator.Label.Y = y + ao * aoy; + visualSeparator.Label.X = x; + visualSeparator.Label.Y = y; if (hasRotation) visualSeparator.Label.RotateTransform = r; visualSeparator.Label.Opacity = 1; diff --git a/src/LiveChartsCore/Drawing/Align.cs b/src/LiveChartsCore/Drawing/Align.cs index 65fe54994..81a17badd 100644 --- a/src/LiveChartsCore/Drawing/Align.cs +++ b/src/LiveChartsCore/Drawing/Align.cs @@ -28,22 +28,15 @@ namespace LiveChartsCore.Drawing; public enum Align { /// - /// Aligns to the start of the axis. + /// Aligns to the start /// Start, - /// - /// Aligns to the end of the axis. + /// Aligns to the end /// End, - - /// - /// Aligns to the middle. - /// - Middle, - /// - /// Aligns to the automatic position (defined by the object). + /// Aligns to the middle /// - Auto + Middle } diff --git a/src/LiveChartsCore/Drawing/IGeometry.cs b/src/LiveChartsCore/Drawing/IGeometry.cs index b63a7786b..a4a4bd777 100644 --- a/src/LiveChartsCore/Drawing/IGeometry.cs +++ b/src/LiveChartsCore/Drawing/IGeometry.cs @@ -88,7 +88,6 @@ public interface IGeometry : IDrawable, IPaint /// Measures the specified drawable task. /// /// The drawable task. - /// Indicates whether the measurement should consider the geometry rotation. /// - LvcSize Measure(IPaint drawableTask, bool mesureRotatedGeometry = true); + LvcSize Measure(IPaint drawableTask); } diff --git a/src/LiveChartsCore/Kernel/Sketches/ICartesianAxis.cs b/src/LiveChartsCore/Kernel/Sketches/ICartesianAxis.cs index 0407ebbc9..4de78e592 100644 --- a/src/LiveChartsCore/Kernel/Sketches/ICartesianAxis.cs +++ b/src/LiveChartsCore/Kernel/Sketches/ICartesianAxis.cs @@ -40,14 +40,6 @@ public interface ICartesianAxis : IPlane, INotifyPropertyChanged /// AxisOrientation Orientation { get; } - /// - /// Gets or sets the labels alignent, default is and it lets the library decide it based on the axis position. - /// - /// - /// The labels rotation. - /// - Align LabelsAlignment { get; set; } - /// /// Gets or sets the padding around the tick labels along the axis. /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/Geometry.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/Geometry.cs index 17f3d95c9..3234984c0 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/Geometry.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/Geometry.cs @@ -256,11 +256,14 @@ public override void Draw(SkiaSharpDrawingContext context) /// The paint. public abstract void OnDraw(SkiaSharpDrawingContext context, SKPaint paint); - /// - public LvcSize Measure(IPaint drawableTask, bool mesureRotatedGeometry = true) + /// + /// Measures the geometry. + /// + /// The drawable task. + /// the size of the geometry. + public LvcSize Measure(IPaint drawableTask) { var measure = OnMeasure((Paint)drawableTask); - if (!mesureRotatedGeometry) return measure; var r = RotateTransform; if (Math.Abs(r) > 0)