# gampleman/elm-visualization architecture

> Architecture diagram of the GitHub repository gampleman/elm-visualization, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gampleman/elm-visualization
- Repository: https://github.com/gampleman/elm-visualization

## Overview

#### Purpose and Package Boundary
`elm-visualization` is an Elm library of composable data-visualization primitives, not a prebuilt charting framework. Consumers retain rendering ownership (typically SVG through external Elm packages) and compose this package’s data transforms, layout algorithms, interaction state, and path/axis generation. Library modules are rooted in `src/`; package metadata is `elm.json`.

#### Public Building Blocks
Scales convert data domains into visual ranges and are the central bridge from data to geometry/color: `src/Scale.elm`, `src/Scale/Continuous.elm`, `src/Scale/Band.elm`. Axis derives tick and label geometry from scales in `src/Axis.elm`. Shape generation creates chart paths and derived series geometry—lines/areas, arcs/pies, and stacks—through `src/Shape.elm`, `src/Shape/Generators.elm`, `src/Shape/Pie.elm`.

#### Data Preparation and Analysis
Data can be reduced before rendering with histogram binning and statistical functions: `src/Histogram.elm`, `src/Histogram/Array.elm`, `src/Statistics.elm`. Color-space and generic interpolation support continuous color/value mapping and intermediate values: `src/Color/Lab.elm`, `src/Interpolation.elm`. These modules are pure transformations; application code supplies source data and decides how results become DOM/SVG.

#### Layout Engines
Force simulation lays out graph nodes using composable physical forces, collision handling, and a quadtree acceleration structure: `src/Force.elm`, `src/Force/Collision.elm`, `src/Force/QuadTree.elm`. Hierarchical layouts transform trees into node positions and partitions for tidy trees, treemaps, and sunbursts: `src/Hierarchy.elm`, `src/Hierarchy/Tidy.elm`, `src/Hierarchy/Treemap.elm`.

#### Interaction, View State, and Animation
Interactive selection is modeled by brush operations in `src/Brush.elm`. Pan/zoom maintains and applies transforms via `src/Zoom.elm`, `src/Zoom/Transform.elm`, and `src/Zoom/Matrix.elm`. Event helpers in `src/Events.elm` connect rendered elements to Elm application messages. Animation is composed from interpolation and transition orchestration in `src/Transition.elm` and `src/Interpolation.elm`; consumers integrate outputs into their Elm `update`/subscription lifecycle.

#### Integration Flow and Runtime Boundaries
A typical consumer flow is: ingest application data → aggregate/layout (`Histogram`, `Statistics`, `Hierarchy`, or `Force`) → map values through `Scale` → generate axes/shapes → render with an external typed SVG/DOM package → feed pointer events through `Events`, `Brush`, or `Zoom` back into Elm state. The package itself has no backend, database, or browser-side service dependency. Material ecosystem boundaries named by the project are Elm runtime/compiler plus external packages for `Color`, typed SVG rendering, SVG path types, and rose trees.

#### Executable Entry Points and Delivery
There is no single application entry point; exported `src` modules are the product. Runnable reference applications are individual Elm example modules such as `examples/LineChart.elm`, `examples/ForceDirectedGraph.elm`, and `examples/Treemap.elm`, configured by `examples/elm.json`. Documentation is an Elm application rooted at `docs/Docs.elm` with `docs/elm.json`; examples/docs are deployed through Netlify configuration in `netlify.toml`. CI is defined in `.github/workflows/ci.yml`.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_library["Elm visualization library"]
  node_analysis["Data preparation<br/>histogram &amp; statistics<br/>[Histogram.elm]"]
  node_scales["Scales<br/>value mapping<br/>[Scale.elm]"]
  node_continuous["Continuous scale<br/>scale implementation<br/>[Continuous.elm]"]
  node_band["Band scale<br/>scale implementation<br/>[Band.elm]"]
  node_interpolation["Interpolation<br/>[Interpolation.elm]"]
  node_color["Lab color<br/>color space<br/>[Lab.elm]"]
  node_shapes["Shape generation<br/>paths &amp; series geometry<br/>[Shape.elm]"]
  node_axis["Axis<br/>tick geometry<br/>[Axis.elm]"]
  node_force["Force simulation<br/>graph layout<br/>[Force.elm]"]
  node_collision["Collision force<br/>force primitive<br/>[Collision.elm]"]
  node_quadtree["Quadtree<br/>spatial index<br/>[QuadTree.elm]"]
  node_hierarchy["Hierarchy layout<br/>tree layout<br/>[Hierarchy.elm]"]
  node_treemap["Treemap layout<br/>hierarchy algorithm<br/>[Treemap.elm]"]
  node_brush["Brush<br/>selection state<br/>[Brush.elm]"]
  node_zoom["Zoom<br/>[Zoom.elm]"]
  node_events["Events<br/>Elm event helpers<br/>[Events.elm]"]
  node_transition["Transition<br/>animation orchestration<br/>[Transition.elm]"]
