private static final long serialVersionUID = 1L;
@Override
protected PivotModel createPivotModel(PivotDataSource pivotDataSource) {
PivotModel pivotModel = super.createPivotModel(pivotDataSource);
// add some fields on some area
pivotModel.getField("REGION").setArea(PivotField.Area.ROW);
pivotModel.getField("SALESMAN").setArea(PivotField.Area.ROW).setAreaIndex(1);
pivotModel.getField("YEAR").setArea(PivotField.Area.COLUMN);
pivotModel.getField("MONTH").setArea(PivotField.Area.COLUMN).setAreaIndex(1);
pivotModel.getField("SALES").setArea(PivotField.Area.DATA);
// set an aggregator for a data pivot field
// pivotModel.getField("SALES").setAggregator(new Aggregator.Count());
// set a custom converter for a pivot field
/*
pivotModel.getField("SALES").setConverter(new DoubleConverter() {
private static final long serialVersionUID = 1L;
@Override
public NumberFormat getNumberFormat(Locale locale) {
NumberFormat format = super.getNumberFormat(locale);
format.setMinimumFractionDigits(2);
return format;
}
});
*/
// show grand totals
pivotModel.setShowGrandTotalForColumn(true);
pivotModel.setShowGrandTotalForRow(true);
return pivotModel;
}
};