DHTMLX Docs & Samples Explorer

Data Loading: CSV

When data are loaded from CSV string, 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\n\;
  3.5, 2001\n\;
  3.1, 2002\n\;
  4.2, 2003\n\;
  4.5, 2004\n\;
  9.6, 2005\n\;
  7.4, 2006\n\;
  9.0, 2007\n\;
  7.3, 2008\n\;
  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, "csv");
    var barChart2 = new dhtmlXChart({
        view: "pie",
        container: "chart_container2",
        value: "#data0#",
        details: "#data1#";
    });
    barChart2.parse(data, "csv");
}
</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>