ggnet
/ggnet
Generate charts with GGNet, the grammar-of-graphics plotting library for .NET/Blazor (C#, fluent DSL, SVG output). Use when creating, editing, or debugging plots in a C#/.NET/Blazor codebase that references GGNet — chart, plot, graph, dashboard, sparkline, histogram, heatmap, candlestick, choropleth requests included. Do NOT use for Plotly, Chart.js, ApexCharts, ScottPlot, matplotlib, or non-.NET charting.
- Author
- pablofrommars ↗
- Repository
- ggnet ↗
- Licence
- MIT
- Last repository change
- 21.10.2026
Assessment and security
- Files in this package
- 37
- Scripts
- 1
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 21.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
- 1 scripts in this package. Review them before installing, as Claude may execute them.
Scripts: scripts/validate.cs
What it does and when to use it
Generate charts with GGNet, the grammar-of-graphics plotting library for .NET/Blazor (C#, fluent DSL, SVG output). Use when creating, editing, or debugging plots in a C#/.NET/Blazor codebase that references GGNet — chart, plot, graph, dashboard, sparkline, histogram, heatmap, candlestick, choropleth requests included. Do NOT use for Plotly, Chart.js, ApexCharts, ScottPlot, matplotlib, or non-.NET charting.
Original author description
Generate charts with GGNet, the grammar-of-graphics plotting library for .NET/Blazor (C#, fluent DSL, SVG output). Use when creating, editing, or debugging plots in a C#/.NET/Blazor codebase that references GGNet — chart, plot, graph, dashboard, sparkline, histogram, heatmap, candlestick, choropleth requests included. Do NOT use for Plotly, Chart.js, ApexCharts, ScottPlot, matplotlib, or non-.NET charting.
How it works
- Mental model
- Decision flow
- The four DSL conventions
- Quick tables
- R ggplot2 → GGNet
- Prefer the MCP tools when registered
- Validate before you show
SKILL.md preview
---
name: ggnet
description: Generate charts with GGNet, the grammar-of-graphics plotting library for .NET/Blazor (C#, fluent DSL, SVG output). Use when creating, editing, or debugging plots in a C#/.NET/Blazor codebase that references GGNet — chart, plot, graph, dashboard, sparkline, histogram, heatmap, candlestick, choropleth requests included. Do NOT use for Plotly, Chart.js, ApexCharts, ScottPlot, matplotlib, or non-.NET charting.
---
# GGNet — grammar-of-graphics plots in C#/Blazor
GGNet (NuGet `GGNet`) is ggplot2-inspired but is **not** ggplot2: the API is one fluent C# chain, not `aes()` + `+` composition, and this skill documents the 2.0 surface (many 1.x parameter names are gone — see [patterns/common-mistakes.md](patterns/common-mistakes.md)).
## Mental model
```
PlotContext.Build(source, x, y) // data + default selectors
.Geom_*(...) // layers, configured in place (repeatable)
.Scale_*(...) // axes, legends, transforms
.Facet_*(...) // panels per group
.Title("...") .XLab("...") // labels (Markdown)
.Style() // terminal call → IPlotContext
```
Stats are **sources, not layers**: `Stat.Bin/Density/Count/Summary` return typed sources any geom draws unchanged (a histogram is `Stat.Bin` + `Geom_Bar` — there is no Histogram geom).
Minimal working example (verified — it is a pinned gallery test):
```csharp
var plot = PlotContext.Build(xy, i => i.X, i => i.Y).Geom_Point().Style();
```
Host in Blazor with `<Plot Context="plot" RenderMode="..." />` (`Width=720 Height=576 Theme="default"` defaults; a sparkline is a small `Width`/`Height` + `hide: true` scales + a theme — see [reference/theming.md](reference/theming.md)), or export headlessly: `await plot.AsStringAsync()` / `SaveAsync(path)` (pure SVG; `selfContained: true` embeds the theme CSS).
## Decision flow
1. **Data shape → chart**: follow [reference/chart-selection.md](reference/chart-selection.md) (functions vocabulary, leaf table with GGNet recipes, alternatives for unsupported charts, stat bridges, transforms).
2. **Chart → geoms + stats**: copy the matching example from [examples/](examples/) — every example is compile- and render-verified against the pinned gallery. Table below for orientation; details in [reference/geoms.md](reference/geoms.md) and [reference/stats.md](reference/stats.md).
3. **Mappings**: constants (`color:`, `fill:`, `size:`) paint the whole layer; `xxxBy:` mappings (`colorBy`, `fillBy`, `sizeBy`, `lineTypeBy`) are data-driven, train a scale, and feed the legend — create them with the matching `Scale_Color_Discrete`, `Scale_Fill_Continuous`, … call on the chain ([reference/scales.md](reference/scales.md)).
4. **Facets, scales, theme**: `Facet_Wrap`/`Facet_Grid` for small multiples; `Scale_X/Y_*` for limits, transforms (`_Log10`, `_Sqrt`), formatters; theming via CSS variables ([reference/theming.md](reference/theming.md)).
## The four DSL conventions
1. **`xxxBy` means data-driven.** The unsuffixed twin is a per-layer constant. Setting both is meaningful: the mapping wins for its own aesthetic; the constant still colors other aesthetics' legend swatches.
2. **Positional arguments stop at the selectors** (`x`, `y`, `ymin`, `open`, …). Every aesthetic, event, or option after them is passed **by name**.
3. **The vocabulary is SVG's**: `strokeWidth`, `opacity`, `fillOpacity`, `strokeColor`. `width`/`height` are geometric extent in *data units* (`Geom_Bar`, `Geom_Tile`, `Geom_Violin`).
4. **Interactivity is a uniform block**: data-mark geoms take `onclick`, `onmouseover`, `onmouseout`, and (where hovering makes sense) `tooltip`. Annotations (`Geom_ABLine/HLine/VLine/Text`) and statistical summaries (`Geom_Boxplot/Violin/RidgeLine`) take no event block.
## Quick tables
**Geoms** (canonical selectors → see reference/geoms.md for full signatures):
| Kind | Geoms |
|---|---|
| Marks | `Geom_Point`, `Geom_Line`, `Geom_Bar`, `Geom_Area`, `Geom_Ribbon`, `Geom_ErrorBar`, `Geom_Segment`, `Geom_Tile`, `Geom_Hex`, `Geom_Radar`, `Geom_Map` |
| Finance | `Geom_Candlestick`, `Geom_OHLC`, `Geom_Volume` |
| Summaries | `Geom_Boxplot` (x = measurements, y = category), `Geom_Violin` (width = density profile), `Geom_RidgeLine` |
| Annotations | `Geom_Text`, `Geom_ABLine`, `Geom_HLine`, `Geom_VLine` |
**Stats** (source-producing; grouped variants add `groupBy:` and prepend `Group` to the output):
| Stat | Output | Draw with |
|---|---|---|
| `Stat.Bin(src, sel, bins: 30)` | `Bin(Min, Mid, Max, Count, Density)` | `Geom_Bar(x: b => b.Mid, y: b => b.Count)` |
| `Stat.Density(src, sel, n: 512)` | `DensityPoint(At, Density)` | `Geom_Area`/`Geom_Line`, `Geom_Violin(width: d => d.Density)` |
| `Stat.Count(src, key)` | `Count<TKey>(Key, N)` | `Geom_Bar` over categories |
| `Stat.Summary(src, x, y)` | `Summary(X, Center, Lower, Upper)` | `Geom_ErrorBar(y: s => s.Center, ymin: s => s.Lower, ymax: s => s.Upper)` |
**Composition**: `Flip()` (bar stats follow the flip) · `Coord_Polar()` · `Facet_Wrap(sel, freeX, freeY, nrows, ncolumns)` · `Facet_Grid(row, col)` · `Panel(factory, w, h)` sub-plots · `XLim/YLim` · per-facet stats = `groupBy:` + facet **the same key**.
## R ggplot2 → GGNet
| R | GGNet |
|---|---|
| `ggplot(df, aes(x, y))` | `PlotContext.Build(items, i => i.X, i => i.Y)` |
| `+ geom_point(size = 3)` | `.Geom_Point(size: 3)` — chain, never `+` |
| `aes(color = grp)` | `.Scale_Color_Discrete(i => i.Grp, palette)` then `colorBy` is inherited |
| `geom_histogram(bins = 12)` | `Build(Stat.Bin(items, i => i.V, bins: 12), b => b.Mid, b => b.Count).Geom_Bar(width: 1.0)` |
| `geom_bar(position = "dodge")` | `.Geom_Bar(position: PositionAdjustment.Dodge)` |
| `facet_wrap(~ grp)` | `.Facet_Wrap(i => i.Grp)` |
| `scale_y_log10()` | `.Scale_Y_Log10()` |
| `coord_flip()` | `.Flip()` |
| `labs(title = ...)` | `.Title("...")` / `.XLab(...)` / `.YLab(...)` — Markdown allowed |
| `theme_minimal()` | no theme objects — CSS variables under `.ggnet[theme=name]` (reference/theming.md) |
## Prefer the MCP tools when registered
If the `ggnet` MCP server is available in your session (register with `claude mcp add ggnet -- dotnet run --project <repo>/src/GGNet.Mcp`), prefer its tools over the manual path — they are deterministic and read the live library:
- `select_chart` (pass raw `values`/`categories` samples — measured shape beats estimates) instead of hand-walking [reference/chart-selection.md](reference/chart-selection.md); present its caveats, `excluded` reasons, stat bridges and transforms verbatim.
- `list_geoms` / `list_scales` (reflected from the loaded assembly, never stale) to confirm signatures.
- `validate_plot` instead of the script below.
Without the server, the reference files and script below are the equivalent manual path — same vocabulary, same recipes.
## Validate before you show
After generating plot code, run the validator (compiles under warnings-as-errors and renders to SVG via GGNet.Headless; snippet contract in the script header — top-level statements ending in a render call):
```bash
dotnet run skills/ggnet/scripts/validate.cs -- path/to/Snippet.cs
```
If it fails, fix against [reference/](reference/) and [patterns/common-mistakes.md](patterns/common-mistakes.md) — do not guess parameter names; every documented signature is extracted from source.
Files in this package (37)
- SKILL.md 7 KB
- examples/annotated.md 1 KB
- examples/area.md 1 KB
- examples/barplot.md 1 KB
- examples/boxplot.md 1 KB
- examples/bubble-map.md 1 KB
- examples/bubble.md 1 KB
- examples/calendar-heatmap.md 1 KB
- examples/candlestick.md 1 KB
- examples/choropleth.md 1 KB
- examples/connected-scatter.md 1 KB
- examples/correlogram.md 1 KB
- examples/density.md 1 KB
- examples/grouped-barplot.md 1 KB
- examples/grouped-scatter.md 1 KB
- examples/heatmap.md 1 KB
- examples/hexbin.md 1 KB
- examples/histogram.md 1 KB
- examples/line.md 1 KB
- examples/lollipop.md 1 KB
- examples/radar.md 1 KB
- examples/ridgeline.md 1 KB
- examples/scatter.md 1 KB
- examples/slope.md 1 KB
- examples/small-multiples.md 1 KB
- examples/stacked-area.md 1 KB
- examples/stacked-barplot.md 1 KB
- examples/summary-errorbar.md 1 KB
- examples/themed.md 1 KB
- examples/violin.md 1 KB
- patterns/common-mistakes.md 11 KB
- reference/chart-selection.md 9 KB
- reference/geoms.md 9 KB
- reference/scales.md 5 KB
- reference/stats.md 10 KB
- reference/theming.md 4 KB
- scripts/validate.cs 2 KB
Versions
The database has no other skills named ggnet.
Database snapshot: 13.11.2026 · package version e77282237a97 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 1 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100productscope-charts
Build charts, dashboards and reports as plain SVG with the Product Scope Charts toolkit (no charting library, no dependencies, works under a strict Content-Security-Policy, accessible by default). Use it whenever the user wants a chart, graph, dashboard, KPI tiles, sparkline,… - 100plotagents
Make every chart, graph, plot, map, table or dashboard with the plotagents library (npm "plotagents"), one JSON spec in, a finished accessible SVG out. Use this skill whenever the user asks to chart, plot, graph or visualize data, build a dashboard, KPI tiles, a data table, a… - 100plotly
Plotly is an open-source charting library that draws interactive charts (hover, zoom, pan, export) from Python with plotly.py and Plotly Express, or in the browser with plotly.js. Use when a user asks to plot data with Plotly, make a scatter plot, line chart, bar chart, heatmap,… - 100charts
Draw a static chart, graph or plot as a PNG with seaborn in the house style (the shared palette, DM Sans, the slides' type sizes): bar, line, scatter, histogram, box, heatmap, small multiples. The default for any chart: use it whenever a chart, graph or plot is to be created… - 100data-charts
Analyze tabular data and render charts (bar, line, scatter, pie, histogram) to PNG/SVG with pandas + matplotlib. Use whenever the user wants to plot, chart, graph, or visualize data from a CSV/JSON/Excel file or inline numbers. - 91evidence-charts
Use when building or debugging Evidence.dev chart components — LineChart, BarChart, AreaChart, ScatterPlot, BubbleChart, Histogram, FunnelChart, Heatmap, CalendarHeatmap, BoxPlot, Sparkline, SankeyDiagram and custom ECharts.