DHTMLX Docs & Samples Explorer

### Data Loading: JSON

Source

    <script src="../../codebase/dhtmlxchart.js" type="text/javascript"></script>
    <link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxchart.css">
    <style>
        .dhx_chart_title{
            padding-left:3px
        }
    </style>
    <script>var data = [{
        value: "2.9",
        label: "2000"
    }, {
        value: "3.5",
        label: "2001"
    }, {
        value: "3.1",
        label: "2002"
    }, {
        value: "4.2",
        label: "2003"
    }, {
        value: "4.5",
        label: "2004"
    }, {
        value: "9.6",
        label: "2005"
    }, {
        value: "7.4",
        label: "2006"
    }, {
        value: "9.0",
        label: "2007"
    }, {
        value: "7.3",
        label: "2008"
    }, {
        value: "2.8",
        label: "2009"
    }];
    window.onload = function() {
        var barChart = new dhtmlXChart({
            view: "bar",
            container: "chart_container",
            label: "#label#",
            padding: {
                bottom: 0,
                right: 0,
                left: 0;
            },
            width: 30,
            gradient: true,
            border: false;
        });
        barChart.parse(data, "json");
        var barChart2 = new dhtmlXChart({
            view: "pie",
            container: "chart_container2",
            details: "#label#";
        });
        barChart2.parse(data, "json");
    }</script>

    <div id="chart_container" style="width:450px;height:300px;border:1px solid #A4BED4;float:left;margin-right:20px"></div>
    <div id="chart_container2" style="width:450px;height:300px;border:1px solid #A4BED4;"></div>