end

subgraph group_consumer["Consumer runtime"]
  node_input["Application data<br/>consumer data"]
  node_svg["Typed SVG/DOM package<br/>external renderer"]
  node_elm_state["Elm update lifecycle<br/>consumer state"]
end

subgraph group_delivery["Examples, docs, delivery"]
  node_examples["Reference examples<br/>Elm applications<br/>[LineChart.elm]"]
  node_docs["Documentation app<br/>Elm application<br/>[Docs.elm]"]
  node_ci["CI<br/>GitHub Actions<br/>[ci.yml]"]
  node_netlify["Netlify deployment<br/>deployment config<br/>[netlify.toml]"]
end

node_input -->|"aggregate"| node_analysis
node_input -->|"graph data"| node_force
node_input -->|"tree data"| node_hierarchy
node_analysis -->|"prepared values"| node_scales
node_scales -->|"implements"| node_continuous
node_scales -->|"implements"| node_band
node_interpolation -->|"interpolates"| node_color
node_scales -->|"tick source"| node_axis
node_scales -->|"visual coordinates"| node_shapes
node_force -->|"uses"| node_collision
node_force -->|"accelerates with"| node_quadtree
node_hierarchy -->|"layout algorithm"| node_treemap
node_force -->|"positioned nodes"| node_shapes
node_hierarchy -->|"positioned partitions"| node_shapes
node_axis -->|"render geometry"| node_svg
node_shapes -->|"render paths"| node_svg
node_svg -->|"pointer events"| node_events
node_events -->|"messages"| node_elm_state
node_brush -->|"selection updates"| node_elm_state
node_zoom -->|"transform updates"| node_elm_state
node_transition -->|"animation values"| node_elm_state
node_interpolation -->|"interpolation"| node_transition
node_examples -.->|"demonstrates rendering"| node_svg
node_docs -->|"deployed by"| node_netlify
node_examples -->|"deployed by"| node_netlify

