UnitSelection

UnitSelection

A collection of zero or more Units.

UnitSelection.where([tags]) => UnitSelection

Get the Units in the collection that match the given tags.

Arguments

  • tags {Object}
    • Optional
    • Defaults to an empty object if nothing is passed, which would return all Units.
    • An object of key value pairs to filter by
      • key: Name of tag
      • value: The value of the tag

Returns

  • UnitSelection {Array}
    • The new collection

UnitSelection.find(id) => UnitSelection

Get all Units in the collection that match the given id/s.

Arguments

  • id {string|Array<string>}
    • A single id or an array of ids to look for.

Returns

  • UnitSelection {Array}
    • The new collection

UnitSelection.first() => UnitSelection

Get the first Unit in the collection.

Returns

  • UnitSelection {Array}
    • The new collection

UnitSelection.at(index) => UnitSelection

Get the Unit at the given index in the collection.

Arguments

  • index {integer}
    • The index of the desired Unit.

Returns

  • UnitSelection {Array}
    • The new collection

UnitSelection.color(color)

Set the fill color for each Unit in the collection. This method is chainable.

Arguments

  • color {string}
    • A valid CSS Color

UnitSelection.center() => Center

Get the center of the UnitSelection.

Returns

  • Center {Array}
    • First value is the value of the center on the x-axis.
    • Second value is the value of the center on the y-axis.

UnitSelection.data() => Data

Get the UnitSelection as a JSON payload.

Returns

  • Data {Object}
    • A JSON object

What’s Next