From df434ad2f6caef703347b1eaea7b4b58cbccda66 Mon Sep 17 00:00:00 2001 From: Dmitry Taimanov Date: Wed, 10 Jun 2020 18:58:41 +0400 Subject: [PATCH] IndexOutOfBoundsException when run diagram report with empty data #258 --- .../reports/entity/charts/ChartToJsonConverter.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/global/src/com/haulmont/reports/entity/charts/ChartToJsonConverter.java b/modules/global/src/com/haulmont/reports/entity/charts/ChartToJsonConverter.java index facaf52b..d2ca0fd5 100644 --- a/modules/global/src/com/haulmont/reports/entity/charts/ChartToJsonConverter.java +++ b/modules/global/src/com/haulmont/reports/entity/charts/ChartToJsonConverter.java @@ -128,11 +128,7 @@ public String convertSerialChart(SerialChartDescription description, List { - if (map instanceof EntityMap) { - sortByCategoryField(data, description.getCategoryField()); - } - }); + sortByCategoryFieldIfNeed(data, description.getCategoryField()); JsonElement jsonTree = gson.toJsonTree(chart); jsonTree.getAsJsonObject().add("dataProvider", serializeData(data, fields)); @@ -145,7 +141,10 @@ public String convertSerialChart(SerialChartDescription description, List> data, String categoryField) { + private void sortByCategoryFieldIfNeed(List> data, String categoryField) { + if (data.isEmpty() || !(data.get(0) instanceof EntityMap)) + return; + data.sort((entityMap1, entityMap2) -> { int compareResult;