click node_analysis "https://github.com/gampleman/elm-visualization/blob/master/src/Histogram.elm"
click node_scales "https://github.com/gampleman/elm-visualization/blob/master/src/Scale.elm"
click node_continuous "https://github.com/gampleman/elm-visualization/blob/master/src/Scale/Continuous.elm"
click node_band "https://github.com/gampleman/elm-visualization/blob/master/src/Scale/Band.elm"
click node_interpolation "https://github.com/gampleman/elm-visualization/blob/master/src/Interpolation.elm"
click node_color "https://github.com/gampleman/elm-visualization/blob/master/src/Color/Lab.elm"
click node_shapes "https://github.com/gampleman/elm-visualization/blob/master/src/Shape.elm"
click node_axis "https://github.com/gampleman/elm-visualization/blob/master/src/Axis.elm"
click node_force "https://github.com/gampleman/elm-visualization/blob/master/src/Force.elm"
click node_collision "https://github.com/gampleman/elm-visualization/blob/master/src/Force/Collision.elm"
click node_quadtree "https://github.com/gampleman/elm-visualization/blob/master/src/Force/QuadTree.elm"
click node_hierarchy "https://github.com/gampleman/elm-visualization/blob/master/src/Hierarchy.elm"
click node_treemap "https://github.com/gampleman/elm-visualization/blob/master/src/Hierarchy/Treemap.elm"
click node_brush "https://github.com/gampleman/elm-visualization/blob/master/src/Brush.elm"
click node_zoom "https://github.com/gampleman/elm-visualization/blob/master/src/Zoom.elm"
click node_events "https://github.com/gampleman/elm-visualization/blob/master/src/Events.elm"
click node_transition "https://github.com/gampleman/elm-visualization/blob/master/src/Transition.elm"
click node_examples "https://github.com/gampleman/elm-visualization/blob/master/examples/LineChart.elm"
click node_docs "https://github.com/gampleman/elm-visualization/blob/master/docs/Docs.elm"
click node_ci "https://github.com/gampleman/elm-visualization/blob/master/.github/workflows/ci.yml"
click node_netlify "https://github.com/gampleman/elm-visualization/blob/master/netlify.toml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_analysis,node_scales,node_continuous,node_band,node_interpolation,node_color,node_shapes,node_axis,node_force,node_collision,node_quadtree,node_hierarchy,node_treemap,node_brush,node_zoom,node_events,node_transition toneBlue
class node_input,node_svg,node_elm_state toneAmber
class node_examples,node_docs,node_ci,node_netlify toneMint
```

## Components

### Elm visualization library

Composable exported modules under src/.

- [Data preparation](https://github.com/gampleman/elm-visualization/blob/master/src/Histogram.elm): histogram & statistics · Bins and summarizes source data before visualization. · `src/Histogram.elm`
- [Scales](https://github.com/gampleman/elm-visualization/blob/master/src/Scale.elm): value mapping · Maps data domains to visual ranges and colors. · `src/Scale.elm`
- [Continuous scale](https://github.com/gampleman/elm-visualization/blob/master/src/Scale/Continuous.elm): scale implementation · `src/Scale/Continuous.elm`
- [Band scale](https://github.com/gampleman/elm-visualization/blob/master/src/Scale/Band.elm): scale implementation · `src/Scale/Band.elm`
- [Interpolation](https://github.com/gampleman/elm-visualization/blob/master/src/Interpolation.elm): value interpolation · Supports continuous values and transitions. · `src/Interpolation.elm`
- [Lab color](https://github.com/gampleman/elm-visualization/blob/master/src/Color/Lab.elm): color space · `src/Color/Lab.elm`
- [Shape generation](https://github.com/gampleman/elm-visualization/blob/master/src/Shape.elm): paths & series geometry · Generates lines, areas, arcs, pies, and stacks. · `src/Shape.elm`
- [Axis](https://github.com/gampleman/elm-visualization/blob/master/src/Axis.elm): tick geometry · Derives ticks and labels from scales. · `src/Axis.elm`
- [Force simulation](https://github.com/gampleman/elm-visualization/blob/master/src/Force.elm): graph layout · Composes forces to position graph nodes. · `src/Force.elm`
- [Collision force](https://github.com/gampleman/elm-visualization/blob/master/src/Force/Collision.elm): force primitive · `src/Force/Collision.elm`
- [Quadtree](https://github.com/gampleman/elm-visualization/blob/master/src/Force/QuadTree.elm): spatial index · Accelerates force and collision queries. · `src/Force/QuadTree.elm`
- [Hierarchy layout](https://github.com/gampleman/elm-visualization/blob/master/src/Hierarchy.elm): tree layout · Transforms trees into positioned and partitioned nodes. · `src/Hierarchy.elm`
- [Treemap layout](https://github.com/gampleman/elm-visualization/blob/master/src/Hierarchy/Treemap.elm): hierarchy algorithm · `src/Hierarchy/Treemap.elm`
- [Brush](https://github.com/gampleman/elm-visualization/blob/master/src/Brush.elm): selection state · `src/Brush.elm`
- [Zoom](https://github.com/gampleman/elm-visualization/blob/master/src/Zoom.elm): pan/zoom state · Maintains and applies viewport transforms. · `src/Zoom.elm`
- [Events](https://github.com/gampleman/elm-visualization/blob/master/src/Events.elm): Elm event helpers · `src/Events.elm`
- [Transition](https://github.com/gampleman/elm-visualization/blob/master/src/Transition.elm): animation orchestration · `src/Transition.elm`

### Consumer runtime

Application-owned rendering and state lifecycle.

- **Application data**: consumer data
- **Typed SVG/DOM package**: external renderer · Consumer-selected package owns DOM and SVG rendering.
- **Elm update lifecycle**: consumer state · Consumes interaction messages and animation state.

### Examples, docs, delivery

- [Reference examples](https://github.com/gampleman/elm-visualization/blob/master/examples/LineChart.elm): Elm applications · `examples/LineChart.elm`
- [Documentation app](https://github.com/gampleman/elm-visualization/blob/master/docs/Docs.elm): Elm application · `docs/Docs.elm`
- [CI](https://github.com/gampleman/elm-visualization/blob/master/.github/workflows/ci.yml): GitHub Actions · `.github/workflows/ci.yml`
- [Netlify deployment](https://github.com/gampleman/elm-visualization/blob/master/netlify.toml): deployment config · `netlify.toml`

## Connections

- Application data → Data preparation: aggregate
- Application data → Force simulation: graph data
- Application data → Hierarchy layout: tree data
- Data preparation → Scales: prepared values
- Scales → Continuous scale: implements
- Scales → Band scale: implements
- Interpolation → Lab color: interpolates
- Scales → Axis: tick source
- Scales → Shape generation: visual coordinates
- Force simulation → Collision force: uses
- Force simulation → Quadtree: accelerates with
- Hierarchy layout → Treemap layout: layout algorithm
- Force simulation → Shape generation: positioned nodes
- Hierarchy layout → Shape generation: positioned partitions
- Axis → Typed SVG/DOM package: render geometry
- Shape generation → Typed SVG/DOM package: render paths
- Typed SVG/DOM package → Events: pointer events
- Events → Elm update lifecycle: messages
- Brush → Elm update lifecycle: selection updates
- Zoom → Elm update lifecycle: transform updates
- Transition → Elm update lifecycle: animation values
- Interpolation → Transition: interpolation
- Reference examples → Typed SVG/DOM package: demonstrates rendering
- Documentation app → Netlify deployment: deployed by
- Reference examples → Netlify deployment: deployed by
