DHTMLX Docs & Samples Explorer

Data Loading: XML

Chart data can be loaded from different sources: xml,json,JS array,csv
This samples demonstrates loading from xml file.

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 barChart;
window.onload = function() {
    barChart = new dhtmlXChart({
        view: "bar",
        container: document.getElementById("chart_container"),
        value: "#sales#",
        label: "#year#",
        padding: {
            bottom: 0,
            right: 0,
            left: 0;
        },
        width: 30,
        gradient: true,
        border: false;
    });
    barChart.load("../common/sales.xml");
    var barChart2 = new dhtmlXChart({
        view: "pie",
        container: "chart_container2",
        value: "#sales#",
        details: "#year#";
    });
    barChart2.load("../common/sales.xml");
}
</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>