MoonChartSVG is a zero-dependency SVG chart library written in pure MoonBit.
It provides builder APIs for bar, line, area, scatter, pie, donut, radar,
stacked bar, and horizontal bar charts.
render() returns a complete standalone <svg> document. It can be written
to a file, embedded in HTML, or composed with the included dashboard helpers.
Highlights
Nine chart types with a consistent builder API
Pure SVG output with no browser or runtime dependency
Automatic axis scaling and a built-in Tableau-style palette
Responsive multi-row legends for narrow canvases
XML escaping for titles, labels, colors, and generated attributes
Stable pie, donut, and radar coordinates across all angle quadrants
Defensive copies in builders so earlier chart values stay unchanged
Graceful handling of empty and non-positive pie or donut data
CSV parsing, descriptive statistics, themes, and HTML wrappers
Demo
moon run cmd/main
The command prints complete examples for every chart type, a composed SVG
dashboard, theme usage, and CSV-driven data.
Validation
moon check --deny-warn --target all
moon fmt --check
moon info --target all
moon test --deny-warn --target all
moon coverage analyze
The current MoonBit CLI does not accept --deny-warn for moon fmt or
moon info; moon fmt --check and a clean moon info run are the supported
equivalent checks. The current suite contains 93 tests.
Data Behavior
Pie and donut slices with values less than or equal to zero are ignored.
A pie or donut whose positive total is zero renders an empty SVG chart.
A single 100% pie uses two SVG half-arcs; a donut uses paired outer and
inner half-arcs so both render consistently across SVG engines.
Donut hole ratios are clamped to the range 0.0..0.95.
Radar grid levels are clamped to at least one.
Radar values missing from a series are rendered as zero.
CSV input supports quoted fields, escaped quotes, embedded newlines, and
CRLF records.
Empty statistical inputs return 0.0 instead of dividing by zero or
indexing an empty array.
User-provided SVG text and attributes are XML escaped.
License
Apache-2.0
关于
纯 MoonBit 实现的 SVG 图表生成库,支持9种图表类型,零依赖,Builder API 设计。
MoonChartSVG
MoonChartSVG is a zero-dependency SVG chart library written in pure MoonBit. It provides builder APIs for bar, line, area, scatter, pie, donut, radar, stacked bar, and horizontal bar charts.
Install
Quick Start
render()returns a complete standalone<svg>document. It can be written to a file, embedded in HTML, or composed with the included dashboard helpers.Highlights
Demo
The command prints complete examples for every chart type, a composed SVG dashboard, theme usage, and CSV-driven data.
Validation
The current MoonBit CLI does not accept
--deny-warnformoon fmtormoon info;moon fmt --checkand a cleanmoon inforun are the supported equivalent checks. The current suite contains 93 tests.Data Behavior
0.0..0.95.0.0instead of dividing by zero or indexing an empty array.License
Apache-2.0