Items operations: adding and deleting

With DHTMLX Touch you can add and delete chart elements dynamically.

Let's consider it in details.

Adding

Initially, data is loaded by load() or parse() method.

But if you want to add additional data objects, you should use add() method. The method requires a data object with the needed properties:

chart.add({
    year: 2010,
    sales: 8.9 
});

You may also define an item index in the second parameter:

chart.add({
    year: 2010,
    sales: 8.9 
},10);

Deleting

remove() method deletes an item by its id:

chart.remove(id);

To delete all items in a chart you can use clearAll() method:

chart.clearAll();

Getting item id

If item's id is unknown, you can use idByIndex() method

var id = chart.idByIndex(10);

Moreover, there are first(), last(), next() and previous() methods.