Getting the value of **year** property
$$("chart").attachEvent("onItemClick", function(id){
id = this.getItem(id).year;
alert(id);
});
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 () {
$$("barChart").add({
year:"'"+counter,
sales:"some_value"
});
counter++;
}
Additionally, you can sefine a counter that sets the starting position of the new items to observe dataset integrity.
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(){
$$("barChart").remove($$("barChart").getFirstId());
}
Related sample: Chart: Adding/Deleting Data Items
Study the corresponding chapter of the manual to learn more about adding and deleting of items.
Here you use a sort() method that takes property from the initial dataset and sorting manner (ascending or descending) as parameters.
$$('chart').sort('#year#','desc');
Related sample: Chart: Sorting
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(){
$$('chart').filter(function(obj){
return obj.sales >50;
});
}
Related sample: Chart: Filtering
Back to top