diff --git a/src/LiveChartsCore/CorePolarAxis.cs b/src/LiveChartsCore/CorePolarAxis.cs index ddaa299da..02a7dea9c 100644 --- a/src/LiveChartsCore/CorePolarAxis.cs +++ b/src/LiveChartsCore/CorePolarAxis.cs @@ -308,6 +308,7 @@ public override void Invalidate(Chart chart) textGeometry.X = l.X; textGeometry.Y = l.Y; textGeometry.Opacity = 0; + textGeometry.Paint = LabelsPaint; textGeometry.CompleteTransition(null); } diff --git a/src/LiveChartsCore/VisualElements/AngularTicksVisual.cs b/src/LiveChartsCore/VisualElements/AngularTicksVisual.cs index 7bfedc0ad..6d8caa490 100644 --- a/src/LiveChartsCore/VisualElements/AngularTicksVisual.cs +++ b/src/LiveChartsCore/VisualElements/AngularTicksVisual.cs @@ -194,6 +194,7 @@ protected internal override void OnInvalidated(Chart chart) visual.Label.X = cx + (float)Math.Cos(beta) * labelsRadius; visual.Label.Y = cy + (float)Math.Sin(beta) * labelsRadius; visual.Label.TextSize = labelsSize; + visual.Label.Paint = LabelsPaint; if (i + tick <= max) { diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/SkiaSharpDrawingContext.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/SkiaSharpDrawingContext.cs index d4c8f89b0..a5288854e 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/SkiaSharpDrawingContext.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/SkiaSharpDrawingContext.cs @@ -156,13 +156,6 @@ public override void Draw(IDrawable drawable, float opacity) { _ = Canvas.Save(); - if (drawable is CoreLabelGeometry label) - { - var a = label.Text; - var b = 1; - var m1 = element.Measure(); - } - var m = element.Measure(); var o = element.TransformOrigin; var p = new SKPoint(element.X, element.Y); diff --git a/tests/LiveChartsCore.UnitTesting/LayoutTests/TableLayoutTest.cs b/tests/LiveChartsCore.UnitTesting/LayoutTests/TableLayoutTest.cs index 566d73aeb..f51b63a82 100644 --- a/tests/LiveChartsCore.UnitTesting/LayoutTests/TableLayoutTest.cs +++ b/tests/LiveChartsCore.UnitTesting/LayoutTests/TableLayoutTest.cs @@ -532,10 +532,15 @@ public void UnevenColumns() var g10g = (LabelGeometry)g10.GetDrawnGeometries()[0]; var g11g = (LabelGeometry)g11.GetDrawnGeometries()[0]; - var g00m = g00g.Measure(g00.Paint); - var g01m = g01g.Measure(g01.Paint); - var g10m = g10g.Measure(g10.Paint); - var g11m = g11g.Measure(g11.Paint); + g00g.Paint = g00.Paint; + g01g.Paint = g01.Paint; + g10g.Paint = g10.Paint; + g11g.Paint = g11.Paint; + + var g00m = g00g.Measure(); + var g01m = g01g.Measure(); + var g10m = g10g.Measure(); + var g11m = g11g.Measure(); var wc0 = g00m.Width > g01m.Width ? g00m.Width : g10m.Width; var wc1 = g10m.Width > g11m.Width ? g01m.Width : g11m.Width; diff --git a/tests/LiveChartsCore.UnitTesting/OtherTests/LabelsMeasureTest.cs b/tests/LiveChartsCore.UnitTesting/OtherTests/LabelsMeasureTest.cs index c270a00ab..9a0d843f5 100644 --- a/tests/LiveChartsCore.UnitTesting/OtherTests/LabelsMeasureTest.cs +++ b/tests/LiveChartsCore.UnitTesting/OtherTests/LabelsMeasureTest.cs @@ -139,7 +139,8 @@ public void MaxWidth() l++; } - var size = label.Measure(paint); + label.Paint = paint; + var size = label.Measure(); Assert.IsTrue(size.Width <= maxWidth); Assert.IsTrue(l == label._lines); @@ -154,7 +155,9 @@ public void MaxWidth() TextSize = 15, MaxWidth = 100 }; - var size2 = label2.Measure(paint); + + label2.Paint = paint; + var size2 = label2.Measure(); Assert.IsTrue(label2._lines == 5); Assert.IsTrue(size2.Width > label2.MaxWidth); // the text is too long, this is allowed. @@ -165,7 +168,8 @@ public void MaxWidth() TextSize = 15, MaxWidth = 100 }; - var size3 = label3.Measure(paint); + label3.Paint = paint; + var size3 = label3.Measure(); var lines3 = label3.GetLines(paint._skiaPaint).ToArray(); Assert.IsTrue(label3._lines == 6); diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/BoxSeriesTests.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/BoxSeriesTests.cs index 65ab1af91..65da1d141 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/BoxSeriesTests.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/BoxSeriesTests.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Runtime.InteropServices; using LiveChartsCore.Defaults; using LiveChartsCore.Measure; using LiveChartsCore.SkiaSharpView; @@ -245,7 +246,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X) < 0.01 && // x is centered @@ -267,7 +269,8 @@ public void ShouldPlaceDataLabel() var l = p.Label; var h = Math.Abs(p.Visual.Y - p.Visual.Min); - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X) < 0.01 && // x is centered @@ -289,7 +292,8 @@ public void ShouldPlaceDataLabel() var l = p.Label; var h = Math.Abs(p.Visual.Y - p.Visual.Min); - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width - (l.X - ls.Width * 0.5)) < 0.01 && // x is right @@ -311,7 +315,8 @@ public void ShouldPlaceDataLabel() var l = p.Label; var h = Math.Abs(p.Visual.Y - p.Visual.Min); - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X - (l.X + ls.Width * 0.5f)) < 0.01 && // x is left @@ -333,7 +338,8 @@ public void ShouldPlaceDataLabel() var l = p.Label; var h = Math.Abs(p.Visual.Y - p.Visual.Min); - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X) < 0.01 && // x is centered @@ -355,7 +361,8 @@ public void ShouldPlaceDataLabel() var l = p.Label; var h = Math.Abs(p.Visual.Y - p.Visual.Min); - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); if (p.Model.Max <= 0) { @@ -388,7 +395,8 @@ public void ShouldPlaceDataLabel() var l = p.Label; var h = Math.Abs(p.Visual.Y - p.Visual.Min); - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); if (p.Model.Max <= 0) { diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/ColumnSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/ColumnSeriesTest.cs index 940051663..46e6a6682 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/ColumnSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/ColumnSeriesTest.cs @@ -227,7 +227,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X) < 0.01 && // x is centered @@ -248,7 +249,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X) < 0.01 && // x is centered @@ -269,7 +271,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width - (l.X - ls.Width * 0.5)) < 0.01 && // x is right @@ -290,7 +293,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X - (l.X + ls.Width * 0.5f)) < 0.01 && // x is left @@ -311,7 +315,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X) < 0.01 && // x is centered @@ -332,7 +337,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); if (p.Model <= 0) { @@ -364,7 +370,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); if (p.Model <= 0) { diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/FinancialSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/FinancialSeriesTest.cs index 163d7abd1..6ec89f126 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/FinancialSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/FinancialSeriesTest.cs @@ -268,7 +268,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X) < 0.01 && // x is centered @@ -290,7 +291,8 @@ public void ShouldPlaceDataLabel() var l = p.Label; var h = Math.Abs(p.Visual.Y - p.Visual.Low); - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X) < 0.01 && // x is centered @@ -312,7 +314,8 @@ public void ShouldPlaceDataLabel() var l = p.Label; var h = Math.Abs(p.Visual.Y - p.Visual.Low); - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width - (l.X - ls.Width * 0.5)) < 0.01 && // x is right @@ -334,7 +337,8 @@ public void ShouldPlaceDataLabel() var l = p.Label; var h = Math.Abs(p.Visual.Y - p.Visual.Low); - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X - (l.X + ls.Width * 0.5f)) < 0.01 && // x is left @@ -356,7 +360,8 @@ public void ShouldPlaceDataLabel() var l = p.Label; var h = Math.Abs(p.Visual.Y - p.Visual.Low); - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X) < 0.01 && // x is centered @@ -378,7 +383,8 @@ public void ShouldPlaceDataLabel() var l = p.Label; var h = Math.Abs(p.Visual.Y - p.Visual.Low); - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); if (p.Model.High <= 0) { @@ -411,7 +417,8 @@ public void ShouldPlaceDataLabel() var l = p.Label; var h = Math.Abs(p.Visual.Y - p.Visual.Low); - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); if (p.Model.High <= 0) { diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/GeneralSeriesTests.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/GeneralSeriesTests.cs index a35c1c0a2..e09b32e7b 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/GeneralSeriesTests.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/GeneralSeriesTests.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Linq; -using LiveChartsCore.Defaults; using LiveChartsCore.Drawing; using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView.Extensions; diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/HeatSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/HeatSeriesTest.cs index 5a8171736..409eb41d0 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/HeatSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/HeatSeriesTest.cs @@ -297,7 +297,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X) < 0.01 && // x is centered @@ -318,7 +319,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X) < 0.01 && // x is centered @@ -339,7 +341,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width - (l.X - ls.Width * 0.5)) < 0.01 && // x is right @@ -360,7 +363,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X - (l.X + ls.Width * 0.5f)) < 0.01 && // x is left @@ -382,7 +386,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X) < 0.01 && // x is centered diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/LineSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/LineSeriesTest.cs index 27236f871..259bd3d09 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/LineSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/LineSeriesTest.cs @@ -236,7 +236,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X - gs) < 0.01 && // x is centered @@ -257,7 +258,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X - gs) < 0.01 && // x is centered @@ -278,7 +280,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width - (l.X - ls.Width * 0.5 + gs)) < 0.01 && // x is right @@ -299,7 +302,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X - (l.X + ls.Width * 0.5f + gs)) < 0.01 && // x is left @@ -320,7 +324,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X - gs) < 0.01 && // x is centered @@ -341,7 +346,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); if (p.Model <= 0) { @@ -373,7 +379,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); if (p.Model <= 0) { diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/ScatterSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/ScatterSeriesTest.cs index ba93ad9e2..940d2bc61 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/ScatterSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/ScatterSeriesTest.cs @@ -250,7 +250,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X) < 0.01 && // x is centered @@ -271,7 +272,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X) < 0.01 && // x is centered @@ -292,7 +294,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width - (l.X - ls.Width * 0.5)) < 0.01 && // x is right @@ -313,7 +316,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X - (l.X + ls.Width * 0.5f)) < 0.01 && // x is left @@ -334,7 +338,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X) < 0.01 && // x is centered @@ -355,7 +360,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); if (p.Model <= 0) { @@ -387,7 +393,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); if (p.Model <= 0) { diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedAreaSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedAreaSeriesTest.cs index af3570669..e755cde4a 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedAreaSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedAreaSeriesTest.cs @@ -180,7 +180,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X - gs) < 0.01 && // x is centered @@ -201,7 +202,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X - gs) < 0.01 && // x is centered @@ -222,7 +224,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width - (l.X - ls.Width * 0.5 + gs)) < 0.01 && // x is right @@ -243,7 +246,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X - (l.X + ls.Width * 0.5f + gs)) < 0.01 && // x is left @@ -264,7 +268,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X - gs) < 0.01 && // x is centered @@ -285,7 +290,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); if (p.Model <= 0) { @@ -317,7 +323,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); if (p.Model <= 0) { diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedColumnSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedColumnSeriesTest.cs index 1c6d9d786..9a671ed3b 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedColumnSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedColumnSeriesTest.cs @@ -174,7 +174,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X) < 0.01 && // x is centered @@ -195,7 +196,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X) < 0.01 && // x is centered @@ -216,7 +218,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width - (l.X - ls.Width * 0.5)) < 0.01 && // x is right @@ -237,7 +240,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X - (l.X + ls.Width * 0.5f)) < 0.01 && // x is left @@ -258,7 +262,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X) < 0.01 && // x is centered @@ -279,7 +284,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); if (p.Model <= 0) { @@ -311,7 +317,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); if (p.Model <= 0) { diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedStepAreaSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedStepAreaSeriesTest.cs index 3f61f12fe..0b35ae1a8 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedStepAreaSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/StackedStepAreaSeriesTest.cs @@ -179,7 +179,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X - gs) < 0.01 && // x is centered @@ -200,7 +201,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X - gs) < 0.01 && // x is centered @@ -221,7 +223,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width - (l.X - ls.Width * 0.5 + gs)) < 0.01 && // x is right @@ -242,7 +245,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X - (l.X + ls.Width * 0.5f + gs)) < 0.01 && // x is left @@ -263,7 +267,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X - gs) < 0.01 && // x is centered @@ -284,7 +289,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); if (p.Model <= 0) { @@ -316,7 +322,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); if (p.Model <= 0) { diff --git a/tests/LiveChartsCore.UnitTesting/SeriesTests/StepLineSeriesTest.cs b/tests/LiveChartsCore.UnitTesting/SeriesTests/StepLineSeriesTest.cs index fe3d7a756..e3cec29f3 100644 --- a/tests/LiveChartsCore.UnitTesting/SeriesTests/StepLineSeriesTest.cs +++ b/tests/LiveChartsCore.UnitTesting/SeriesTests/StepLineSeriesTest.cs @@ -235,7 +235,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X - gs) < 0.01 && // x is centered @@ -256,7 +257,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X - gs) < 0.01 && // x is centered @@ -277,7 +279,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width - (l.X - ls.Width * 0.5 + gs)) < 0.01 && // x is right @@ -298,7 +301,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X - (l.X + ls.Width * 0.5f + gs)) < 0.01 && // x is left @@ -319,7 +323,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); Assert.IsTrue( Math.Abs(v.X + v.Width * 0.5f - l.X - gs) < 0.01 && // x is centered @@ -340,7 +345,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); if (p.Model <= 0) { @@ -372,7 +378,8 @@ public void ShouldPlaceDataLabel() var v = p.Visual; var l = p.Label; - var ls = l.Measure(sutSeries.DataLabelsPaint); + l.Paint = sutSeries.DataLabelsPaint; + var ls = l.Measure(); if (p.Model <= 0) {