Hylograph.TreeDSL.ShapeTree
- Package
- purescript-hylograph-selection
- Repository
- afcondon/purescript-hylograph-selection
Hylograph.TreeDSL.ShapeTree - Heterogeneous Shape Rendering Extension
This module extends TreeDSL with support for rendering heterogeneous shapes - trees where nodes can be circles, rectangles, polygons, tables, or any other visual form depending on the data.
Usage
import Hylograph.TreeDSL.ShapeTree
myViz :: forall tree. ShapeTreeDSL tree => tree NodeData
myViz = joinData "nodes" "g" nodes $ \node ->
fromShapeSpec (_.shape) (nodeDimensions node)
Design
ShapeSpec is an ADT describing visual forms. Each constructor carries
the attributes needed to render that form. The fromShapeSpec method
takes a function that extracts a ShapeSpec from your datum.
This is an EXTENSION - it doesn't modify the core TreeDSL class. Interpreters opt-in by implementing ShapeTreeDSL.
#ShapeTreeDSL Source
class ShapeTreeDSL :: (Type -> Type) -> Constraintclass (TreeDSL tree) <= ShapeTreeDSL tree where
Extension for heterogeneous shape rendering.
This class adds the ability to render different visual forms based on a ShapeSpec extracted from each datum.
The dimensions function is required for layout - it tells
layout algorithms how much space each node needs.
Members
fromShapeSpec :: forall datum. (datum -> ShapeSpec datum) -> (datum -> Dimensions) -> tree datum
Instances
ShapeTreeDSL TreeShapeTreeDSL instance for Tree.
Implements shape rendering by converting to ConditionalRender. Each shape type becomes a predicate/spec pair.
#ShapeSpec Source
data ShapeSpec datumSpecification for a visual shape.
Each constructor represents a different visual form with its
own set of attributes. The datum parameter allows attributes
to be computed from data.
This is intentionally a closed ADT - it defines a "vocabulary" of visual primitives. Extensions can add new shape types by creating additional ShapeTreeDSL-like classes.
Constructors
CircleSpec { fill :: datum -> String, radius :: datum -> Number, stroke :: datum -> Maybe String, strokeWidth :: datum -> Maybe Number }RectSpec { cornerRadius :: datum -> Maybe Number, fill :: datum -> String, height :: datum -> Number, stroke :: datum -> Maybe String, strokeWidth :: datum -> Maybe Number, width :: datum -> Number }PolygonSpec { fill :: datum -> String, points :: datum -> String, stroke :: datum -> Maybe String, strokeWidth :: datum -> Maybe Number }TableSpec { cellFill :: datum -> String, cellPadding :: datum -> Number, headerFill :: datum -> String, rows :: datum -> Array (Array String), textColor :: datum -> String }GroupSpec { children :: Array (ShapeSpec datum) }
#Dimensions Source
type Dimensions = { height :: Number, width :: Number }Dimensions for layout calculations.
Layout algorithms need to know the size of each node before positioning them. This record provides that information.
#isCircleSpec Source
isCircleSpec :: forall d. ShapeSpec d -> Boolean#isRectSpec Source
isRectSpec :: forall d. ShapeSpec d -> Boolean#isPolygonSpec Source
isPolygonSpec :: forall d. ShapeSpec d -> Boolean#isTableSpec Source
isTableSpec :: forall d. ShapeSpec d -> Boolean#isGroupSpec Source
isGroupSpec :: forall d. ShapeSpec d -> Boolean#circleSpec Source
circleSpec :: forall d. { fill :: d -> String, radius :: d -> Number } -> ShapeSpec dCreate a circle spec with sensible defaults.
#polygonSpec Source
polygonSpec :: forall d. { fill :: d -> String, points :: d -> String } -> ShapeSpec dCreate a polygon spec with sensible defaults.
- Modules
- Data.
DependencyGraph - Hylograph.
AST - Hylograph.
Axis. Axis - Hylograph.
Brush - Hylograph.
Brush. FFI - Hylograph.
Brush. Types - Hylograph.
Classify - Hylograph.
Data. Graph - Hylograph.
Data. Graph. Algorithms - Hylograph.
Data. Node - Hylograph.
Data. Tree - Hylograph.
Expr. Animation - Hylograph.
Expr. Attr - Hylograph.
Expr. Datum - Hylograph.
Expr. Expr - Hylograph.
Expr. Friendly - Hylograph.
Expr. Integration - Hylograph.
Expr. Interpreter. CodeGen - Hylograph.
Expr. Interpreter. Eval - Hylograph.
Expr. Interpreter. Meta - Hylograph.
Expr. Interpreter. PureSVG - Hylograph.
Expr. Interpreter. SVG - Hylograph.
Expr. Path - Hylograph.
Expr. Path. Generators - Hylograph.
Expr. Sugar - Hylograph.
Expr. Units - Hylograph.
HATS - Hylograph.
HATS. Friendly - Hylograph.
HATS. InterpreterTick - Hylograph.
HATS. Transitions - Hylograph.
Interaction. Brush - Hylograph.
Interaction. Coordinated - Hylograph.
Interaction. Pointer - Hylograph.
Interaction. Zoom - Hylograph.
Internal. Attribute - Hylograph.
Internal. Behavior. FFI - Hylograph.
Internal. Behavior. Types - Hylograph.
Internal. Capabilities. Selection - Hylograph.
Internal. Capabilities. Transition - Hylograph.
Internal. FFI - Hylograph.
Internal. Selection. Join - Hylograph.
Internal. Selection. Operations - Hylograph.
Internal. Selection. Operations. Conversions - Hylograph.
Internal. Selection. Operations. Helpers - Hylograph.
Internal. Selection. Operations. Selection - Hylograph.
Internal. Selection. Query - Hylograph.
Internal. Selection. Types - Hylograph.
Internal. Transition. FFI - Hylograph.
Internal. Transition. Manager - Hylograph.
Internal. Transition. Scene - Hylograph.
Internal. Transition. Types - Hylograph.
Internal. Types - Hylograph.
Interpreter. D3 - Hylograph.
Interpreter. English - Hylograph.
Interpreter. Mermaid - Hylograph.
Interpreter. MetaAST - Hylograph.
Interpreter. SemiQuine - Hylograph.
Interpreter. SemiQuine. TreeToCode - Hylograph.
Interpreter. SemiQuine. Types - Hylograph.
Render - Hylograph.
Scale - Hylograph.
Scale. FP - Hylograph.
Shape. Arc - Hylograph.
Shape. Pie - Hylograph.
Shape. Polygon - Hylograph.
Tooltip - Hylograph.
Transform - Hylograph.
TreeDSL - Hylograph.
TreeDSL. ShapeTree - Hylograph.
Unified - Hylograph.
Unified. Attribute - Hylograph.
Unified. DataDSL - Hylograph.
Unified. Display - Hylograph.
Unified. Examples - Hylograph.
Unified. Join - Hylograph.
Unified. Sugar
Render a shape based on a specification extracted from datum.
Example: