Operations with Chart Data

Getting an Item's Value

Getting value of the year property

$$("chart").attachEvent("onItemClick", function(id){
    id = this.getItem(id).year;

Related sample:  Chart: Events

Adding Items

While adding an item, make use of the add() method and state new data as an object and position of the new item:

var counter = 12;
    function addNew () {

Additionally, you can define a counter that sets the starting position of the new items to observe dataset integrity.

Item Deletion

To delete an item you should pass its ID into the remove() function (zero-base numbering) or make use of first() and last() methods to delete first and last items from the dataset.

$$("barChart").remove(4); // the 5th item will be removed
function deleteFirst(){

Related sample:  Chart: Adding/Deleting Data Items

Study the corresponding chapter of the manual to learn more about adding and deleting of items.

Sort Data

Here you use a sort() method that takes property from the initial dataset and sorting manner (ascending or descending) as parameters.


Related sample:  Chart: Sorting

Sort method in API Reference

Filter Data

As a rule, filter() method takes a function as parameter. In the function you specify the data you want to be filtered.

Make the chart show you only sales exceeding 50.

function filter1(){
        return obj.sales >50;

Related sample:  Chart: Filtering

Rules of Data Filtering

Back to top