@Override protected JsonObject getChartData() { JsonObject data = new JsonObject(); JsonObject values = new JsonObject(); HashMap<String, int[]> map = getValues(new HashMap<String, int[]>()); if (map == null || map.isEmpty()) { // Null = skip the chart return null; } boolean allSkipped = true; for (Map.Entry<String, int[]> entry : map.entrySet()) { if (entry.getValue().length == 0) { continue; // Skip this invalid } allSkipped = false; JsonArray categoryValues = new JsonArray(); for (int categoryValue : entry.getValue()) { categoryValues.add(new JsonPrimitive(categoryValue)); } values.add(entry.getKey(), categoryValues); } if (allSkipped) { // Null = skip the chart return null; } data.add("values", values); return data; }