diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f670c6f..bb68f58 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,37 +25,36 @@ jobs: with: fetch-depth: 0 + # Pinned to match pull-request.yml. The workload set decides $(MauiVersion), which + # becomes the Microsoft.Maui.Controls floor of the published Microcharts.Maui package. - name: Install .NET SDK uses: actions/setup-dotnet@v6 with: dotnet-version: | - 10.0.x + 10.0.401 - name: "Install .NET workloads" run: | - dotnet workload install android - dotnet workload install ios - dotnet workload install maccatalyst - dotnet workload install maui + dotnet workload install android ios maccatalyst maui --version 10.0.401 dotnet workload list - name: "Restore and build solution" - run: dotnet build Sources/Microcharts.slnx --configuration Release -p:VersionPrelease=.${{ github.run_number }} + run: dotnet build Sources/Microcharts.slnx --configuration Release -p:VersionPrelease=-preview.${{ github.run_number }} - name: "Pack Microcharts Core" - run: dotnet pack Sources/Microcharts/Microcharts.csproj --configuration Release --no-build -p:VersionPrelease=.${{ github.run_number }} + run: dotnet pack Sources/Microcharts/Microcharts.csproj --configuration Release --no-build -p:VersionPrelease=-preview.${{ github.run_number }} - name: "Pack Microcharts Droid" - run: dotnet pack Sources/Microcharts.Droid/Microcharts.Droid.csproj --configuration Release --no-build -p:VersionPrelease=.${{ github.run_number }} + run: dotnet pack Sources/Microcharts.Droid/Microcharts.Droid.csproj --configuration Release --no-build -p:VersionPrelease=-preview.${{ github.run_number }} - name: "Pack Microcharts iOS" - run: dotnet pack Sources/Microcharts.iOS/Microcharts.iOS.csproj --configuration Release --no-build -p:VersionPrelease=.${{ github.run_number }} + run: dotnet pack Sources/Microcharts.iOS/Microcharts.iOS.csproj --configuration Release --no-build -p:VersionPrelease=-preview.${{ github.run_number }} - name: "Pack Microcharts MAUI" - run: dotnet pack Sources/Microcharts.Maui/Microcharts.Maui.csproj --configuration Release --no-build -p:VersionPrelease=.${{ github.run_number }} + run: dotnet pack Sources/Microcharts.Maui/Microcharts.Maui.csproj --configuration Release --no-build -p:VersionPrelease=-preview.${{ github.run_number }} - name: "Pack Microcharts Meta-package" - run: dotnet pack Sources/Microcharts.Metapackage/Microcharts.Metapackage.csproj --configuration Release -p:VersionPrelease=.${{ github.run_number }} + run: dotnet pack Sources/Microcharts.Metapackage/Microcharts.Metapackage.csproj --configuration Release -p:VersionPrelease=-preview.${{ github.run_number }} # Always publish the build to GitHub Packages (prerelease/CI feed). - name: Publish packages to GitHub Packages diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index e93f876..db8332b 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -19,25 +19,26 @@ jobs: with: fetch-depth: 0 + # The SDK, workload set and Xcode are pinned as a set (iOS 26.5 + MAUI 10.0.20 on + # Xcode 26.6). Newer workload sets ship the iOS 27 workload, which needs Xcode 27 + # (not on macos-26), and raise $(MauiVersion), the Microsoft.Maui.Controls floor + # of the published Microcharts.Maui package. Keep publish.yml in sync. - name: Install .NET SDK uses: actions/setup-dotnet@v6 with: dotnet-version: | - 10.0.x + 10.0.401 - name: "Install .NET workloads" run: | - dotnet workload install android - dotnet workload install ios - dotnet workload install maccatalyst - dotnet workload install maui + dotnet workload install android ios maccatalyst maui --version 10.0.401 dotnet workload list - name: Select Xcode if: matrix.os == 'macos-26' uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: latest-stable + xcode-version: '26.6' - name: "Build solution" run: dotnet build Sources/Microcharts.slnx --configuration Release diff --git a/CLAUDE.md b/CLAUDE.md index b94c4f7..66d19e7 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -28,7 +28,7 @@ There are no test projects in this repository. ## Architecture -Microcharts is a cross-platform charting library built on **SkiaSharp 3.x** targeting **.NET 10**. All chart rendering is platform-agnostic SkiaSharp drawing; platform projects provide thin `ChartView` wrappers. +Microcharts is a cross-platform charting library built on **SkiaSharp 4.x** targeting **.NET 10**. All chart rendering is platform-agnostic SkiaSharp drawing; platform projects provide thin `ChartView` wrappers. ### Project Dependency Graph @@ -74,5 +74,7 @@ Version is managed centrally in `Sources/Directory.Build.props` (`VersionMain` p ## CI/CD -- **pull-request.yml** - Runs on pull requests (and manual dispatch); builds on `windows-latest` and `macos-26` (with Xcode `latest-stable` via `maxim-lobanov/setup-xcode@v1`) +- **pull-request.yml** - Runs on pull requests (and manual dispatch); builds on `windows-latest` and `macos-26` (with Xcode `26.6` via `maxim-lobanov/setup-xcode@v1`) - **publish.yml** - Manual trigger (`workflow_dispatch`); always publishes packages to GitHub Packages (`microcharts-dotnet` org), and additionally to nuget.org when the `publish_to_nuget` input is set (OIDC trusted publishing) + +Both workflows pin .NET SDK `10.0.401` and workload set `10.0.401` (iOS 26.5, MAUI 10.0.20). Newer workload sets bring the iOS 27 workload, which needs Xcode 27, and raise `$(MauiVersion)` — the `Microsoft.Maui.Controls` floor of the published `Microcharts.Maui` package. Bump the SDK, workload set and Xcode together. diff --git a/Sources/Directory.Build.props b/Sources/Directory.Build.props index bc4c5c9..26f55e5 100644 --- a/Sources/Directory.Build.props +++ b/Sources/Directory.Build.props @@ -6,8 +6,13 @@ - 2.0.0 - + 3.0.0 + -preview + + + + + 4.153.1 diff --git a/Sources/Microcharts.Droid/Microcharts.Droid.csproj b/Sources/Microcharts.Droid/Microcharts.Droid.csproj index b35ffb2..072a155 100644 --- a/Sources/Microcharts.Droid/Microcharts.Droid.csproj +++ b/Sources/Microcharts.Droid/Microcharts.Droid.csproj @@ -10,7 +10,7 @@ maui anroid chart skia - + diff --git a/Sources/Microcharts.Maui/Microcharts.Maui.csproj b/Sources/Microcharts.Maui/Microcharts.Maui.csproj index 08bc6bd..c7ff9c4 100644 --- a/Sources/Microcharts.Maui/Microcharts.Maui.csproj +++ b/Sources/Microcharts.Maui/Microcharts.Maui.csproj @@ -12,7 +12,7 @@ https://github.com/microcharts-dotnet/Microcharts.git - + diff --git a/Sources/Microcharts.Metapackage/Microcharts.Metapackage.csproj b/Sources/Microcharts.Metapackage/Microcharts.Metapackage.csproj index 41c8035..49a6c16 100644 --- a/Sources/Microcharts.Metapackage/Microcharts.Metapackage.csproj +++ b/Sources/Microcharts.Metapackage/Microcharts.Metapackage.csproj @@ -4,7 +4,8 @@ Microcharts.Metapackage.nuspec - version=$(PackageVersion) + both for CI builds (3.0.0-preview.) and clean releases (3.0.0). + $skiasharpversion$ keeps the SkiaSharp deps in lockstep with the projects. --> + version=$(PackageVersion);skiasharpversion=$(SkiaSharpVersion) \ No newline at end of file diff --git a/Sources/Microcharts.Metapackage/Microcharts.Metapackage.nuspec b/Sources/Microcharts.Metapackage/Microcharts.Metapackage.nuspec index 84eb89b..331ef4c 100644 --- a/Sources/Microcharts.Metapackage/Microcharts.Metapackage.nuspec +++ b/Sources/Microcharts.Metapackage/Microcharts.Metapackage.nuspec @@ -17,34 +17,34 @@ - + - - - + + + - - - + + + - - - + + + - - + + diff --git a/Sources/Microcharts.Samples.Android/Microcharts.Samples.Android.csproj b/Sources/Microcharts.Samples.Android/Microcharts.Samples.Android.csproj index 617d57f..c322d27 100644 --- a/Sources/Microcharts.Samples.Android/Microcharts.Samples.Android.csproj +++ b/Sources/Microcharts.Samples.Android/Microcharts.Samples.Android.csproj @@ -13,7 +13,7 @@ full - + diff --git a/Sources/Microcharts.Samples.Maui/Microcharts.Samples.Maui.csproj b/Sources/Microcharts.Samples.Maui/Microcharts.Samples.Maui.csproj index 6ed73e5..dd490c4 100644 --- a/Sources/Microcharts.Samples.Maui/Microcharts.Samples.Maui.csproj +++ b/Sources/Microcharts.Samples.Maui/Microcharts.Samples.Maui.csproj @@ -53,7 +53,7 @@ - + diff --git a/Sources/Microcharts.Samples.iOS/Microcharts.Samples.iOS.csproj b/Sources/Microcharts.Samples.iOS/Microcharts.Samples.iOS.csproj index 813bbf6..e728bef 100644 --- a/Sources/Microcharts.Samples.iOS/Microcharts.Samples.iOS.csproj +++ b/Sources/Microcharts.Samples.iOS/Microcharts.Samples.iOS.csproj @@ -15,7 +15,7 @@ iPhone Developer - + diff --git a/Sources/Microcharts.iOS/Microcharts.iOS.csproj b/Sources/Microcharts.iOS/Microcharts.iOS.csproj index 7ea1b08..05d7504 100644 --- a/Sources/Microcharts.iOS/Microcharts.iOS.csproj +++ b/Sources/Microcharts.iOS/Microcharts.iOS.csproj @@ -10,7 +10,7 @@ maui ios chart skia - + diff --git a/Sources/Microcharts/Charts/HalfRadialGaugeChart.cs b/Sources/Microcharts/Charts/HalfRadialGaugeChart.cs index 26c42a3..e843bbc 100644 --- a/Sources/Microcharts/Charts/HalfRadialGaugeChart.cs +++ b/Sources/Microcharts/Charts/HalfRadialGaugeChart.cs @@ -56,10 +56,13 @@ public void DrawGaugeArea(SKCanvas canvas, ChartEntry entry, float radius, int c IsAntialias = true, }) { - using (SKPath path = new SKPath()) + using (var builder = new SKPathBuilder()) { - path.AddArc(SKRect.Create(cx - radius * 2, cy - radius * 2, 4 * radius, 4 * radius), 180, 180); - canvas.DrawPath(path, paint); + builder.AddArc(SKRect.Create(cx - radius * 2, cy - radius * 2, 4 * radius, 4 * radius), 180, 180); + using (var path = builder.Detach()) + { + canvas.DrawPath(path, paint); + } } } } @@ -75,11 +78,14 @@ public void DrawGauge(SKCanvas canvas, SKColor color, float value, float radius, IsAntialias = true, }) { - using (SKPath path = new SKPath()) + using (var builder = new SKPathBuilder()) { var sweepAngle = AnimationProgress * 180 * (Math.Abs(value) - AbsoluteMinimum) / ValueRange; - path.AddArc(SKRect.Create(cx - radius * 2, cy - radius * 2, 4 * radius, 4 * radius), 180, sweepAngle); - canvas.DrawPath(path, paint); + builder.AddArc(SKRect.Create(cx - radius * 2, cy - radius * 2, 4 * radius, 4 * radius), 180, sweepAngle); + using (var path = builder.Detach()) + { + canvas.DrawPath(path, paint); + } } } } diff --git a/Sources/Microcharts/Charts/Legacy/LegacyPointChart.cs b/Sources/Microcharts/Charts/Legacy/LegacyPointChart.cs index f36225e..60b0d1b 100644 --- a/Sources/Microcharts/Charts/Legacy/LegacyPointChart.cs +++ b/Sources/Microcharts/Charts/Legacy/LegacyPointChart.cs @@ -329,32 +329,11 @@ protected SKRect[] MeasureLabels(string[] labels) return MeasureHelper.MeasureTexts(labels, font); } - /// - /// Measures the value labels with the text size of the given paint. - /// - /// The value labels. - protected SKRect[] MeasureLabels(string[] labels, SKPaint paint) - { - if (paint == null) - { - return MeasureLabels(labels); - } - - using var font = new SKFont(SKTypeface.Default, paint.TextSize); - return MeasureHelper.MeasureTexts(labels, font); - } - /// /// Measures the value label. /// /// The value label. protected SKRect MeasureLabel(string label) => MeasureLabels(new[] { label }).First(); - - /// - /// Measures the value label with the text size of the given paint. - /// - /// The value label. - protected SKRect MeasureLabel(string label, SKPaint paint) => MeasureLabels(new[] { label }, paint).First(); #endregion } } diff --git a/Sources/Microcharts/Charts/LineChart.cs b/Sources/Microcharts/Charts/LineChart.cs index b261cd5..3b3cae2 100644 --- a/Sources/Microcharts/Charts/LineChart.cs +++ b/Sources/Microcharts/Charts/LineChart.cs @@ -190,8 +190,7 @@ private void DrawSeriesLine(SKCanvas canvas, SKSize itemSize) using (var shader = CreateXGradient(points, s.Entries, s.Color)) paint.Shader = shader; - var path = new SKPath(); - //path.MoveTo(points.First()); + using var path = new SKPathBuilder(); var isFirst = true; var entries = s.Entries; @@ -229,7 +228,10 @@ private void DrawSeriesLine(SKCanvas canvas, SKSize itemSize) } } - canvas.DrawPath(path, paint); + using (var linePath = path.Detach()) + { + canvas.DrawPath(linePath, paint); + } } } } @@ -251,7 +253,7 @@ private void DrawLineArea(SKCanvas canvas, ChartSerie serie, SKPoint[] points, S { paint.Shader = EnableYFadeOutGradient ? SKShader.CreateCompose(shaderY, shaderX, SKBlendMode.SrcOut) : shaderX; - var path = new SKPath(); + using var path = new SKPathBuilder(); var isFirst = true; var entries = serie.Entries; @@ -303,7 +305,10 @@ private void DrawLineArea(SKCanvas canvas, ChartSerie serie, SKPoint[] points, S path.LineTo(lastPoint.X, origin); path.Close(); - canvas.DrawPath(path, paint); + using (var areaPath = path.Detach()) + { + canvas.DrawPath(areaPath, paint); + } } } } diff --git a/Sources/Microcharts/Charts/RadarChart.cs b/Sources/Microcharts/Charts/RadarChart.cs index 6aee7fe..85b99ee 100644 --- a/Sources/Microcharts/Charts/RadarChart.cs +++ b/Sources/Microcharts/Charts/RadarChart.cs @@ -103,9 +103,11 @@ public override void DrawContent(SKCanvas canvas, int width, int height) DrawBorder(canvas, center, radius); - using (var clip = new SKPath()) + using var clipBuilder = new SKPathBuilder(); + clipBuilder.AddCircle(center.X, center.Y, radius, SKPathDirection.Clockwise); + + using (var clip = clipBuilder.Detach()) { - clip.AddCircle(center.X, center.Y, radius); for (int i = 0; i < total; i++) diff --git a/Sources/Microcharts/Charts/RadialGaugeChart.cs b/Sources/Microcharts/Charts/RadialGaugeChart.cs index 858f42e..3a623d1 100644 --- a/Sources/Microcharts/Charts/RadialGaugeChart.cs +++ b/Sources/Microcharts/Charts/RadialGaugeChart.cs @@ -70,11 +70,14 @@ public void DrawGauge(SKCanvas canvas, SKColor color, float value, float radius, IsAntialias = true, }) { - using (SKPath path = new SKPath()) + using (var builder = new SKPathBuilder()) { var sweepAngle = AnimationProgress * 360 * (Math.Abs(value) - AbsoluteMinimum) / ValueRange; - path.AddArc(SKRect.Create(cx - radius, cy - radius, 2 * radius, 2 * radius), StartAngle, sweepAngle); - canvas.DrawPath(path, paint); + builder.AddArc(SKRect.Create(cx - radius, cy - radius, 2 * radius, 2 * radius), StartAngle, sweepAngle); + using (var path = builder.Detach()) + { + canvas.DrawPath(path, paint); + } } } } diff --git a/Sources/Microcharts/Helpers/RadialHelpers.cs b/Sources/Microcharts/Helpers/RadialHelpers.cs index 7c22a91..dc5c74f 100644 --- a/Sources/Microcharts/Helpers/RadialHelpers.cs +++ b/Sources/Microcharts/Helpers/RadialHelpers.cs @@ -27,21 +27,21 @@ public static SKPoint GetCirclePoint(float r, float angle) public static SKPath CreateSectorPath(float start, float end, float outerRadius, float innerRadius = 0.0f, float margin = 0.0f) { - var path = new SKPath(); - // if the sector has no size, then it has no path if (start == end) { - return path; + return new SKPath(); } + using var path = new SKPathBuilder(); + // if the sector is a full circle, then do that if (end - start == 1.0f) { path.AddCircle(0, 0, outerRadius, SKPathDirection.Clockwise); path.AddCircle(0, 0, innerRadius, SKPathDirection.Clockwise); path.FillType = SKPathFillType.EvenOdd; - return path; + return path.Detach(); } // calculate the angles @@ -76,7 +76,7 @@ public static SKPath CreateSectorPath(float start, float end, float outerRadius, path.Close(); - return path; + return path.Detach(); } #endregion diff --git a/Sources/Microcharts/Microcharts.csproj b/Sources/Microcharts/Microcharts.csproj index 6f9590a..46996d6 100644 --- a/Sources/Microcharts/Microcharts.csproj +++ b/Sources/Microcharts/Microcharts.csproj @@ -13,6 +13,6 @@ $(NoWarn);CS1591 - +