Hylograph.Interaction.Coordinated
- Package
- purescript-hylograph-selection
- Repository
- afcondon/purescript-hylograph-selection
Unified Coordinated Interaction Framework
This module provides a unified approach to coordinated interactions across multiple visualization components. It extends the existing CoordinatedHighlight pattern to support:
- Hover: Highlight related elements across views (existing pattern)
- Brush: Select elements within a region
- Selection: Discrete set of selected items
- Focus: Single focused item (e.g., clicked node)
Design Principles
- Declarative: Components declare how they respond to interactions
- Composable: Multiple interaction types can coexist
- Framework-agnostic: Works with Halogen, React, or vanilla JS
- Type-safe: PureScript types ensure correct usage
Example
-- Component A: Scatter plot
registerCoordinated scatterElement
{ identify: _.id
, respond: \trigger datum -> case trigger of
HoverTrigger id -> if datum.id == id then Primary else Dimmed
BrushTrigger box -> if inBox datum box then Selected else Neutral
_ -> Neutral
, group: Just "linked-views"
}
-- Component B: Bar chart (same group, responds to same triggers)
registerCoordinated barElement
{ identify: _.category
, respond: \trigger datum -> ...
, group: Just "linked-views"
}
#InteractionTrigger Source
data InteractionTriggerWhat triggered the interaction
All components in a group receive the same trigger and respond based on their relationship to the triggering element/region.
Constructors
HoverTrigger StringBrushTrigger BoundingBoxSelectionTrigger (Set String)FocusTrigger (Maybe String)ClearTrigger
Instances
#BoundingBox Source
type BoundingBox = { x0 :: Number, x1 :: Number, y0 :: Number, y1 :: Number }Bounding box for brush selections
Coordinates are in the local coordinate system of the visualization.
#emptyBox Source
emptyBox :: BoundingBoxEmpty bounding box (for clearing brush)
#InteractionState Source
data InteractionStateHow an element responds to the current interaction
CSS classes are applied based on state:
- Primary →
.coord-primary - Related →
.coord-related - Selected →
.coord-selected - Dimmed →
.coord-dimmed - Neutral → no class change
Constructors
Instances
#isHighlighted Source
isHighlighted :: InteractionState -> BooleanCheck if state represents any kind of highlighting
#isSelected Source
isSelected :: InteractionState -> BooleanCheck if state represents selection
#CoordinatedConfig Source
type CoordinatedConfig datum = { group :: Maybe String, identify :: datum -> String, position :: Maybe (datum -> { x :: Number, y :: Number }), respond :: InteractionTrigger -> datum -> InteractionState }Configuration for coordinated interaction behavior
The respond function is called for every element when any interaction
occurs. It should be pure and fast since it runs on every hover/brush.
#simpleHover Source
simpleHover :: forall datum. (datum -> String) -> CoordinatedConfig datumSimple hover-only configuration
Elements are Primary when hovered, Dimmed when something else is hovered, Neutral when nothing is hovered.
#withBrush Source
withBrush :: forall datum. (datum -> { x :: Number, y :: Number }) -> CoordinatedConfig datum -> CoordinatedConfig datumAdd brush support to a configuration
Elements inside the brush region become Selected.
#withSelection Source
withSelection :: forall datum. CoordinatedConfig datum -> CoordinatedConfig datumAdd discrete selection support to a configuration
Elements whose ID is in the selection set become Selected.
#CoordinatedHandle Source
data CoordinatedHandleHandle for managing coordinated interaction registration
Use to unregister when component unmounts.
#registerCoordinated Source
registerCoordinated :: forall datum. Element -> CoordinatedConfig datum -> Effect (Effect Unit)Register an element for coordinated interactions
Returns an Effect that unregisters the element when called.
unregister <- registerCoordinated element config
-- Later, on unmount:
unregister
#emitTrigger Source
emitTrigger :: Maybe String -> InteractionTrigger -> Effect UnitEmit a trigger to all elements in a group
Used by brush handlers to dispatch brush regions.
#clearInteractions Source
clearInteractions :: Maybe String -> Effect UnitClear all interaction state in a group
#mkHoverTrigger Source
mkHoverTrigger :: String -> InteractionTriggerCreate a HoverTrigger
#mkBrushTrigger Source
mkBrushTrigger :: BoundingBox -> InteractionTriggerCreate a BrushTrigger
#mkClearTrigger Source
mkClearTrigger :: InteractionTriggerCreate a ClearTrigger
#mkFocusTrigger Source
mkFocusTrigger :: Maybe String -> InteractionTriggerCreate a FocusTrigger
#pointInBox Source
pointInBox :: { x :: Number, y :: Number } -> BoundingBox -> BooleanTest if a point is inside a bounding box
#boxesOverlap Source
boxesOverlap :: BoundingBox -> BoundingBox -> BooleanTest if two bounding boxes overlap
- 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