DHTMLX Docs & Samples Explorer

Adding and Deleting

With DhtmlxChart you can add and delete chart elements dynamically.

Let's consider it in details.


Initially data are 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 necessary properties:

    year: 2010,
    sales: 8.9 

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

    year: 2010,
    sales: 8.9 


The remove() method deletes an item by its id:


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


Getting item id

If item id is unknown, you can use the idByIndex() method:

     var id = chart.idByIndex(10);

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

An example that uses mentioned above methods you can see here.