Objects

Object

Object methods allow you to create, update and remove label and shape objects.

addobject

Adds one or more objects (labels or shapes) on the chart.

zingchart.exec('myid', 'addobject', {
  type: 'label',
  data: {
    id: 'label1',
    text: 'My Label',
    x: 200,
    y: 100
  }
});

Note: Must call repaintobjects after adding an object.

AttributeTypeInfo
dataMixed

The data containing the object definitions. It can be an object if just one item is added or an array of objects if many items are added at once.

{...} | [{...}, {...}, ...]

graphid (optional)Mixed

The id/index of the graph. The default is 0.

"mygraph" | 0 | 1 | ...

typeString

The type of the object.

"label" | "shape"

removeobject

Removes one or more objects (labels or shapes) from the chart.

zingchart.exec('myid', 'removeobject', { 
  type: 'label', 
  id: 'label1' 
});
https://app.zingsoft.com/demos/embed/CQVTABFQ
https://app.zingsoft.com/demos/embed/CQVTABFQ
AttributeTypeInfo
graphid (optional)Mixed

The id/index of the graph. The default is 0.

"mygraph" | 0 | 1 | ...

idMixed

The id's of the objects to remove. It can be a string in case one object is removed or an array if many objects are removed.

"label1" | ["label1", "label2", ...]

repaintobjects

Repaints all the object collection when previous object related API's were called using update: false

zingchart.exec('myid', 'repaintobjects', {});
https://app.zingsoft.com/demos/embed/OS64JOCW
https://app.zingsoft.com/demos/embed/OS64JOCW
AttributeTypeInfo
graphid (optional)Mixed

The id/index of the graph. The default is 0.

"mygraph" | 0 | 1 | ...

updateobject

Updates one or more objects (labels or shapes) of the chart.

zingchart.exec('myid', 'updateobject', { 
  type: 'label', 
  data: { 'id' : 'label1', 'background-color' : '\#f90' } 
});
https://app.zingsoft.com/demos/embed/H7F2UJ4L
https://app.zingsoft.com/demos/embed/H7F2UJ4L
AttributeTypeInfo
dataMixed

The data containing the object definitions. It can be an object if just one item is updated or an array of objects if many items are updated at once. The objects should be referenced by their id's.

{...} | [{...}, {...}, ...]

graphid (optional)Mixed

The id/index of the graph. The default is 0.

"mygraph" | 0 | 1 | ...