// Calculate the data set to display.
// Set the scalar function to apply for the calculations of the chart values.
ScalarFunction scalarFunction = scalarFunctionManager.getScalarFunctionByCode(SumFunction.CODE);
barChartDisplayer.setRangeScalarFunction(scalarFunction);
DataSet xyDataSet = barChartDisplayer.buildXYDataSet();
// Check the expected results matrix
assertDataSetValues(xyDataSet, new String[][] {
new String[] {"Engineering", "7,650.162"},
new String[] {"Services", "2,504.5"},
new String[] {"Sales", "3,213.53"},
new String[] {"Support", "3,345.6"},
new String[] {"Management", "6,017.47"}}, 0);
// Sort by department and check the expected results.
DataSetComparator comp = new DataSetComparator();
comp.addSortCriteria("0", DataSetComparator.ORDER_DESCENDING);
xyDataSet = xyDataSet.sort(comp);
assertDataSetValues(xyDataSet, new String[][] {
new String[] {"Support", "3,345.6"}}, 0);
// Sort by amount and check the expected results.
comp = new DataSetComparator();
comp.addSortCriteria("1", DataSetComparator.ORDER_ASCENDING);
xyDataSet = xyDataSet.sort(comp);
assertDataSetValues(xyDataSet, new String[][]{
new String[]{"Services", "2,504.5"}}, 0);
}