Skip to content

Commit

Permalink
IndexOutOfBoundsException when run diagram report with empty data #258
Browse files Browse the repository at this point in the history
  • Loading branch information
dtaimanov committed Jun 11, 2020
1 parent ca29720 commit df434ad
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@ public String convertSerialChart(SerialChartDescription description, List<Map<St
graphs.add(graph);
}

Optional.ofNullable(data.get(0)).ifPresent(map -> {
if (map instanceof EntityMap) {
sortByCategoryField(data, description.getCategoryField());
}
});
sortByCategoryFieldIfNeed(data, description.getCategoryField());

JsonElement jsonTree = gson.toJsonTree(chart);
jsonTree.getAsJsonObject().add("dataProvider", serializeData(data, fields));
Expand All @@ -145,7 +141,10 @@ public String convertSerialChart(SerialChartDescription description, List<Map<St
return gson.toJson(jsonTree);
}

private void sortByCategoryField(List<Map<String, Object>> data, String categoryField) {
private void sortByCategoryFieldIfNeed(List<Map<String, Object>> data, String categoryField) {
if (data.isEmpty() || !(data.get(0) instanceof EntityMap))
return;

data.sort((entityMap1, entityMap2) -> {
int compareResult;

Expand Down

0 comments on commit df434ad

Please sign in to comment.