Module

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

    Render a shape based on a specification extracted from datum.

    Example:

    joinData "nodes" "g" nodes $ \node ->
      fromShapeSpec
        (_.visual)  -- extract ShapeSpec from datum
        (\d -> { width: 50.0, height: 50.0 })  -- dimensions for layout
    

Instances

  • ShapeTreeDSL Tree

    ShapeTreeDSL instance for Tree.

    Implements shape rendering by converting to ConditionalRender. Each shape type becomes a predicate/spec pair.

#ShapeSpec Source

data ShapeSpec datum

Specification 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

#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 d

Create a circle spec with sensible defaults.

#rectSpec Source

rectSpec :: forall d. { fill :: d -> String, height :: d -> Number, width :: d -> Number } -> ShapeSpec d

Create a rect spec with sensible defaults.

#polygonSpec Source

polygonSpec :: forall d. { fill :: d -> String, points :: d -> String } -> ShapeSpec d

Create a polygon spec with sensible defaults.

#tableSpec Source

tableSpec :: forall d. { rows :: d -> Array (Array String) } -> ShapeSpec d

Create a table spec with sensible defaults.

#groupSpec Source

groupSpec :: forall d. Array (ShapeSpec d) -> ShapeSpec d

Create a group spec (container for multiple shapes).

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