The chart engine of the Aioros ecosystem, in pure C#.
Public preview. APIs can change between versions and it is not ready for production yet.
Aioros.Graphs gives you what charts are made of: arrays, scales, shapes, curves, paths, and number and time formats. It has no UI dependency. Shapes write path commands into a sink, and two sinks ship with it: SVG path data in UTF-8 for the web, and native geometry for the desktop.
Aioros.Pictor builds charts in XAML on top of it. Use this library directly if you want to build your own charts.
- The same output as d3. Every ported function is tested against fixtures generated by d3 itself: ticks, scale values and tick labels bit for bit, and SVG path data byte for byte.
- Built for speed. Hot paths use structs and spans, shapes are specialized at compile time for their curve and sink, and no allocation happens per point. On nineteen gallery charts it is 2.7 times faster than d3 on average. See Benchmarks.
dotnet add package Aioros.Graphs --version 0.1.0-preview.2
dotnet add package Aioros.Graphs.Svg --version 0.1.0-preview.2 # SVG path data, for the web
dotnet add package Aioros.Graphs.Avalonia --version 0.1.0-preview.2 # native geometry, for the desktopA line through five values, written as SVG path data:
using System.Buffers;
using System.Text;
using Aioros.Graphs.Scales;
using Aioros.Graphs.Shapes;
using Aioros.Graphs.Svg;
double[] data = [3, 8, 5, 9, 4];
var x = LinearScale.Create([0, data.Length - 1], [0, 960]);
var y = LinearScale.Create([0, 10], [500, 0]);
var xs = new double[data.Length];
var ys = new double[data.Length];
for (var i = 0; i < data.Length; i++)
{
xs[i] = x.Map(i);
ys[i] = y.Map(data[i]);
}
var buffer = new ArrayBufferWriter<byte>();
var svg = new SvgPathWriter(buffer);
Line.Write(ref svg, Curve.MonotoneX, xs, ys);
Console.WriteLine(Encoding.UTF8.GetString(buffer.WrittenSpan));
// M0,350C80,225,160,100,240,100C320,100,400,250,480,250C560,250,640,50,720,50C800,50,880,175,960,300To draw the same line natively, write it into a GeometrySink from Aioros.Graphs.Avalonia instead.
| Area | Covers |
|---|---|
| Arrays | Ticks, bisectors, extents, bins, quantiles and groups |
| Scales | Linear, log, power, symlog, radial, band, point, ordinal, quantize, time and more |
| Shapes | Lines, areas, arcs, pies, stacks, symbols and links, with every curve |
| Paths | path and pathRound |
| Formats | Numbers and times, in every locale d3 ships |
| Time | UTC and local intervals over an injectable time zone |
| Color | RGB, HSL, Lab, HCL and cubehelix, with interpolation and the d3 color schemes |
| Layouts | Hierarchies, treemaps, packing, partitions, chords, Sankey diagrams and forces |
| Axes | d3-axis as data, and as markup |
What each area does exactly is listed in the acceptance criteria, with one test per criterion.
| Project | Role |
|---|---|
src/Aioros.Graphs |
The engine, with no dependencies |
src/Aioros.Graphs.Svg |
Writes paths and axes as SVG |
src/Aioros.Graphs.Avalonia |
Writes paths into native geometry |
samples/Demo |
Nineteen d3 gallery charts drawn by the engine, next to d3's output for the same data |
tools/golden |
Generates the test fixtures from a pinned d3 |
dotnet build Aioros.Graphs.slnx
dotnet test --solution Aioros.Graphs.slnxThe SDK is pinned in global.json. See AGENTS.md for how changes are made, and the roadmap for what comes next.
MIT, as is the whole Aioros ecosystem: see LICENSE.
Aioros.Graphs is an independent port and is not affiliated with or endorsed by the d3 project. The ported code follows d3 (ISC) and d3-sankey (BSD-3-Clause), whose notices are in THIRD-PARTY-NOTICES.md and ship with every package.