Search in sources :

Example 6 with DimensionCategory

use of org.activityinfo.shared.report.content.DimensionCategory in project activityinfo by bedatadriven.

the class PiechartLayerGenerator method sumSlices.

private void sumSlices(PieMapMarker marker, List<PointValue> pvs) {
    Map<DimensionCategory, PieMapMarker.SliceValue> slices = new HashMap<DimensionCategory, PieMapMarker.SliceValue>();
    for (PointValue pv : pvs) {
        for (PieMapMarker.SliceValue slice : pv.getSlices()) {
            PieMapMarker.SliceValue summedSlice = slices.get(slice.getCategory());
            if (summedSlice == null) {
                summedSlice = new PieMapMarker.SliceValue(slice);
                summedSlice.setIndicatorId(slice.getIndicatorId());
                slices.put(slice.getCategory(), summedSlice);
            } else {
                summedSlice.setValue(summedSlice.getValue() + slice.getValue());
            }
        }
    }
    marker.setSlices(new ArrayList<PieMapMarker.SliceValue>(slices.values()));
}
Also used : DimensionCategory(org.activityinfo.shared.report.content.DimensionCategory) HashMap(java.util.HashMap) PointValue(org.activityinfo.shared.report.model.PointValue) PieMapMarker(org.activityinfo.shared.report.content.PieMapMarker)

Aggregations

DimensionCategory (org.activityinfo.shared.report.content.DimensionCategory)6 Dimension (org.activityinfo.shared.report.model.Dimension)3 JsonArray (com.google.gson.JsonArray)2 HashMap (java.util.HashMap)2 CategoryProperties (org.activityinfo.shared.report.model.CategoryProperties)2 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 Bucket (org.activityinfo.shared.command.result.Bucket)1 CommandException (org.activityinfo.shared.exception.CommandException)1 PieMapMarker (org.activityinfo.shared.report.content.PieMapMarker)1 PivotTableData (org.activityinfo.shared.report.content.PivotTableData)1 AdminDimension (org.activityinfo.shared.report.model.AdminDimension)1 AttributeGroupDimension (org.activityinfo.shared.report.model.AttributeGroupDimension)1 DateDimension (org.activityinfo.shared.report.model.DateDimension)1 PointValue (org.activityinfo.shared.report.model.PointValue)1