Type-safe D3 selection and attribute library for PureScript.
A declarative, type-safe approach to D3.js visualization in PureScript. Instead of imperative D3 method chaining, you build a HATS tree that describes your visualization, then render it.
spago install hylograph-selectionBuild visualizations as data structures using HATS:
import Hylograph.HATS as H
import Hylograph.HATS.Friendly as HF
import Hylograph.Expr.Friendly (width, height, cx, cy, r, fill, num, text)
import Hylograph.HATS.InterpreterTick (rerender)
myViz :: H.Tree
myViz =
HF.svg [ width $ num 400.0, height $ num 300.0 ]
[ HF.circle
[ cx $ num 200.0
, cy $ num 150.0
, r $ num 50.0
, fill $ text "steelblue"
]
]
main :: Effect Unit
main = void $ rerender "#chart" myVizGenerate elements from data with Array.map:
barChart :: Array Number -> H.Tree
barChart dataset =
HF.svg [ width $ num 400.0, height $ num 300.0 ]
(dataset # Array.mapWithIndex \i val ->
HF.rect
[ x $ num (toNumber i * 50.0)
, y $ num (300.0 - val)
, width $ num 40.0
, height $ num val
, fill $ text "steelblue"
])- D3 Interpreter (
Hylograph.HATS.InterpreterTick) - Renders to DOM - English Interpreter - Describes the tree in plain English
- Mermaid Interpreter - Generates Mermaid diagrams
- SemiQuine Interpreter - Generates PureScript code
- MetaHATS Interpreter - Meta-visualization of tree structure
Hylograph.HATS- Tree types and constructorsHylograph.HATS.Friendly- User-friendly element helpers (svg, circle, rect, etc.)Hylograph.HATS.InterpreterTick- DOM rendering (rerender, rerenderInto)Hylograph.Render- Selection-based rendering utilities
Hylograph.Expr.Friendly- Attribute helpers (width, cx, fill, num, text, etc.)Hylograph.Expr.Attr- Low-level attribute typesHylograph.Expr.Sugar- Convenience functions
Hylograph.Interpreter.D3- D3.js selection operationsHylograph.Interpreter.English- Plain English descriptionHylograph.Interpreter.Mermaid- Mermaid diagram generationHylograph.Interpreter.SemiQuine- Code generationHylograph.Interpreter.MetaHATS- Tree meta-visualization
Hylograph.Interaction.Zoom- Zoom behaviorHylograph.Interaction.Brush- Brush selectionHylograph.Interaction.Pointer- Pointer eventsHylograph.Interaction.Coordinated- Coordinated highlighting
Hylograph.Scale- D3-style scalesHylograph.Transform- SVG transformsHylograph.Tooltip- Tooltip helpers
- hylograph-selection - D3 selection library (this package)
- hylograph-graph - Graph data structures
- hylograph-layout - Layout algorithms
- hylograph-simulation - Force simulation
Uses tree-rose for rose tree data structures.
MIT
