Skip to content
geisha-langPublic

About

Zero-dependency Grammar of Graphics (ggplot2 + patchwork) visualization library for Geisha (SVG + cross-platform PNG)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

plot.gsa

Zero-dependency Grammar of Graphics (ggplot2 + patchwork) visualization library for Geisha, with Pure-Geisha SVG (native / wasm32 / iOS) and Cross-Platform PNG (macOS CoreGraphics/CoreText 2x Retina + Linux pure-C99 AA software rasterizer) backends.

Dual DSL Styles (Shared AST)

Style A — R ggplot2 + & patchwork | / /

use plot.plot.{
    ggplot, aes, x, y, color,
    geomLine, geomSmooth, geomHline,
    smoothLoess, se, lineWidth, dashed, dotted, colorHex,
    labs, subtitle, legendBottom, themeMinimal,
    saveSvg, savePng
}

let p = ggplot(tbl, aes([x("date"), y("nav"), color("asset")]))
    + geomLine([lineWidth(2.1)])
    + geomSmooth([smoothLoess(0.55), se(true), dashed()])
    + geomHline(100.0, [colorHex("#94A3B8"), dotted()])
    + labs("Asset NAV Curves", "Date", "NAV")
    + legendBottom()
    + themeMinimal();

let dashboard = vstackHeights([hstackWidths([pBox, pHeat], [1.1, 1.0]), pHist], [1.15, 0.95])
    + collectGuides()
    + plotAnnotation("Research Dashboard", "", "plot.gsa v0.1")
    + themeDark();

saveSvg(dashboard, 1080, 760, "dashboard.svg")?;
savePng(dashboard, 1080, 760, "dashboard.png")?;

Style B — Declarative List

let p = plot(tbl, [
    aes([x("f1"), y("f2"), fill("corr"), label("lbl")]),
    geomTile([]),
    geomText([colorHex("#0F172A"), textSize(11.0)]),
    scaleFillDiverging(),
    labs("Factor Correlation Matrix", "", ""),
    legendTitle("Corr"),
]);

Features (v0.1)

  • Zero External Package Dependencies: Pure-Geisha PlotTable / PlotCol (ColFloat, ColInt, ColStr, ColBool, ColTime) + open concept PlotSource with built-in instances for PlotTable, MutArray Float, List Float, (MutArray Float, MutArray Float), List (Float, Float), and List (String, Float). Works on native, wasm32, and ios.
  • 31 Geoms & Annotations:
    • Core: geomPoint, geomLine (sorted by x, breaks on NaN/Inf), geomPath (row-order), geomStep, geomArea, geomRibbon (grouped + breaks on NaN), geomCol, geomBar (true StatCount), geomHist (grouped count/density)
    • Distributions & Diagnostics: geomBoxplot (grouped/dodged), geomViolin (trimmed KDE + IQR/median), geomDensity (Silverman Gaussian KDE), geomEcdf, geomRug, geomQq (Normal Q-Q + reference line)
    • Intervals, 2D & Finance: geomErrorbar, geomLinerange, geomPointrange, geomTile (discrete & continuous step width), geomRect, geomSegment, geomArrow, geomCandlestick, geomOhlc
    • Reference, Text & Smoothing: geomHline, geomVline, geomAbline, geomText, geomLabel (pill background + nudge), geomSmooth (OLS / LOESS / Rolling + optional 95% SE band), annotateText, annotateRect, annotateSegment, annotateArrow
  • Positions: positionIdentity, positionDodge, positionStack, positionFill (100% stacked), positionJitter
  • Visual Channels & Guides: x, y, ymin/ymax, xmin/xmax, xend/yend, openPx/highPx/lowPx/closePx, independent color and fill scales (Okabe-Ito, Tableau10, Set2, Paired, Viridis, Plasma, Inferno, 0-anchored Diverging, RdYlGn, Grayscale, manual maps, 2/3-stop gradients), normalized size + bubble legend, shape (7 markers + legend), linetype (4 dash styles + legend), alphaCol, group, label
  • Scales & Secondary Axis: Linear, Log10, Symlog, Sqrt, Reverse, automatic UTC calendar Time scale, custom breaks & tick formats (FmtAuto, FmtFixed, FmtPercent, FmtCurrency, FmtSci, FmtCompact, FmtUnit, date/time formats), plus dual Y axis (secYAxisLinear, secYAxisAuto, onSecY)
  • Coords & Facets: coordFlip, coordFixed, coordCartesian (viewport zoom without clipping stats), coordPolar / coordPie / coordDonut, facetWrap (Fixed / FreeX / FreeY / Free), facetGrid(rowCol, colCol)
  • Patchwork & Themes: |, /, hstackWidths, vstackHeights, automatic panel edge alignment, collectGuides, plotAnnotation, 6 themes (Minimal, Gray, Bw, Dark, Classic, Void), and composable themeOpts overrides (legendBottom/Top/Left/Right, axisTextXAngle, grid toggles, spacing)
  • Backends: Pure-Geisha SVG (toSvg, saveSvg) + macOS CoreGraphics/CoreText 2x Retina PNG + Linux zero-dependency pure-C99 AA software PNG (savePng, savePngScale)

Zero-Copy tabular.gsa Bridge

Because plot.gsa has zero external dependencies, you can wrap a tabular.frame.DataFrame in 6 lines with zero array copies by passing its MutArray buffers directly into colFloat / colInt / colStr / colBool / tableFromCols.

Build & Test

MACOSX_DEPLOYMENT_TARGET=14.0 geisha check
MACOSX_DEPLOYMENT_TARGET=14.0 geisha test

About

Zero-dependency Grammar of Graphics (ggplot2 + patchwork) visualization library for Geisha (SVG + cross-platform PNG)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages