How gampleman/elm-visualization works
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.
Components 24
Elm visualization library
Composable exported modules under src/.
- Data preparation · Bins and summarizes source data before visualization.
src/Histogram.elm - Scales · Maps data domains to visual ranges and colors.
src/Scale.elm - Continuous scale
src/Scale/Continuous.elm - Band scale
src/Scale/Band.elm - Interpolation · Supports continuous values and transitions.
src/Interpolation.elm - Lab color
src/Color/Lab.elm - Shape generation · Generates lines, areas, arcs, pies, and stacks.
src/Shape.elm - Axis · Derives ticks and labels from scales.
src/Axis.elm - Force simulation · Composes forces to position graph nodes.
src/Force.elm - Collision force
src/Force/Collision.elm - Quadtree · Accelerates force and collision queries.
src/Force/QuadTree.elm - Hierarchy layout · Transforms trees into positioned and partitioned nodes.
src/Hierarchy.elm - Treemap layout
src/Hierarchy/Treemap.elm - Brush
src/Brush.elm - Zoom · Maintains and applies viewport transforms.
src/Zoom.elm - Events
src/Events.elm - Transition
src/Transition.elm
Consumer runtime
Application-owned rendering and state lifecycle.
- Application data
- Typed SVG/DOM package · Consumer-selected package owns DOM and SVG rendering.
- Elm update lifecycle · Consumes interaction messages and animation state.
Examples, docs, delivery
- Reference examples
examples/LineChart.elm - Documentation app
docs/Docs.elm - CI
.github/workflows/ci.yml - Netlify deployment
netlify.toml
Connections 25
- 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