Skip to content

Slint - #388

Closed
yurkinh wants to merge 2 commits into
microcharts-dotnet:mainfrom
yurkinh:slint
Closed

Slint#388
yurkinh wants to merge 2 commits into
microcharts-dotnet:mainfrom
yurkinh:slint

Conversation

@yurkinh

@yurkinh yurkinh commented Oct 29, 2026

Copy link
Copy Markdown

Add Microcharts.Slint, a chart view for Slint

Slint is a native UI toolkit with .NET 10 bindings, Slint for .NET, for macOS, Linux, Windows, Android, and iOS.
This adds Microcharts.Slint, so that Slint apps can show Microcharts' charts, like the MAUI, iOS, and Android views do.
I'm the author of the .NET bindings for Slint, and I'll maintain this view.

Android iOS
Microcharts on Slint, Android Microcharts on Slint, iOS

What's in It

  • Microcharts.Core builds without MAUI.
    UseMaui gave the core's assemblies MAUI's XAML namespace attributes, whose types live in Microsoft.Maui.Controls.
    Mono decodes them when it loads the assembly, so an Android app without MAUI aborts at startup:
    mono_assembly_load_friends: Could not load file or assembly 'Microsoft.Maui.Controls'.
    The assemblies of the published 3.0.0-preview.4 carry the same attributes, so it likely affects other Android apps without MAUI too.
    The core uses no MAUI API, so the change is two lines in its project; Microcharts.Maui and the Android sample still build.
  • Sources/Microcharts.Slint, under 200 lines with comments, for net10.0, net10.0-android, and net10.0-ios:
    • ChartRenderer draws a chart with Chart.Draw into an SKBitmap at the size of a Slint Image, in physical pixels,
      and hands the pixels to Slint without converting them.
      It draws again when the chart invalidates or the size changes, and follows the chart through ObserveInvalidate.
      The chart's sizes, such as LabelTextSize, are in logical pixels, scaled by the window's scale factor, like Slint's lengths.
    • SlintTimer is an ITimer on Slint's timers, so that animations step on the Slint thread, where the UI may change.
      SlintTimer.Install() sets Microcharts.Timer.Create, like UseMicrocharts() on MAUI.
    • chart-view.slint has a ChartView, an Image that reports its size.
  • Sources/Microcharts.Samples.Slint: the charts of Data.CreateQuickstart, in a desktop, an Android, and an iOS project that share the UI.
  • The README has a Slint section, with the code and the screenshots above.

Usage

SlintTimer.Install(); // before creating charts, so that they animate on the Slint thread
using var app = AppWindow.Create();
var renderer = new ChartRenderer(app.Window, image => app.SalesChart = image)
{
    Chart = new BarChart { Entries = entries },
};
app.OnSalesChartResized(renderer.Resize);
app.Run();

Testing

  • The gallery runs on macOS, on an Android emulator (Pixel 9, arm64), and in the iPhone simulator.
    On iOS, SkiaSharp's framework and Slint's sit side by side in the app.
  • A frame of a 1920 × 934 pixel chart takes about 1.4 ms to draw and hand to Slint, so animations stay smooth.
  • Microcharts.Maui and Microcharts.Samples.Android build with the changed core.

Not in It Yet

The projects aren't in Microcharts.slnx or the publish workflow yet.
They need Slint for .NET 1.19.0-preview.10, which adds the premultiplied pixel API, and I'd add them once it's on nuget.org, or in this PR if it's there first.
Until then, build them against a Slint checkout with -p:SlintRepository=<path>.

yurkinh and others added 2 commits October 29, 2026 16:24
Microcharts.Core uses no MAUI API, but UseMaui gave its assemblies
MAUI's XAML namespace attributes, whose types are in
Microsoft.Maui.Controls. Mono decodes them when it loads the assembly,
so an Android app without MAUI, such as one with the native
Microcharts.Droid view or with Slint, aborts at startup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Slint apps show a chart in an Image: ChartRenderer draws it with
SkiaSharp at the element's size in physical pixels, and hands the
premultiplied pixels to Slint. SlintTimer steps the animations on the
Slint thread. chart-view.slint has a ChartView that reports its size.

Microcharts.Samples.Slint shows the quickstart charts on the desktop,
Android, and iOS. Both reference Slint for .NET 1.19.0-preview.10, or
a Slint checkout with -p:SlintRepository=<path>.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@follesoe

Copy link
Copy Markdown
Contributor

Thanks for the PR @yurkinh, but we will not be accepting new front-end or UI frameworks for Microcharts. You are free to work on it and maintain it as you see fit to support Slint. I wish you all the best with your new UI framework built on top of .NET.

@follesoe follesoe closed this Nov 12, 2026
@yurkinh
yurkinh deleted the slint branch November 13, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants