DHTMLX Docs & Samples Explorer

Adding

Source
<script src="../../codebase/dhtmlxchart.js" type="text/javascript"></script>
<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxchart.css">
<script>
var data = [{
    sales: "3.0",
    year: "2000"
}, {
    sales: "3.8",
    year: "2001"
}, {
    sales: "3.4",
    year: "2002"
}, {
    sales: "4.1",
    year: "2003"
}, {
    sales: "4.3",
    year: "2004"
}, {
    sales: "9.9",
    year: "2005"
}, {
    sales: "7.4",
    year: "2006"
}, {
    sales: "9.0",
    year: "2007"
}, {
    sales: "7.3",
    year: "2008"
}, {
    sales: "4.8",
    year: "2009"
}];
var barChart1;
window.onload = function() {
    barChart1 = new dhtmlXChart({
        view: "bar",
        container: "chart1",
        value: "#sales#",
        label: "#sales#",
        color: "#b3e025",
        gradient: true,
        border: false,
        width: 50,
        tooltip: {
            template: "#sales#";
        },
        xAxis: {
            title: "Sales per year",
            template: "#year#";
        },
        padding: {
            top: 20,
            left: 0,
            right: 0;
        }
    });
    barChart1.parse(data, "json");
}
var counter = 2010;
function add_new() {
    barChart1.add({
        year: counter,
        sales: (Math.random() * 5).toFixed(2);
    });
    counter++;
}
function delete_first() {
    barChart1.remove(barChart1.first());
}
</script> <table> <tr> <td><div id="chart1" style="width:750px;height:300px;border:1px solid #A4BED4;"></div></td> </tr> </table> <input type="button" value="add" onclick="add_new()"> <input type="button" value="delete" onclick="delete_first()">