DHTMLX Docs & Samples Explorer

Sorting

Source
<script src="../../codebase/dhtmlxchart.js" type="text/javascript"></script>
<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxchart.css">
<script src="../common/testdata.js"></script>
<script>
var barChart1;
window.onload = function() {
    barChart1 = new dhtmlXChart({
        view: "bar",
        container: "chart1",
        value: "#sales#",
        color: "#color#",
        radius: 2,
        width: 40,
        tooltip: {
            template: "#sales#";
        },
        yAxis: {
            start: 0,
            end: 100,
            step: 10,
            template: function(value) {
                return value % 20 ? "": value;
            }
        },
        xAxis: {
            template: "'#year#";
        }
    });
    barChart1.parse(dataset_colors, "json");
}
</script> <div id="chart1" style="width:600px;height:250px;border:1px solid #A4BED4;"></div> <input type="button" value="sort by sales, ASC" onclick="barChart1.sort('#sales#','asc');"> <input type="button" value="sort by sales, DESC" onclick="barChart1.sort('#sales#','desc');"> <input type="button" value="sort by year, ASC" onclick="barChart1.sort('#year#','asc');"> <input type="button" value="sort by year, DESC" onclick="barChart1.sort('#year#','desc');">