Update Properties

Set properties to define the appearance and behavior of visual objects.

msc.sortChildren(elem, property, descending, orderedVals)

Sorts the children of a group or the vertices of a path by a data attribute or a channel.

  • elem: Group or Path
  • property: a data attribute name or a channel (e.g., "x", "y", "width", "height")
  • descending (Boolean, optional): whether to sort in descending order
  • orderedVals (Array, optional): explicit ranking of string attribute values to sort by
  • Return type: void

msc.translate(elem, dx, dy)

Moves an element by the given offsets along the x and y axes.

  • elem: Mark, Group, vertex, or segment
  • dx (Number): offset along the x axis
  • dy (Number): offset along the y axis
  • Return type: void

msc.update(target, patch)

Updates the properties of an element or a layout. If peer elements share the same class ID they are updated together.

  • target: Mark, Group, vertex, segment, or layout
  • patch (Object): properties to update, where each key is a channel (e.g., "x", "y", "width", "height", "radius"), a style (e.g., "fillColor", "opacity"), or "layout"
  • Return type: void