Skip to content

Commit

Permalink
Merge pull request #1130 from beto-rodriguez/fix-labels
Browse files Browse the repository at this point in the history
Fix labels
  • Loading branch information
beto-rodriguez committed Jul 22, 2023
2 parents 8a4cc0b + ba81233 commit b1ccacd
Show file tree
Hide file tree
Showing 15 changed files with 134 additions and 162 deletions.
10 changes: 3 additions & 7 deletions samples/MauiSample/Axes/CustomSeparatorsInterval/View.xaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="MauiSample.Axes.Multiple.View"
<ContentPage x:Class="MauiSample.Axes.CustomSeparatorsInterval.View"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.Maui;assembly=LiveChartsCore.SkiaSharpView.Maui"
xmlns:vms="clr-namespace:ViewModelsSamples.Axes.Multiple;assembly=ViewModelsSamples"
xmlns:vms="clr-namespace:ViewModelsSamples.Axes.CustomSeparatorsInterval;assembly=ViewModelsSamples"
>
<ContentPage.BindingContext>
<vms:ViewModel/>
</ContentPage.BindingContext>
<lvc:CartesianChart
Series="{Binding Series}"
YAxes="{Binding YAxes}"
LegendPosition="Bottom"
LegendBackgroundPaint="{Binding LegendTextPaint}"
LegendTextPaint="{Binding LegendTextPaint}"
LegendTextSize="16">
YAxes="{Binding YAxes}">
</lvc:CartesianChart>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace MauiSample.Axes.Multiple;
namespace MauiSample.Axes.CustomSeparatorsInterval;

[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class View : ContentPage
Expand Down
10 changes: 7 additions & 3 deletions samples/MauiSample/Axes/Multiple/View.xaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="MauiSample.Axes.CustomSeparatorsInterval.View"
<ContentPage x:Class="MauiSample.Axes.Multiple.View"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.Maui;assembly=LiveChartsCore.SkiaSharpView.Maui"
xmlns:vms="clr-namespace:ViewModelsSamples.Axes.CustomSeparatorsInterval;assembly=ViewModelsSamples"
xmlns:vms="clr-namespace:ViewModelsSamples.Axes.Multiple;assembly=ViewModelsSamples"
>
<ContentPage.BindingContext>
<vms:ViewModel/>
</ContentPage.BindingContext>
<lvc:CartesianChart
Series="{Binding Series}"
YAxes="{Binding YAxes}">
YAxes="{Binding YAxes}"
LegendPosition="Bottom"
LegendBackgroundPaint="{Binding LegendTextPaint}"
LegendTextPaint="{Binding LegendTextPaint}"
LegendTextSize="16">
</lvc:CartesianChart>
</ContentPage>
2 changes: 1 addition & 1 deletion samples/MauiSample/Axes/Multiple/View.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace MauiSample.Axes.CustomSeparatorsInterval;
namespace MauiSample.Axes.Multiple;

[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class View : ContentPage
Expand Down
2 changes: 1 addition & 1 deletion src/LiveChartsCore/Axis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public abstract class Axis<TDrawingContext, TTextGeometry, TLineGeometry>
private TTextGeometry? _nameGeometry;
private AxisPosition _position = AxisPosition.Start;
private Func<double, string> _labeler = Labelers.Default;
private Padding _padding = Padding.Default;
private Padding _padding = new();
private double? _minLimit = null;
private double? _maxLimit = null;
private IPaint<TDrawingContext>? _namePaint;
Expand Down
5 changes: 0 additions & 5 deletions src/LiveChartsCore/Drawing/Padding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ public Padding(double left, double top, double right, double bottom)
Bottom = (float)bottom;
}

/// <summary>
/// The default padding.
/// </summary>
public static Padding Default = new();

/// <summary>
/// Gets or sets the left.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
using System;
using LiveChartsCore.Drawing;
using LiveChartsCore.Motion;
using LiveChartsCore.SkiaSharpView.Painting;
using SkiaSharp;

namespace LiveChartsCore.SkiaSharpView.Drawing.Geometries;
Expand Down Expand Up @@ -89,8 +88,8 @@ public override void OnDraw(SkiaSharpDrawingContext context, SKPaint paint)
context.Canvas.DrawLine(cx, yj, cx, l, paint);
}

/// <inheritdoc cref="Geometry.OnMeasure(Paint)" />
protected override LvcSize OnMeasure(Paint paintTasks)
/// <inheritdoc cref="Geometry.OnMeasure(IPaint{SkiaSharpDrawingContext})" />
protected override LvcSize OnMeasure(IPaint<SkiaSharpDrawingContext> paintTasks)
{
return new LvcSize(Width, Math.Abs(Low - Y));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
using System;
using LiveChartsCore.Drawing;
using LiveChartsCore.Motion;
using LiveChartsCore.SkiaSharpView.Painting;
using SkiaSharp;

namespace LiveChartsCore.SkiaSharpView.Drawing.Geometries;
Expand Down Expand Up @@ -93,8 +92,8 @@ public float SweepAngle

internal static Action<DoughnutGeometry, SkiaSharpDrawingContext, SKPaint>? AlternativeDraw { get; set; }

/// <inheritdoc cref="Geometry.OnMeasure(Paint)" />
protected override LvcSize OnMeasure(Paint paint)
/// <inheritdoc cref="Geometry.OnMeasure(IPaint{SkiaSharpDrawingContext})" />
protected override LvcSize OnMeasure(IPaint<SkiaSharpDrawingContext> paint)
{
return new LvcSize(Width, Height);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
using LiveChartsCore.Drawing;
using LiveChartsCore.Motion;
using LiveChartsCore.SkiaSharpView.Motion;
using LiveChartsCore.SkiaSharpView.Painting;
using SkiaSharp;

namespace LiveChartsCore.SkiaSharpView.Drawing.Geometries;
Expand Down Expand Up @@ -187,11 +186,6 @@ public override void Draw(SkiaSharpDrawingContext context)
var xo = m.Width * o.X;
var yo = m.Height * o.Y;

if (_hasGeometryTransform)
{
ApplyCustomGeometryTransform(context);
}

if (_hasRotation)
{
context.Canvas.Translate(p.X + xo, p.Y + yo);
Expand Down Expand Up @@ -275,7 +269,7 @@ public override void Draw(SkiaSharpDrawingContext context)
/// <returns>the size of the geometry.</returns>
public LvcSize Measure(IPaint<SkiaSharpDrawingContext> drawableTask)
{
var measure = OnMeasure((Paint)drawableTask);
var measure = OnMeasure(drawableTask);

var r = RotateTransform;
if (Math.Abs(r) > 0)
Expand Down Expand Up @@ -304,11 +298,5 @@ public LvcSize Measure(IPaint<SkiaSharpDrawingContext> drawableTask)
/// </summary>
/// <param name="paintTasks">The paint task.</param>
/// <returns>the size of the geometry</returns>
protected abstract LvcSize OnMeasure(Paint paintTasks);

/// <summary>
/// Applies the geometry transform.
/// </summary>
/// <param name="context"></param>
protected virtual void ApplyCustomGeometryTransform(SkiaSharpDrawingContext context) { }
protected abstract LvcSize OnMeasure(IPaint<SkiaSharpDrawingContext> paintTasks);
}

0 comments on commit b1ccacd

Please sign in to comment.