Objects

live example

Explore the API in the live example.

api reference

Objects()
Component implementing the objects feature. This feature allows for inserting various SVG elements to the background of a chart. When this component is available for a widget, its API is exposed via the .objects namespace.
Objects.add(id, obj, pos, options[, duration])
Adds an SVG element to the widget using internal (data level) or widget coordinates.

Parameters

NameTypeDescription
idstringUnique identifier of the object to add. If an object with the ID already exists, it is updated with the new parameters.
objElementThe SVG HTML element to insert to the widget.
posObjectObject representing the x and y coordinates of the point to add the object at. The coordinates are used as the widget's internal (data) coordinates.
optionsObjectOptions of inserting the object. Supported values:
  • booleanlayer: Where to insert the object: background of the plot area, foreground of the plot area or outside. In case of foreground or background, the object is clipped by the plot region. Default value is outside.
  • booleanfloating: Whether to insert a floating object (position is used as data coordinates and the object position is updated when data changes) or fixed (position is used as coordinates relative to the widget's top left corner and does not change when data is updated). Set it to true if you want to insert objects using data coordinates and want them to follow the changes in data, otherwise leave it unset. Default sis false.
durationnumberoptionalDuration of the insert animation. Default value is 0.

Returns

Widget
Reference to the Widget's API.
Objects.remove(id[, duration])
Removes one or all objects from the widget.

Parameters

NameTypeDescription
idIdentifier of the object to remove. If not specified or null, all objects are removed.
durationnumberoptionalDuration of the removal animation. Default value is 0.

Returns

Widget
Reference to the Widget's API.
Objects.svg()
Returns a D3 selection to an invisible SVG that can be used to draw an object to add. Useful if you want to use D3's simple chainable API to create objects to add.

Returns

Selection
D3 selection to the Objects API SVG.