Skip to content

Commit

Permalink
fixes a new issue introduces where SKCharts tooltips and legends text…
Browse files Browse the repository at this point in the history
…size was 0
  • Loading branch information
beto-rodriguez committed Jan 5, 2025
1 parent c7383e9 commit fe36435
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ LvcColor IChartView.BackColor
public Paint? LegendBackgroundPaint { get; set; }

/// <inheritdoc cref="IChartView.LegendTextSize"/>
public double LegendTextSize { get; set; }
public double LegendTextSize { get; set; } = LiveCharts.DefaultSettings.LegendTextSize;

/// <inheritdoc cref="IChartView.TooltipTextPaint"/>
public Paint? TooltipTextPaint { get; set; }
Expand All @@ -171,7 +171,7 @@ LvcColor IChartView.BackColor
public Paint? TooltipBackgroundPaint { get; set; }

/// <inheritdoc cref="IChartView.TooltipTextSize"/>
public double TooltipTextSize { get; set; }
public double TooltipTextSize { get; set; } = LiveCharts.DefaultSettings.TooltipTextSize;

/// <inheritdoc cref="IChartView.Measuring" />
public event ChartEventHandler? Measuring;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ public Paint? BackgroundPaint
}
}

/// <summary>
/// Gets or sets the fonts size.
/// </summary>
public double TextSize { get; set; } = 15;

/// <inheritdoc cref="IChartLegend.Draw(Chart)"/>
public void Draw(Chart chart)
{
Expand Down Expand Up @@ -125,7 +120,7 @@ private void BuildLayout(Chart chart)
{
if (chart.View.LegendTextPaint is not null) FontPaint = chart.View.LegendTextPaint;
if (chart.View.LegendBackgroundPaint is not null) BackgroundPaint = chart.View.LegendBackgroundPaint;
TextSize = chart.View.LegendTextSize;
var textSize = (float)chart.View.LegendTextSize;

_stackLayout.Orientation = chart.LegendPosition is LegendPosition.Left or LegendPosition.Right
? ContainerOrientation.Vertical
Expand Down Expand Up @@ -161,7 +156,7 @@ private void BuildLayout(Chart chart)
{
Text = series.Name ?? string.Empty,
Paint = FontPaint,
TextSize = (float)TextSize,
TextSize = textSize,
Padding = new Padding(8, 2, 0, 2),
MaxWidth = (float)LiveCharts.DefaultSettings.MaxTooltipsAndLegendsLabelsWidth,
VerticalAlign = Align.Start,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ public Paint? BackgroundPaint
}
}

/// <summary>
/// Gets or sets the fonts size.
/// </summary>
public double TextSize { get; set; }

/// <summary>
/// Gets or sets the easing function.
/// </summary>
Expand All @@ -95,7 +90,7 @@ public void Show(IEnumerable<ChartPoint> foundPoints, Chart chart)
{
const int wedge = 10;

TextSize = chart.View.TooltipTextSize;
var textSize = (float)chart.View.TooltipTextSize;
if (chart.View.TooltipBackgroundPaint is not null) BackgroundPaint = chart.View.TooltipBackgroundPaint;
if (chart.View.TooltipTextPaint is not null) FontPaint = chart.View.TooltipTextPaint;

Expand Down Expand Up @@ -157,7 +152,7 @@ public void Show(IEnumerable<ChartPoint> foundPoints, Chart chart)
{
Text = point.Context.Series.GetSecondaryToolTipText(point) ?? string.Empty,
Paint = FontPaint,
TextSize = (float)TextSize,
TextSize = textSize,
Padding = new Padding(0, 0, 0, 8),
MaxWidth = lw,
VerticalAlign = Align.Start,
Expand All @@ -180,7 +175,7 @@ public void Show(IEnumerable<ChartPoint> foundPoints, Chart chart)
{
Text = point.Context.Series.Name ?? string.Empty,
Paint = FontPaint,
TextSize = (float)TextSize,
TextSize = textSize,
Padding = new Padding(10, 0, 0, 0),
MaxWidth = lw,
VerticalAlign = Align.Start,
Expand All @@ -191,7 +186,7 @@ public void Show(IEnumerable<ChartPoint> foundPoints, Chart chart)
{
Text = content,
Paint = FontPaint,
TextSize = (float)TextSize,
TextSize = textSize,
Padding = new Padding(10, 2, 0, 2),
MaxWidth = lw,
VerticalAlign = Align.Start,
Expand Down
4 changes: 2 additions & 2 deletions src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKPieChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ LvcColor IChartView.BackColor
public Paint? LegendBackgroundPaint { get; set; }

/// <inheritdoc cref="IChartView.LegendTextSize"/>
public double LegendTextSize { get; set; }
public double LegendTextSize { get; set; } = LiveCharts.DefaultSettings.LegendTextSize;

/// <inheritdoc cref="IChartView.TooltipTextPaint"/>
public Paint? TooltipTextPaint { get; set; }
Expand All @@ -161,7 +161,7 @@ LvcColor IChartView.BackColor
public Paint? TooltipBackgroundPaint { get; set; }

/// <inheritdoc cref="IChartView.TooltipTextSize"/>
public double TooltipTextSize { get; set; }
public double TooltipTextSize { get; set; } = LiveCharts.DefaultSettings.TooltipTextSize;

/// <inheritdoc cref="IChartView.Measuring" />
public event ChartEventHandler? Measuring;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ LvcColor IChartView.BackColor
public Paint? LegendBackgroundPaint { get; set; }

/// <inheritdoc cref="IChartView.LegendTextSize"/>
public double LegendTextSize { get; set; }
public double LegendTextSize { get; set; } = LiveCharts.DefaultSettings.LegendTextSize;

/// <inheritdoc cref="IChartView.TooltipTextPaint"/>
public Paint? TooltipTextPaint { get; set; }
Expand All @@ -163,7 +163,7 @@ LvcColor IChartView.BackColor
public Paint? TooltipBackgroundPaint { get; set; }

/// <inheritdoc cref="IChartView.TooltipTextSize"/>
public double TooltipTextSize { get; set; }
public double TooltipTextSize { get; set; } = LiveCharts.DefaultSettings.TooltipTextSize;

/// <inheritdoc cref="IChartView.Title"/>
public VisualElement? Title { get; set; }
Expand Down

0 comments on commit fe36435

Please sign in to comment.