# nano-ui-diagrams
Charts and [diagrams](https://diagrams.github.io/) vector graphics for [nano-ui](https://github.com/goolord/nano-ui). Backend-agnostic: pair with any `nano-ui` backend to open a window.
`NanoUI.Plot` draws line, bar, scatter, area, and step charts with automatic axes, legends, hover inspection, and point decimation for large series. `NanoUI.Diagrams` re-exports `NanoUI.Plot` alongside `diagram`, which embeds any `diagrams-lib` `Diagram` inside a `nano-ui` layout.
```haskell
{-# LANGUAGE OverloadedStrings #-}
import Data.Text qualified as T
import NanoUI
import NanoUI.Plot
temperatures :: Chart
temperatures =
withTitle "Temperature" . withLegend LegendBottom $
chart
[ line "Indoor" [(0, 20), (1, 21.5), (2, 22), (3, 21)]
, line "Outdoor" [(0, 8), (1, 11), (2, 14), (3, 12)]
]
-- Allocate cache <- newPlotCache once during setup.
view :: PlotCache -> NanoUI ()
view cache = column $ do
resp <- plot cache (minH 240 . fillW) temperatures
case plotHover resp of
Just h -> label (T.pack (show (hoverDataX h, hoverDataY h)))
Nothing -> pure ()
```
Series points use data-space coordinates while the layout modifier passed to `plot` sizes the widget in logical pixels. Define static `Chart` values outside the per-frame view so `PlotCache` skips rebuilds between frames.
## Documentation
- [The nano-ui Book: Charts and Diagrams](https://goolord.github.io/nano-ui/book/packages/index.html#charts-and-diagrams): Chart types, styling, legends, hover readouts, and `diagram` examples.