Skip to content

Commit

Permalink
revert fix for #518
Browse files Browse the repository at this point in the history
  • Loading branch information
beto-rodriguez committed Aug 10, 2022
1 parent ff5b395 commit 2b6789f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 41 deletions.
20 changes: 3 additions & 17 deletions src/LiveChartsCore/Axis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public abstract class Axis<TDrawingContext, TTextGeometry, TLineGeometry>

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;
Expand Down Expand Up @@ -138,9 +137,6 @@ public abstract class Axis<TDrawingContext, TTextGeometry, TLineGeometry>
/// <inheritdoc cref="IPlane.LabelsRotation"/>
public double LabelsRotation { get => _labelsRotation; set { _labelsRotation = value; OnPropertyChanged(); } }

/// <inheritdoc cref="ICartesianAxis.LabelsAlignment"/>
public Align LabelsAlignment { get => _labelsAlignment; set { _labelsAlignment = value; OnPropertyChanged(); } }

/// <inheritdoc cref="IPlane.TextSize"/>
public double TextSize { get => _textSize; set { _textSize = value; OnPropertyChanged(); } }

Expand Down Expand Up @@ -351,11 +347,6 @@ public override void Measure(Chart<TDrawingContext> chart)

var measured = new HashSet<AxisVisualSeprator<TDrawingContext>>();

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;
Expand Down Expand Up @@ -484,17 +475,12 @@ public override void Measure(Chart<TDrawingContext> 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;
Expand Down
15 changes: 4 additions & 11 deletions src/LiveChartsCore/Drawing/Align.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,15 @@ namespace LiveChartsCore.Drawing;
public enum Align
{
/// <summary>
/// Aligns to the start of the axis.
/// Aligns to the start
/// </summary>
Start,

/// <summary>
/// Aligns to the end of the axis.
/// Aligns to the end
/// </summary>
End,

/// <summary>
/// Aligns to the middle.
/// </summary>
Middle,

/// <summary>
/// Aligns to the automatic position (defined by the object).
/// Aligns to the middle
/// </summary>
Auto
Middle
}
3 changes: 1 addition & 2 deletions src/LiveChartsCore/Drawing/IGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public interface IGeometry<TDrawingContext> : IDrawable<TDrawingContext>, IPaint
/// Measures the specified drawable task.
/// </summary>
/// <param name="drawableTask">The drawable task.</param>
/// <param name="mesureRotatedGeometry">Indicates whether the measurement should consider the geometry rotation.</param>
/// <returns></returns>
LvcSize Measure(IPaint<TDrawingContext> drawableTask, bool mesureRotatedGeometry = true);
LvcSize Measure(IPaint<TDrawingContext> drawableTask);
}
8 changes: 0 additions & 8 deletions src/LiveChartsCore/Kernel/Sketches/ICartesianAxis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ public interface ICartesianAxis : IPlane, INotifyPropertyChanged
/// </value>
AxisOrientation Orientation { get; }

/// <summary>
/// Gets or sets the labels alignent, default is <see cref="Align.Auto"/> and it lets the library decide it based on the axis position.
/// </summary>
/// <value>
/// The labels rotation.
/// </value>
Align LabelsAlignment { get; set; }

/// <summary>
/// Gets or sets the padding around the tick labels along the axis.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,14 @@ public override void Draw(SkiaSharpDrawingContext context)
/// <param name="paint">The paint.</param>
public abstract void OnDraw(SkiaSharpDrawingContext context, SKPaint paint);

/// <inheritdoc cref="IGeometry{TDrawingContext}.Measure(IPaint{TDrawingContext}, bool)"/>
public LvcSize Measure(IPaint<SkiaSharpDrawingContext> drawableTask, bool mesureRotatedGeometry = true)
/// <summary>
/// Measures the geometry.
/// </summary>
/// <param name="drawableTask">The drawable task.</param>
/// <returns>the size of the geometry.</returns>
public LvcSize Measure(IPaint<SkiaSharpDrawingContext> drawableTask)
{
var measure = OnMeasure((Paint)drawableTask);
if (!mesureRotatedGeometry) return measure;

var r = RotateTransform;
if (Math.Abs(r) > 0)
Expand Down

0 comments on commit 2b6789f

Please sign in to comment.