color_by_property

Colours nodes by the host property property (from the PropertyResolver), replacing any earlier colouring; selection still shows on top. categorical (default): distinct values in first-seen order over the sorted node ids, palette cycled. range: finite numbers mapped linearly over range (default min..max of the values) through the palette as a gradient; other values stay uncoloured. palette: linear RGB [r, g, b] in [0, 1]. nodeIds limits it to those nodes (unknown ids are ignored). Returns { property, mode, colors: { value, color }[], colored, uncolored }.

CommandAsync

Usage

TypeScript
await surface.executeAsync('color_by_property', { property, mode?, palette?, range?, nodeIds? })

Parameters

  • propertystring

    Required

  • mode"categorical" | "range"

    Optional

  • palettenumber[][]

    Optional

  • rangenumber[]

    [min, max], min <= max

    Optional

  • nodeIdsstring[]

    Optional

Returns

object with property, mode, colors, colored, uncolored, in the ok: true envelope.

JSON
{
  "type": "object",
  "properties": {
    "property": {
      "type": [
        "string",
        "null"
      ]
    },
    "mode": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "categorical",
        "range",
        null
      ]
    },
    "colors": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "value": {
            "description": "any JSON value"
          },
          "color": {
            "type": "array",
            "minItems": 3,
            "maxItems": 3,
            "items": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            }
          }
        },
        "required": [
          "value",
          "color"
        ]
      }
    },
    "colored": {
      "type": "integer",
      "minimum": 0
    },
    "uncolored": {
      "type": "integer",
      "minimum": 0
    }
  },
  "required": [
    "property",
    "mode",
    "colors",
    "colored",
    "uncolored"
  ]
}

See also