DHTMLX Docs & Samples Explorer

### Data Loading: JS array

When data are loaded from JS array, you should use "data" and field index to define field in the template, for example, "#data0#","#data1#",etc.
Charts in this sample represents values in the first column. Therefore, we have set value:"#data0#" in a chart contructor.

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 = [["2.9", "2000"], ["3.5", "2001"], ["3.1", "2002"], ["4.2", "2003"], ["4.5", "2004"], ["9.6", "2005"], ["7.4", "2006"], ["9.0", "2007"], ["7.3", "2008"], ["2.8", "2009"]];
    window.onload = function() {
        var barChart = new dhtmlXChart({
            view: "bar",
            container: "chart_container",
            value: "#data0#",
            label: "#data1#",
            padding: {
                bottom: 0,
                right: 0,
                left: 0;
            },
            width: 30,
            gradient: true,
            border: false;
        });
        barChart.parse(data, "jsarray");
        var barChart2 = new dhtmlXChart({
            view: "pie",
            container: "chart_container2",
            value: "#data0#",
            details: "#data1#";
        });
        barChart2.parse(data, "jsarray");
    }</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>