Block: Legend

A Legend block for configuring a coloured legend to be displayed in the user interface.

Overview

A Legend block is used for configuring a colour legend, to be displayed within a frame. The legend displays a set of colours with labels, in a vertical orientation.

Two types of legends can be generated: categorical and staggered.

  • A categorical legend is typically used to define a set of distinct colors representing different categories.
  • A staggered legend is typically used to define a series of colors along a gradient, representing continuous values.

Rather than statically configuring the legend colors and values, it is also possible to generate them dynamically from a Grasshopper model. For this, the legend must subscribe to a Model block, and the model needs to output the required legend data in a JSON structure.

For more information, see the Workbench documentation how-to guide on adding legends.

Example

Below is an example configuration.

kind: Solution
version: v0
router:
  kind: Router
  routes:
    - frame: home-frame
frames:
  home-frame:
    kind: Frame
    layout:
      kind: ColumnLayout
      widths: [300px, 1fr, 300px]
      areas: [my-control-panel, my-viewer, my-legend]
    contents:
      my-control-panel:
        kind: ControlPanel
        controls:
          height:
            kind: Slider
            value: 10
            min: 5
            max: 30
            precision: 1
      my-model:
        kind: Model
        modelFile: my-grasshopper-model.gh
        subscribe:
          - kind: ControlPanel
            frame: home-frame
            source: my-control-panel
      my-legend:
        kind: Legend
        type: Categorical
        subscribe:
          - kind: Model
            frame: home-frame
            source: my-model
            legend: my-output-component

LegendConfig

Name Type Required Description
kind "Legend" Yes Legend
labels List<string> No
colours List<List<number» No
type "Categorical" | "Staggered" No
subscribe List<LegendModelSubscription> No A list of objects for subscribing the Legend block to other blocks.

LegendModelSubscription

An object for configuring a subscription from a Legend block to a Model block. The subscription allows the legend colours and labels to be set based on the output of a Grasshopper model.

Name Type Required Description
kind "Model" Yes A constant, Model.
frame string Yes A string specifying the name of the frame in which the Model is located.
source string Yes A string specifying the name of the Model.
legend string Yes A string specifying a name of a Packhunt Data Output component in the Grasshopper model that outputs a JSON object containing the legend colours and labels.