Sorting

Defines sorting settings.

  • sort
    • by - (template) sets a template for the property that the chart is sorted by
    • dir - (asc or dsc) the sorting direction
    • as - (int, string, string_strict (case-sensitive “string”) or custom) a build-in or custom sorting method

Data can be sorted by sort property in the chart constructor:

var data = [
	{ sales: 4.1, year: 2003 },
	{ sales: 4.3, year: 2004 },
	{ sales: 3.0, year: 2000 },
	{ sales: 3.8, year: 2001 },
	{ sales: 3.4, year: 2002 },
	{ sales: 7.3, year: 2008 },
	{ sales: 4.8, year: 2009 },
];
var chart =  new dhx.ui({
        view:"chart",
	type:"bar",
	container:"chart_container",
        value:"#sales#",
	label:"#sales#",
	xAxis:{
	    template:"#year#",
	    title:"Sales per year"
	},
	sort:{
	    by:"#sales#",
	    dir:"asc",
	    as:"int"
	}
})
chart.parse(data,"json");

or by sort() method:

chart.sort({
        by:"#year#",
        dir:"asc",
        as:"int"
});