From c6234a92ab11f2876de1e01f6768f61f65da1333 Mon Sep 17 00:00:00 2001 From: Indrijeet kumar Date: Mon, 1 Jun 2020 09:32:04 +0530 Subject: lowered code smells in ChartD3Helper.java Lowered code smells in ChartD3Helper.java Issue-ID: PORTAL-813 Change-Id: Ia2a8451ac94bf59e45da2436ecefd321cf18212e Signed-off-by: Indrijeet Kumar --- .../analytics/model/runtime/ChartD3Helper.java | 66 ++-------------------- 1 file changed, 5 insertions(+), 61 deletions(-) diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java index dd063554..0934e35c 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java @@ -436,7 +436,7 @@ public class ChartD3Helper { } uniqueElement = (String)uniqueElements[j]; if(date==null) { - //continue; + //continue flagNoDate = 1; int pos = 0; for (int f=0 ; f< uniqueXAxisElements.length; f++) { @@ -461,7 +461,6 @@ public class ChartD3Helper { } catch (NumberFormatException ex1) { flagNull = 1; } - //flagNull = 1; } /* For Non-date type value enclose with double quotes */ @@ -506,7 +505,6 @@ public class ChartD3Helper { flagNull = 1; } - //flagNull = 1; } HashMap dataMap = dataSeriesMap.get((String) uniqueElements[j]); if(logScale) { @@ -518,7 +516,6 @@ public class ChartD3Helper { } - //} } } for(int kI = 0; kI < uniqueElements.length; kI++) { @@ -544,7 +541,6 @@ public class ChartD3Helper { YAXISNUM = 0; YAXISDOUBLENUM = 0.0; flagNull= 0; - //flagSecondNull = 0; dateStr = ds.getString(i, 1); if(timeAxis) { date = getDateFromDateStr(dateStr); @@ -552,7 +548,7 @@ public class ChartD3Helper { } uniqueElement = (String)uniqueElements[j]; if(date==null) { - //continue; + //continue flagNoDate = 1; int pos = 0; for (int f=0 ; f< uniqueXAxisElements.length; f++) { @@ -579,7 +575,6 @@ public class ChartD3Helper { flagNull = 1; } - //flagNull = 1; } if(logScale) { @@ -631,7 +626,6 @@ public class ChartD3Helper { flagNull = 1; } - //flagNull = 1; } HashMap dataMap = dataSeriesMap.get((String) uniqueElements[j]); @@ -727,19 +721,16 @@ public class ChartD3Helper { } if(timeAxis) { - //if(!barRealTimeAxis) { // false - non-time Object[] dateAllElements = (Object[]) sortSet.toArray(); for (int i = 0; i < uniqueElements.length; i++) { HashMap dataMap = dataSeriesMap.get((String)uniqueElements[i]); for (int j=0; j= 1) { UPPER_RANGE = Math.ceil(MAXDOUBLENUM+(MAXDOUBLENUM*25/100)); @@ -884,10 +872,7 @@ public class ChartD3Helper { } if(nvl(chartRightAxisLabel).length() > 0) { - //if(flagNoDate == 1) wholeScript.append(" chart.yAxis\n"); - //else - // wholeScript.append(" chart.yAxis1\n"); if(logScale) { wholeScript.append(" .logScale(true)\n "); } else { @@ -896,16 +881,10 @@ public class ChartD3Helper { wholeScript.append(" .axisLabel('" + chartLeftAxisLabel + "') \n" + " .tickFormat(d3.format(',.0f')); \n"); - /*" chart.yAxis2\n " + - " .axisLabel('" + chartRightAxisLabel + "') \n" + - " .tickFormat(d3.format(',.0f')); \n");*/ } else { - //if(flagNoDate == 1) wholeScript.append(" chart.yAxis\n"); - //else - // wholeScript.append(" chart.yAxis1\n"); if(logScale) { wholeScript.append(" .logScale(true)\n "); } else { @@ -921,7 +900,6 @@ public class ChartD3Helper { wholeScript.append(" .tickFormat(d3.format(',."+MAXNUMDECIMALPLACES+"f')); \n"); else wholeScript.append(" .tickFormat(d3.format(',." + precision + "f')); \n"); - //" .tickFormat(d3.format(',.0f')); \n"); } wholeScript.append(" d3.select('#chart"+reportRuntime.getReportID()+" svg') \n" + " .datum(historicalBarChart) \n" ); @@ -934,7 +912,6 @@ public class ChartD3Helper { "return chart; \n" + "}); \n"); wholeScript.append("function redraw() { \n"); - //wholeScript.append(" nv.utils.windowResize(chart.update); \n"); wholeScript.append(" d3.select('#chart"+reportRuntime.getReportID()+" svg') \n") ; wholeScript.append(" .datum(historicalBarChart) \n"); wholeScript.append(" .transition().duration(500) \n"); @@ -971,7 +948,6 @@ public class ChartD3Helper { int flag = 0; flag = hasCategoryAxis?1:0; String uniqueElements [] = null; - //TreeSet ts = new TreeSet(); ArrayList ts = new ArrayList(); HashMap columnMap = new HashMap(); //check timeAxis @@ -1020,7 +996,6 @@ public class ChartD3Helper { catStr.append("|"+color); } } catch (ArrayIndexOutOfBoundsException ex) { - //System.out.println("No Chart Color"); } if(catStr.length()>0) { @@ -1030,15 +1005,11 @@ public class ChartD3Helper { } } - //Object uniqueElements [] = ts.toArray(); - //SortedSet s = Collections.synchronizedSortedSet(ts); - //uniqueElements = (String[]) ts.toArray(); DataColumnType dct = null; List yTextSeries = reportRuntime.getChartDisplayNamesList(AppConstants.CHART_ALL_COLUMNS, formValues); if(yTextSeries.size()==1) { for (Iterator iter = l.iterator(); iter.hasNext();) { dct = (DataColumnType) iter.next(); - //System.out.println(dct.getDisplayName() + " " + yText); if(!(nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND))) { if(nvl(chartLeftAxisLabel).length()<=0) { chartLeftAxisLabel = nvl(dct.getYAxis()); @@ -1054,11 +1025,9 @@ public class ChartD3Helper { DataColumnType dct = null; List yTextSeries = reportRuntime.getChartDisplayNamesList(AppConstants.CHART_ALL_COLUMNS, formValues); - //if(columnValuesList.size() == 1) { int dctIndex = 0; for (Iterator iter = l.iterator(); iter.hasNext();) { dct = (DataColumnType) iter.next(); - //System.out.println(dct.getDisplayName() + " " + yText); if(!(nvl(dct.getColOnChart()).equals(AppConstants.GC_LEGEND))) { if(yTextSeries.contains((String)dct.getDisplayName())) { if(nvl(dct.getChartColor()).length()>0) @@ -1096,10 +1065,8 @@ public class ChartD3Helper { } - //SortedSet s = Collections.synchronizedSortedSet(ts); Object tempArray[] = ts.toArray(); uniqueElements = Arrays.copyOf(tempArray, tempArray.length, String[].class); - //uniqueElements = (String[]) ts.toArray(); } @@ -1151,29 +1118,20 @@ public class ChartD3Helper { wholeScript.append("\n"); wholeScript.append(" \n"); wholeScript.append(" \n"); - //wholeScript.append(" \n"); - //if(multipleSeries) - //wholeScript.append(" \n"); //json wholeScript.append("