diff --git a/src/main/java/com/tarento/analytics/handler/LineChartResponseHandler.java b/src/main/java/com/tarento/analytics/handler/LineChartResponseHandler.java index f4b05bc2446e4e642d3d8fb15c967ad79b90252f..271fd24230af8b779a5fc39ff180c5940a6b2498 100644 --- a/src/main/java/com/tarento/analytics/handler/LineChartResponseHandler.java +++ b/src/main/java/com/tarento/analytics/handler/LineChartResponseHandler.java @@ -88,6 +88,7 @@ public class LineChartResponseHandler implements IResponseHandler { double previousVal = !isCumulative ? 0.0 : (totalValues.size() > 0 ? totalValues.get(totalValues.size() - 1) : 0.0); + double value; if (action.equals("Negative Count") && action != null && bucket.findValue(IResponseHandler.NEGATIVE_COUNT) != null) { @@ -95,7 +96,7 @@ public class LineChartResponseHandler implements IResponseHandler { ? bucket.findValue(IResponseHandler.VALUE).asDouble() * -1 : bucket.findValue(IResponseHandler.DOC_COUNT).asDouble()); } else { - if (bucket.findValue(IResponseHandler.CUMULATIVE_VALUE) != null) { + if (isCumulative) { value = previousVal + ((bucket.findValue(IResponseHandler.VALUE) != null) ? bucket.findValue(IResponseHandler.VALUE).asDouble() : bucket.findValue(IResponseHandler.DOC_COUNT).asDouble()); @@ -115,17 +116,21 @@ public class LineChartResponseHandler implements IResponseHandler { .map(e -> new Plot(e.getKey(), e.getValue(), symbol, headerLabel, valueLabel)) .collect(Collectors.toList()); try { - Data data = new Data(headerPath.asText(), (totalValues == null || totalValues.isEmpty()) ? 0.0 - : totalValues.stream().reduce(0.0, Double::sum), symbol); - /* - * Data data; if(!isCumulative) { data = new Data(headerPath.asText(), - * (totalValues==null || totalValues.isEmpty()) ? 0.0 : - * totalValues.stream().reduce(0.0, Double::sum), symbol); } else { data = new - * Data(headerPath.asText(), (totalValues==null || totalValues.isEmpty()) ? 0.0 - * : plots.get(plots.size()-1), symbol); } - */ +// Data data = new Data(headerPath.asText(), (totalValues == null || totalValues.isEmpty()) ? 0.0 +// : totalValues.stream().reduce(0.0, Double::sum), symbol); + + Data data; + + if (!isCumulative) { + data = new Data(headerPath.asText(), (totalValues == null || totalValues.isEmpty()) ? 0.0 + : totalValues.stream().reduce(0.0, Double::sum), symbol); + } else { + data = new Data(headerPath.asText(), + (totalValues == null || totalValues.isEmpty()) ? 0.0 : plots.get(plots.size() - 1), symbol); + } data.setPlots(plots); dataList.add(data); + } catch (Exception e) { logger.error(" Legend/Header " + headerPath.asText() + " exception occurred " + e.getMessage()); } diff --git a/src/main/resources/schema/SMF_ChartApiConfig.json b/src/main/resources/schema/SMF_ChartApiConfig.json index e271caa75924cc5c3ee4528b46b44c38a182ad4e..3b52769690ccac2f96eedeb4ee6b2e43b7d6a597 100644 --- a/src/main/resources/schema/SMF_ChartApiConfig.json +++ b/src/main/resources/schema/SMF_ChartApiConfig.json @@ -157,7 +157,7 @@ } ], "chartType": "line", - "resultType": "doc_count", + "resultType": "value", "valueType": "number", "isDecimal": true, "action": "",