=== added file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/action/ExportDataElementToExcelAction.java' --- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/action/ExportDataElementToExcelAction.java 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/action/ExportDataElementToExcelAction.java 2010-11-02 11:35:05 +0000 @@ -0,0 +1,527 @@ +/* + * Copyright (c) 2004-2010, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.hisp.dhis.dashboard.action; + +import java.awt.image.BufferedImage; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.UUID; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import jxl.CellType; +import jxl.Workbook; +import jxl.format.Alignment; +import jxl.format.Border; +import jxl.format.BorderLineStyle; +import jxl.format.CellFormat; +import jxl.format.Colour; +import jxl.write.Label; +import jxl.write.Number; +import jxl.write.WritableCell; +import jxl.write.WritableCellFormat; +import jxl.write.WritableImage; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; + +import org.apache.struts2.ServletActionContext; +import org.hisp.dhis.config.ConfigurationService; +import org.hisp.dhis.config.Configuration_IN; + +import com.keypoint.PngEncoder; +import com.opensymphony.xwork2.Action; +import com.opensymphony.xwork2.ActionContext; +/** + * @author Mithilesh Kumar Thakur + * + * @version ExportDataElementToExcelAction.java Oct 29, 2010 1:59:14 PM + */ +public class ExportDataElementToExcelAction implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- +/* + private LocationManager locationManager; + + public void setLocationManager( LocationManager locationManager ) + { + this.locationManager = locationManager; + } + */ + private ConfigurationService configurationService; + + public void setConfigurationService( ConfigurationService configurationService ) + { + this.configurationService = configurationService; + } + + // ------------------------------------------------------------------------- + // Input & output + // ------------------------------------------------------------------------- + + double[][] data1; + + // double[][] data2; + + String[] series1; + + // String[] series2; + + String[] categories1; + + // String[] categories2; + + + private InputStream inputStream; + + public InputStream getInputStream() + { + return inputStream; + } + + /* + private String contentType; + + public String getContentType() + { + return contentType; + } + */ + + private String fileName; + + public String getFileName() + { + return fileName; + } + + /* + private int bufferSize; + + public int getBufferSize() + { + return bufferSize; + } + */ + + private String viewSummary; + + public void setViewSummary( String viewSummary ) + { + this.viewSummary = viewSummary; + } + + private String chartDisplayOption; + + public void setChartDisplayOption( String chartDisplayOption ) + { + this.chartDisplayOption = chartDisplayOption; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + int tempCol1 = 0; + int tempRow1 = 1; + + ActionContext ctx = ActionContext.getContext(); + HttpServletRequest req = (HttpServletRequest) ctx.get( ServletActionContext.HTTP_REQUEST ); + HttpSession session = req.getSession(); + BufferedImage chartImage = (BufferedImage) session.getAttribute("chartImage"); + PngEncoder encoder = new PngEncoder(chartImage, false, 0, 9); + + byte[] encoderBytes = encoder.pngEncode(); + Double[][] objData1 = (Double[][]) session.getAttribute( "data1" ); + //Double[][] objData2 = (Double[][]) session.getAttribute( "data2" ); + + String[] series1S = (String[]) session.getAttribute( "series1" ); + //String[] series2S = (String[]) session.getAttribute( "series2" ); + String[] categories1S = (String[]) session.getAttribute( "categories1" ); + // String[] categories2S = (String[]) session.getAttribute( "categories2" ); + + + // initialzeAllLists(series1S, series2S, categories1S, categories2S); + initialzeAllLists(series1S, categories1S ); + + //if(objData1 == null || objData2 == null || series1 == null || series2 == null || categories1 == null || categories2 == null ) + if(objData1 == null || series1 == null || categories1 == null ) + System.out.println("Session Objects are null"); + else + System.out.println("Session Objects are not null"); + + data1 = convertDoubleTodouble( objData1 ); + // data2 = convertDoubleTodouble( objData2 ); + + if(chartDisplayOption == null || chartDisplayOption.equalsIgnoreCase("none")) { } + else if(chartDisplayOption.equalsIgnoreCase("ascend")) { sortByAscending(); } + else if(chartDisplayOption.equalsIgnoreCase("desend")) { sortByDesscending(); } + else if(chartDisplayOption.equalsIgnoreCase("alphabet")) { sortByAlphabet(); } + + //File outputReportFile = locationManager.getFileForWriting( UUID.randomUUID().toString() + ".xls", "db", "output" ); + + + // String outputReportFile = System.getProperty( "user.home" ) + File.separator + "dhis" + File.separator + configurationService.getConfigurationByKey( Configuration_IN.KEY_REPORTFOLDER ).getValue() + // + File.separator + "output" + File.separator + UUID.randomUUID().toString() + ".xls"; + String outputReportFile = System.getenv( "DHIS2_HOME" ) + File.separator + configurationService.getConfigurationByKey( Configuration_IN.KEY_REPORTFOLDER ).getValue() + + File.separator + "output" + File.separator + UUID.randomUUID().toString() + ".xls"; + + // System.out.println("Env Variable is :" + System.getenv( "DHIS2_HOME" ) ); + // System.out.println("Complete path is :" + outputReportFile ); + + WritableWorkbook outputReportWorkbook = Workbook.createWorkbook( new File(outputReportFile) ); + WritableSheet sheet0 = outputReportWorkbook.createSheet( "DataElementChartOutput", 0 ); + + if(viewSummary.equals( "no" )) + { + WritableImage writableImage = new WritableImage(0,1,10,23,encoderBytes); + sheet0.addImage( writableImage ); + tempRow1 = 24; + } + else + { + tempRow1 -= objData1.length; + } + + + int count1 = 0; + int count2 = 0; + int flag1 = 0; + while(count1 <= categories1.length) + { + for(int j=0;j categories1.length) && (categories1.length - count1 <= 10)) + { + count1 += categories1.length - count1; + flag1 = 1; + } + else + count1 += 10; + } + outputReportWorkbook.write(); + outputReportWorkbook.close(); + + fileName = "DataElement Chart Output.xls"; + + inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) ); + + + return SUCCESS; + } + + +// public void initialzeAllLists(String[]series1S, String[] series2S, String[] categories1S, String[] categories2S) + public void initialzeAllLists(String[]series1S, String[] categories1S) + { + int i; + series1 = new String[series1S.length]; + // series2 = new String[series2S.length]; + categories1 = new String[categories1S.length]; + // categories2 = new String[categories2S.length]; + + for(i = 0; i < series1S.length; i++) + { + series1[i] = series1S[i]; + } +/* + for(i = 0; i < series2S.length; i++) + { + series2[i] = series2S[i]; + } +*/ + for(i = 0; i < categories1S.length; i++) + { + categories1[i] = categories1S[i]; + } +/* + for(i = 0; i < categories2S.length; i++) + { + categories2[i] = categories2S[i]; + } +*/ + } + + public double[][] convertDoubleTodouble( Double[][] objData ) + { + //System.out.println("Before Sorting : "); + double[][] data = new double[objData.length][objData[0].length]; + for ( int i = 0; i < objData.length; i++ ) + { + for ( int j = 0; j < objData[0].length; j++ ) + { + data[i][j] = objData[i][j].doubleValue(); + //System.out.print(categories1[j]+": "+data[i][j]+", "); + } + //System.out.println(""); + } + + return data; + }// convertDoubleTodouble end + + public void sortByAscending() + { + for(int i=0; i < categories1.length-1 ; i++) + { + for(int j=0; j < categories1.length-1-i; j++) + { + if(data1[0][j] > data1[0][j+1]) + { + for(int k=0; k data2[0][j+1]) + { + for(int k=0; k 0) + { + for(int k=0; k 0) + { + for(int k=0; k" ); } - public void initialzeAllLists(String[]series1S, String[] series2S, String[] categories1S, String[] categories2S) +// public void initialzeAllLists(String[]series1S, String[] series2S, String[] categories1S, String[] categories2S) + public void initialzeAllLists(String[]series1S, String[] categories1S ) { int i; series1 = new String[series1S.length]; - series2 = new String[series2S.length]; + // series2 = new String[series2S.length]; categories1 = new String[categories1S.length]; - categories2 = new String[categories2S.length]; + // categories2 = new String[categories2S.length]; for(i = 0; i < series1S.length; i++) { series1[i] = series1S[i]; } - +/* for(i = 0; i < series2S.length; i++) { series2[i] = series2S[i]; } - +*/ for(i = 0; i < categories1S.length; i++) { categories1[i] = categories1S[i]; } - +/* for(i = 0; i < categories2S.length; i++) { categories2[i] = categories2S[i]; } - +*/ } public double[][] convertDoubleTodouble( Double[][] objData ) @@ -170,7 +173,7 @@ } } } - +/* for(int i=0; i < categories2.length-1 ; i++) { for(int j=0; j < categories2.length-1-i; j++) @@ -190,8 +193,8 @@ } } } - - } +*/ + } public void sortByDesscending() { @@ -214,7 +217,7 @@ } } } - + /* for(int i=0; i < categories2.length-1 ; i++) { for(int j=0; j < categories2.length-1-i; j++) @@ -234,7 +237,7 @@ } } } - +*/ } public void sortByAlphabet() @@ -258,7 +261,7 @@ } } } - + /* for(int i=0; i < categories2.length-1 ; i++) { for(int j=0; j < categories2.length-1-i; j++) @@ -278,7 +281,7 @@ } } } - +*/ } }// class end === modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ds/action/ExportToExcelAction.java' --- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ds/action/ExportToExcelAction.java 2010-06-04 11:50:05 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ds/action/ExportToExcelAction.java 2010-11-02 11:35:05 +0000 @@ -4,9 +4,9 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; -import com.opensymphony.xwork2.ActionSupport; +import com.opensymphony.xwork2.Action; -public class ExportToExcelAction extends ActionSupport +public class ExportToExcelAction implements Action { // ------------------------------------------------------------------------- // Dependencies === modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/action/charts/GenerateChartAction.java' --- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/action/charts/GenerateChartAction.java 2010-06-04 11:50:05 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/action/charts/GenerateChartAction.java 2010-11-02 11:35:05 +0000 @@ -140,6 +140,8 @@ String[] categories1S = (String[]) session.getAttribute( "categories1" ); String[] categories2S = (String[]) session.getAttribute( "categories2" ); + // series2 = (String[]) session.getAttribute( "series2" ); + chartTitle = (String) session.getAttribute( "chartTitle" ); xAxis_Title = (String) session.getAttribute( "xAxisTitle" ); yAxis_Title = (String) session.getAttribute( "yAxisTitle" ); @@ -255,6 +257,7 @@ } public void initialzeAllLists(String[]series1S, String[] series2S, String[] categories1S, String[] categories2S) + { int i; series1 = new String[series1S.length]; @@ -276,12 +279,12 @@ { categories1[i] = categories1S[i]; } - + for(i = 0; i < categories2S.length; i++) { categories2[i] = categories2S[i]; } - + } public double[][] convertDoubleTodouble( Double[][] objData ) === added file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/action/charts/GenerateChartAction1.java' --- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/action/charts/GenerateChartAction1.java 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/action/charts/GenerateChartAction1.java 2010-11-02 11:35:05 +0000 @@ -0,0 +1,460 @@ +/* + * Copyright (c) 2004-2010, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.hisp.dhis.dashboard.ga.action.charts; + +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.apache.struts2.ServletActionContext; +import org.hisp.dhis.dashboard.ga.charts.AreaChart; +import org.hisp.dhis.dashboard.ga.charts.Horizontal3DBarChart; +import org.hisp.dhis.dashboard.ga.charts.LineAndBarChart; +import org.hisp.dhis.dashboard.ga.charts.LineChart; +import org.hisp.dhis.dashboard.ga.charts.StandardChart; +import org.hisp.dhis.dashboard.ga.charts.Vertical3DBarChart; +import org.jfree.chart.ChartRenderingInfo; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.entity.StandardEntityCollection; + +import com.opensymphony.xwork2.Action; +import com.opensymphony.xwork2.ActionContext; +/** + * @author Mithilesh Kumar Thakur + * + * @version GenerateChartAction1.java Oct 27, 2010 1:17:24 PM + */ + + +public class GenerateChartAction1 + implements Action +{ + double[][] data1; + + // double[][] data2; + + String[] series1; + + // String[] series2; + + String[] categories1; + + // String[] categories2; + + String chartTitle; + + String xAxis_Title; + + String yAxis_Title; + + private StandardChart selChart; + + // private Vertical3DBarChart selChart; + + private HttpSession session; + + public HttpSession getSession() + { + return session; + } + + private JFreeChart chart; + + public JFreeChart getChart() + { + return chart; + } + + private String headingInfo; + + public String getHeadingInfo() + { + return headingInfo; + } + + private List yseriesList; + + public List getYseriesList() + { + return yseriesList; + } + + private List xseriesList; + + public List getXseriesList() + { + return xseriesList; + } + + private List> dataList; + + public List> getDataList() + { + return dataList; + } + + public String execute() + throws Exception + { + + xseriesList = new ArrayList(); + yseriesList = new ArrayList(); + dataList = new ArrayList>(); + + ActionContext ctx = ActionContext.getContext(); + HttpServletRequest req = (HttpServletRequest) ctx.get( ServletActionContext.HTTP_REQUEST ); + String currentChart = req.getParameter( "currentChart" ); + String chartDisplayOption = req.getParameter( "chartDisplayOption" ); + + //System.out.println("chartDisplayOption : "+chartDisplayOption); + session = req.getSession(); + Double[][] objData1 = (Double[][]) session.getAttribute( "data1" ); + // Double[][] objData2 = (Double[][]) session.getAttribute( "data2" ); + + + String[] series1S = (String[]) session.getAttribute( "series1" ); + // String[] series2S = (String[]) session.getAttribute( "series2" ); + String[] categories1S = (String[]) session.getAttribute( "categories1" ); + // String[] categories2S = (String[]) session.getAttribute( "categories2" ); + + // series2 = (String[]) session.getAttribute( "series2" ); + + chartTitle = (String) session.getAttribute( "chartTitle" ); + xAxis_Title = (String) session.getAttribute( "xAxisTitle" ); + yAxis_Title = (String) session.getAttribute( "yAxisTitle" ); + + initialzeAllLists( series1S, categories1S ); + /* + System.out.println( "\n data1 : " + objData1 ); + System.out.println( "\n series1 : " + series1S ); + System.out.println( "\n categories1 : " + categories1S ); + System.out.println( "\n chartTitle : " + chartTitle ); + System.out.println( "\n xAxisTitle : " + xAxis_Title ); + System.out.println( "\n yAxisTitle : " + yAxis_Title ); + */ + + if( objData1 == null || series1 == null || categories1 == null || chartTitle == null || xAxis_Title == null || yAxis_Title == null ) + System.out.println("Session Objects are null"); + else + System.out.println("Session Objects are not null"); + + data1 = convertDoubleTodouble( objData1 ); + // data2 = convertDoubleTodouble( objData2 ); + + if(chartDisplayOption == null || chartDisplayOption.equalsIgnoreCase("none")) { } + else if(chartDisplayOption.equalsIgnoreCase("ascend")) { sortByAscending(); } + else if(chartDisplayOption.equalsIgnoreCase("desend")) { sortByDesscending(); } + else if(chartDisplayOption.equalsIgnoreCase("alphabet")) { sortByAlphabet(); } + + initializeDataLists(); + + System.out.println( "current chart Type is : " + currentChart + "And Chart Display Option is : " + chartDisplayOption ); + + if ( currentChart == null ) + { + System.out.println( "current chart is null" ); + currentChart = "Vertical3DBarChart"; + } + + else if ( currentChart.equals( "Vertical3DBarChart" ) ) + { + System.out.println( "Vertical3DBarChart" ); + selChart = new Vertical3DBarChart(); + } + else if ( currentChart.equals( "Horizontal3DBarChart" ) ) + { + System.out.println( "\n\n Horizontal3DBarChart" ); + selChart = new Horizontal3DBarChart(); + } + else if ( currentChart.equals( "LineChart" ) ) + { + System.out.println( "\n\n LineChart" ); + selChart = new LineChart(); + } + else if ( currentChart.equals( "LineAndBarChart" ) ) + { + System.out.println( "\n\n LineAndBarChart" ); + selChart = new LineAndBarChart(); + } + + else if ( currentChart.equals( "AreaChart" ) ) + { + System.out.println( "\n\n AreaChart" ); + selChart = new AreaChart(); + } +/* else if ( currentChart.equals( "DualAxisChart" ) ) + { + //System.out.println( "DualAxisChart" ); + selChart = new DualAxisChart(); + } + + + else if ( currentChart.equals( "PieChart3D" ) ) + { + //System.out.println( "PieChart3D" ); + selChart = new PieChart3D(); + } + else if ( currentChart.equals( "SurveyChart" ) ) + { + //System.out.println( "SurveyChart" ); + selChart = new SurveyChart(); + } +*/ + // chart = selChart.getChartViewer( data1, series1, categories1, chartTitle, xAxis_Title, yAxis_Title ); + chart = selChart.getChartViewergetChartViewerDataElement( data1, series1, categories1, chartTitle, xAxis_Title, yAxis_Title ); + + + // Saving chart into Session + ChartRenderingInfo info = null; + try + { + info = new ChartRenderingInfo(new StandardEntityCollection()); + BufferedImage chartImage = chart.createBufferedImage(700, 500, info); + session.setAttribute("chartImage", chartImage); + + session.setAttribute( "headingInfo", headingInfo ); + + } + catch(Exception e) + { + System.out.println(e.getMessage()); + } + + return SUCCESS; + }// execute end + + + public void initializeDataLists() + { + int i; + headingInfo = ""; + + for(i=0; i < categories1.length; i++) + { + headingInfo += ""; + } + headingInfo +=""; + + for(i=0; i"+series1[i]+""; + for(int j=0; j"+data1[i][j]+""; + } + } + + headingInfo += "
Service Name"+categories1[i]+"
"; + } + + public void initialzeAllLists(String[]series1S, String[] categories1S ) + + { + int i; + series1 = new String[series1S.length]; + // series2 = new String[series2S.length]; + categories1 = new String[categories1S.length]; + // categories2 = new String[categories2S.length]; + + for(i = 0; i < series1S.length; i++) + { + series1[i] = series1S[i]; + } +/* + for(i = 0; i < series2S.length; i++) + { + series2[i] = series2S[i]; + } +*/ + for(i = 0; i < categories1S.length; i++) + { + categories1[i] = categories1S[i]; + } +/* + for(i = 0; i < categories2S.length; i++) + { + categories2[i] = categories2S[i]; + } +*/ + } + + public double[][] convertDoubleTodouble( Double[][] objData ) + { + //System.out.println("Before Sorting : "); + //double[][] data = new double[series1.length][categories1.length]; + double[][] data = new double[objData.length][objData[0].length]; + for ( int i = 0; i < objData.length; i++ ) + { + for ( int j = 0; j < objData[0].length; j++ ) + { + // System.out.println(objData[i][j]); + data[i][j] = objData[i][j].doubleValue(); + // System.out.print(categories1[j]+": "+data[i][j]+", "); + } + //System.out.println(""); + } + + return data; + }// convertDoubleTodouble end + + public void sortByAscending() + { + for(int i=0; i < categories1.length-1 ; i++) + { + for(int j=0; j < categories1.length-1-i; j++) + { + if(data1[0][j] > data1[0][j+1]) + { + for(int k=0; k data2[0][j+1]) + { + for(int k=0; k 0) + { + for(int k=0; k 0) + { + for(int k=0; k dataElementComparator; + + public void setDataElementComparator( Comparator dataElementComparator ) + { + this.dataElementComparator = dataElementComparator; + } +*/ + // -------------------------------------------------------------------------- + // Parameters + // -------------------------------------------------------------------------- + + private HttpSession session; + + public HttpSession getSession() + { + return session; + } + + private List selectedOptionComboList; + + private List selectedServiceList; + + public List getSelectedServiceList() + { + return selectedServiceList; + } + + private List selOUList; + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- +/* + private List selectedDataElements; + + public void setSelectedDataElements( List selectedDataElements ) + { + this.selectedDataElements = selectedDataElements; + } +*/ + private List selectedDataElements; + + + public void setSelectedDataElements( List selectedDataElements ) + { + this.selectedDataElements = selectedDataElements; + } + + private String deSelection; + + public void setDeSelection( String deSelection ) + { + this.deSelection = deSelection; + } + +/* + private List ougGroupSetCB; + + public List getOugGroupSetCB() + { + return ougGroupSetCB; + } + + public void setOugGroupSetCB( List ougGroupSetCB ) + { + this.ougGroupSetCB = ougGroupSetCB; + } +*/ + + private String ougGroupSetCB; + + public void setOugGroupSetCB( String ougGroupSetCB ) + { + this.ougGroupSetCB = ougGroupSetCB; + } + + public String getOugGroupSetCB() + { + return ougGroupSetCB; + } + + private List orgUnitGroupList; + + + public List getOrgUnitGroupList() + { + return orgUnitGroupList; + } + + public void setOrgUnitGroupList( List orgUnitGroupList ) + { + this.orgUnitGroupList = orgUnitGroupList; + } + + private String aggDataCB; + + public void setAggDataCB( String aggDataCB ) + { + this.aggDataCB = aggDataCB; + } + + private List orgUnitListCB; + + public void setOrgUnitListCB( List orgUnitListCB ) + { + this.orgUnitListCB = orgUnitListCB; + } + + private String categoryLB; + + public String getCategoryLB() + { + return categoryLB; + } + + public void setCategoryLB( String categoryLB ) + { + this.categoryLB = categoryLB; + } + + private String selectedButton; + + public String getSelectedButton() + { + return selectedButton; + } + + public void setSelectedButton( String selectedButton ) + { + this.selectedButton = selectedButton; + } + + private String periodTypeLB; + + public void setPeriodTypeLB( String periodTypeLB ) + { + this.periodTypeLB = periodTypeLB; + } + + private List yearLB; + + public void setYearLB( List yearLB ) + { + this.yearLB = yearLB; + } + + private List periodLB; + + public void setPeriodLB( List periodLB ) + { + this.periodLB = periodLB; + } + + private List periodNames; + + private List selStartPeriodList; + + private List selEndPeriodList; + + private DataElementChartResult dataElementChartResult; + + public DataElementChartResult getDataElementChartResult() + { + return dataElementChartResult; + } + + private OrganisationUnit selectedOrgUnit; + + private OrganisationUnitGroup selOrgUnitGroup; + + private List selOUGroupMemberList = new ArrayList(); + //public List orgUnit; + +// public List decoc ; + +/* + String chartTitle ; + + public String getChartTitle() + { + return chartTitle; + } + + String xAxis_Title; + + public String getXAxis_Title() + { + return xAxis_Title; + } + + String yAxis_Title; + + public String getYAxis_Title() + { + return yAxis_Title; + } +*/ + + List yseriesList; + + public List getYseriesList() + { + return yseriesList; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + + + + @SuppressWarnings( "unchecked" ) public String execute() throws Exception { - - + statementManager.initialise(); + selectedOptionComboList = new ArrayList(); + + selOUList = new ArrayList(); + System.out.println( "selected orgUnit size : " + orgUnitListCB.size() ); + + System.out.println( "selected Year size : " + yearLB.size()); + + // System.out.println( "selected Period size : " + periodLB.size()); + + System.out.println( "selected dataelements : " + selectedDataElements); + + System.out.println( "selected dataelements size : " + selectedDataElements.size()); + + // int flag = 0; + // selOUList = new ArrayList(); + selStartPeriodList = new ArrayList(); + selEndPeriodList = new ArrayList(); + + yseriesList = new ArrayList(); + // DataElement dElement = new DataElement(); + + // DataElementCategoryOptionCombo decoc1 = new DataElementCategoryOptionCombo(); + // int countForServiceList = 0; + + // ouChildCountMap = new HashMap(); + + String monthOrder[] = { "04", "05", "06", "07", "08", "09", "10", "11", "12", "01", "02", "03" }; + int monthDays[] = { 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31 }; + + /* Period Info */ + + String startD = ""; + String endD = ""; + + SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "MMM-yyyy" ); + + periodNames = new ArrayList(); + + for ( String year : yearLB ) + { + int selYear = Integer.parseInt( year.split( "-" )[0] ); + + if ( periodTypeLB.equalsIgnoreCase( YearlyPeriodType.NAME ) ) + { + + startD = "" + selYear + "-04-01"; + endD = "" + (selYear + 1) + "-03-31"; + + selStartPeriodList.add( format.parseDate( startD ) ); + selEndPeriodList.add( format.parseDate( endD ) ); + + periodNames.add( "" + selYear + "-" + (selYear + 1) ); + + continue; + + } + + for ( String periodStr : periodLB ) + { + int period = Integer.parseInt( periodStr ); + + if ( periodTypeLB.equalsIgnoreCase( MonthlyPeriodType.NAME ) ) + { + simpleDateFormat = new SimpleDateFormat( "MMM-yyyy" ); + + if ( period >= 9 ) + { + startD = "" + (selYear + 1) + "-" + monthOrder[period] + "-01"; + endD = "" + (selYear + 1) + "-" + monthOrder[period] + "-" + monthDays[period]; + + if ( (selYear + 1) % 4 == 0 && period == 10 ) + { + endD = "" + (selYear + 1) + "-" + monthOrder[period] + "-" + (monthDays[period] + 1); + } + } + else + { + startD = "" + selYear + "-" + monthOrder[period] + "-01"; + endD = "" + selYear + "-" + monthOrder[period] + "-" + monthDays[period]; + } + + selStartPeriodList.add( format.parseDate( startD ) ); + selEndPeriodList.add( format.parseDate( endD ) ); + periodNames.add( simpleDateFormat.format( format.parseDate( startD ) ) ); + } + else if ( periodTypeLB.equalsIgnoreCase( QuarterlyPeriodType.NAME ) ) + { + if ( period == 0 ) + { + startD = "" + selYear + "-04-01"; + endD = "" + selYear + "-06-30"; + periodNames.add( selYear + "-Q1" ); + } + else if ( period == 1 ) + { + startD = "" + selYear + "-07-01"; + endD = "" + selYear + "-09-30"; + periodNames.add( selYear + "-Q2" ); + } + else if ( period == 2 ) + { + startD = "" + selYear + "-10-01"; + endD = "" + selYear + "-12-31"; + periodNames.add( selYear + "-Q3" ); + } + else + { + startD = "" + (selYear + 1) + "-01-01"; + endD = "" + (selYear + 1) + "-03-31"; + periodNames.add( (selYear) + "-Q4" ); + } + selStartPeriodList.add( format.parseDate( startD ) ); + selEndPeriodList.add( format.parseDate( endD ) ); + } + else if ( periodTypeLB.equalsIgnoreCase( SixMonthlyPeriodType.NAME ) ) + { + if ( period == 0 ) + { + startD = "" + selYear + "-04-01"; + endD = "" + selYear + "-09-30"; + periodNames.add( selYear + "-HY1" ); + } + else + { + startD = "" + selYear + "-10-01"; + endD = "" + (selYear + 1) + "-03-31"; + periodNames.add( selYear + "-HY2" ); + } + selStartPeriodList.add( format.parseDate( startD ) ); + selEndPeriodList.add( format.parseDate( endD ) ); + } + + System.out.println( startD + " : " + endD ); + } + + } + + // DataElement Information + + List dataElementList = new ArrayList(); + + if ( deSelection == null ) + { + System.out.println( "deOptionValue is null" ); + return null; + } + else + { + //System.out.println( "deOptionValue : " + deSelection ); + } + + System.out.println("\n\n\n ===== \n deSelection: " + deSelection); + + + + if ( deSelection.equalsIgnoreCase( OPTIONCOMBO ) ) + { + // System.out.println("\n\n\n ===== \n deSelection: OK "); + Iterator deIterator = selectedDataElements.iterator(); + + // dElement = (DataElement) deIterator.next(); + + while ( deIterator.hasNext() ) + { + String serviceId = (String) deIterator.next(); + String partsOfServiceId[] = serviceId.split( ":" ); + int dataElementId = Integer.parseInt( partsOfServiceId[0] ); + DataElement dataElement = dataElementService.getDataElement( dataElementId ); + // selectedServiceList.add( dataElement ); + dataElementList.add( dataElement ); + int optionComboId = Integer.parseInt( partsOfServiceId[1] ); + DataElementCategoryOptionCombo decoc = dataElementCategoryService.getDataElementCategoryOptionCombo( optionComboId ); + selectedOptionComboList.add( decoc ); + // chartTitle += dataElement.getName() + " : " + dataElementCategoryService.getDataElementCategoryOptionCombo( decoc ).getName() + ", "; + /* + decoc1 = selectedOptionComboList.get( countForServiceList ); + yseriesList.add( dElement.getName() + " : " + dataElementCategoryService.getDataElementCategoryOptionCombo( decoc1 ).getName() ); + System.out.println( "Data Elenent name is : " + dElement.getName() + " categoryOptionCombo is : " + dataElementCategoryService.getDataElementCategoryOptionCombo( decoc1 ).getName() ); + */ + } + + + } + else + { + Iterator deIterator = selectedDataElements.iterator(); + while ( deIterator.hasNext() ) + { + int serviceID = Integer.parseInt( (String) deIterator.next() ); + DataElement dataElement = dataElementService.getDataElement( serviceID ); + // selectedServiceList.add( dataElement ); + dataElementList.add( dataElement ); + // chartTitle += dataElement.getName() + ", "; + /* yseriesList.add( dElement.getName() ); + System.out.println( "Data Elenent name is : " + dElement.getName() );*/ + } + + } + //Collections.sort( dataElementList, dataElementComparator ); + selectedServiceList = new ArrayList( dataElementList ); + + // OrgUnit Information + + for ( String ouStr : orgUnitListCB ) + { + OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( ouStr ) ); + selOUList.add( orgUnit ); + } + + Calendar now = Calendar.getInstance();//for mili seconds + + // calling individual Function + if ( categoryLB.equalsIgnoreCase( PERIODWISE )&& ougGroupSetCB == null ) + { + System.out.println( "Inside PeriodWise Chart Data" ); + System.out.println( "Chart Generation Start Time is : \t" + new Date() ); + + + dataElementChartResult = generateChartDataPeriodWise( selStartPeriodList,selEndPeriodList,periodNames,dataElementList,selectedOptionComboList,selOUList.iterator().next() ); + /* + ActionContext ctx = ActionContext.getContext(); + HttpServletRequest req = (HttpServletRequest) ctx.get( ServletActionContext.HTTP_REQUEST ); + + session = req.getSession(); + /* + #foreach( ) + $dataElementChartResult.data[$count1][$count2] + #end + *//* + Integer i = dataElementChartResult.getCategories().length; + System.out.println( "\n Categories Length is " + i ); + + Integer j = dataElementChartResult.getSeries().length; + System.out.println( "\n Series Length is " + j ); + + session.setAttribute( "data1", dataElementChartResult.getData() ); + session.setAttribute( "series1", dataElementChartResult.getSeries() ); + session.setAttribute( "categories1", dataElementChartResult.getCategories() ); + session.setAttribute( "chartTitle", dataElementChartResult.getChartTitle() ); + session.setAttribute( "xAxisTitle", dataElementChartResult.getXAxis_Title() ); + session.setAttribute( "yAxisTitle", dataElementChartResult.getYAxis_Title() ); + */ + + } + else if ( categoryLB.equalsIgnoreCase( CHILDREN ) && ougGroupSetCB == null ) + { + System.out.println( "Inside Child Wise Chart Data" ); + System.out.println( "Chart Generation Start Time is : \t" + new Date() ); + + selectedOrgUnit = new OrganisationUnit(); + selectedOrgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitListCB.get( 0 ) ) ); + + List childOrgUnitList = new ArrayList(); + childOrgUnitList = new ArrayList( selectedOrgUnit.getChildren()); + + + dataElementChartResult = generateChartDataWithChildrenWise( selStartPeriodList,selEndPeriodList,periodNames,dataElementList,selectedOptionComboList,childOrgUnitList ); + + } + else if ( categoryLB.equalsIgnoreCase( SELECTED ) && ougGroupSetCB == null ) + { + + System.out.println( "Inside Selected OrgUnit Chart Data" ); + System.out.println( "Chart Generation Start Time is : \t" + new Date() ); + + dataElementChartResult = generateChartDataSelectedOrgUnitWise( selStartPeriodList,selEndPeriodList,periodNames,dataElementList,selectedOptionComboList,selOUList ); + + } + + else if ( categoryLB.equalsIgnoreCase( PERIODWISE ) && ougGroupSetCB != null ) + { + System.out.println( "Inside Period dWise With OrgGroup Chart Data" ); + System.out.println( "Chart Generation Start Time is : \t" + new Date() + "Mili seconds is : " + now.getTimeInMillis() ); + + //finding the common list of selected org unit and selected Group + + // selOUList = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitListCB.get( 0 ) ) ); + + selectedOrgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitListCB.get( 0 ) ) ); + List orgUnitChildList = new ArrayList( organisationUnitService.getOrganisationUnitWithChildren( selectedOrgUnit.getId() ) ); + + System.out.println( "oug Group Set is = " + orgUnitGroupList ); + + selOrgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( Integer.parseInt( orgUnitGroupList.get( 0 ) ) ); + // String selOrgGroupname = selOrgUnitGroup.getName(); + selOUGroupMemberList = new ArrayList( selOrgUnitGroup.getMembers() ); + + // System.out.println( "Report Generation Start Time is : \t" + new Date() + "Mili seconds is : " + now.getTimeInMillis() ); + + // System.out.println( "Size of Group member is before retain : " + selOUGroupMemberList.size() ); + + selOUGroupMemberList.retainAll( orgUnitChildList ); + + // orgUnitChildList.retainAll( selOUGroupMemberList ); + /* + System.out.println( "Size of Group member is after retain : " + selOUGroupMemberList.size() ); + + System.out.println( "Report Generation End Time is : \t" + new Date()+ "Mili seconds is : " + now.getTimeInMillis() ); + + System.out.println( "OruUnit: " + selectedOrgUnit.getName() + "Group Name is : " + selOrgUnitGroup.getName() + "Size of Group member after retain is : " + selOUGroupMemberList.size() ); + + System.out.println( "Inside PeriodWise With OrgGroup Chart Data" ); + */ + + // dataElementChartResult = generateChartDataOrgGroupPeriodWise(selStartPeriodList,selEndPeriodList,periodNames,dataElementList,selectedOptionComboList,selectedOrgUnit,selOrgUnitGroup,selOUGroupMemberList); + dataElementChartResult = generateChartDataOrgGroupPeriodWise(selStartPeriodList,selEndPeriodList,periodNames,dataElementList,selectedOptionComboList,selOUGroupMemberList); + + } + + else if ( categoryLB.equalsIgnoreCase( CHILDREN ) && ougGroupSetCB != null ) + { + System.out.println( "Inside ChildWise With OrgGroup Chart Data" ); + System.out.println( "Chart Generation Start Time is : \t" + new Date() ); + + selectedOrgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitListCB.get( 0 ) ) ); + List orgUnitChildList = new ArrayList( organisationUnitService.getOrganisationUnitWithChildren( selectedOrgUnit.getId() ) ); + + int groupCount = 0; + System.out.println("\n\n ++++++++++++++++++++++ \n orgUnitGroup : " + orgUnitGroupList ); + for ( String orgUnitGroupId : orgUnitGroupList ) + { + OrganisationUnitGroup selOrgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( Integer.parseInt( orgUnitGroupId ) ); + + List selectedOUGroupMemberList = new ArrayList( selOrgUnitGroup.getMembers() ); + + selOUGroupMemberList.addAll( selectedOUGroupMemberList ); + + System.out.println( "Total Size of " + groupCount + " : " + selOUGroupMemberList.size() ); + + groupCount++; + + } + + // System.out.println( "Total Size of " + selOUGroupMemberList.size() ); + + // System.out.println( "Report Generation Start Time is : \t" + new Date() + "Mili seconds is : " + now.getTimeInMillis() ); + + // System.out.println( "Size of Group member is before retain : " + selOUGroupMemberList.size() + " ,Size of Child Member is :" + orgUnitChildList.size() ); + + selOUGroupMemberList.retainAll( orgUnitChildList ); + + // System.out.println( "Report Generation End Time is : \t" + new Date()+ "Mili seconds is : " + now.getTimeInMillis() ); + + // System.out.println( "OruUnit: " + selectedOrgUnit.getName() + " Group Size is : " + orgUnitGroupList.size() + " ,Size of Group member after retain is : " + selOUGroupMemberList.size() ); + // generateChartDataOrgGroupChildWise(); + + // calling sane function in case of SelectedOrgUnit Chart Data + dataElementChartResult = generateChartDataSelectedOrgUnitWise( selStartPeriodList,selEndPeriodList,periodNames,dataElementList,selectedOptionComboList,selOUGroupMemberList ); + + + } + + else if ( categoryLB.equalsIgnoreCase( SELECTED ) && ougGroupSetCB != null ) + { + System.out.println( "Inside Selected With OrgGroup Chart Data" ); + System.out.println( "Chart Generation Start Time is : \t" + new Date() ); + + Map> orgUnitGroupMap = new HashMap>(); + + System.out.println( "Inside SelectedOrgUnit With OrgGroup Chart Data" ); + + selectedOrgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitListCB.get( 0 ) ) ); + List orgUnitChildList = new ArrayList( organisationUnitService.getOrganisationUnitWithChildren( selectedOrgUnit.getId() ) ); + + for ( String orgUnitGroupId : orgUnitGroupList ) + { + OrganisationUnitGroup selOrgUnitGroup = organisationUnitGroupService.getOrganisationUnitGroup( Integer.parseInt( orgUnitGroupId ) ); + List selectedOUGroupMemberList = new ArrayList( selOrgUnitGroup.getMembers() ); + + selectedOUGroupMemberList.retainAll( orgUnitChildList ); + + orgUnitGroupMap.put( selOrgUnitGroup, selectedOUGroupMemberList); + //selOUGroupMemberList.addAll( selectedOUGroupMemberList ); + } + + // System.out.println( "selOrgUnitGroup Size is : " + orgUnitGroupMap.keySet().size() ); + + dataElementChartResult = generateChartDataSelectedOrgUnitGroupWise( selStartPeriodList,selEndPeriodList,periodNames,dataElementList,selectedOptionComboList,orgUnitGroupMap ); + + } + + ActionContext ctx = ActionContext.getContext(); + HttpServletRequest req = (HttpServletRequest) ctx.get( ServletActionContext.HTTP_REQUEST ); + + session = req.getSession(); + + session.setAttribute( "data1", dataElementChartResult.getData() ); + session.setAttribute( "series1", dataElementChartResult.getSeries() ); + session.setAttribute( "categories1", dataElementChartResult.getCategories() ); + session.setAttribute( "chartTitle", dataElementChartResult.getChartTitle() ); + session.setAttribute( "xAxisTitle", dataElementChartResult.getXAxis_Title() ); + session.setAttribute( "yAxisTitle", dataElementChartResult.getYAxis_Title() ); + + System.out.println( "Chart Generation End Time is : \t" + new Date() ); + statementManager.destroy(); return SUCCESS; } // execute end + + // Supporting Methods + // ------------------------------------------------------------------------- + // Methods for getting Chart Data only Period Wise start + // ------------------------------------------------------------------------- + + + public DataElementChartResult generateChartDataPeriodWise( List selStartPeriodList,List selEndPeriodList,List periodNames,List dataElementList,List decocList,OrganisationUnit orgUnit ) throws Exception + { + DataElementChartResult dataElementChartResult; + + String[] series = new String[dataElementList.size()]; + String[] categories = new String[selStartPeriodList.size()]; + Double[][] data = new Double[dataElementList.size()][selStartPeriodList.size()]; + String chartTitle = "OrganisationUnit : " + orgUnit.getShortName(); + String xAxis_Title = "Time Line"; + String yAxis_Title = "Value"; + + // System.out.println("\n\n +++ \n decoc : " + decocList); + + int serviceCount = 0; + + for( DataElement dataElement : dataElementList ) + { + DataElementCategoryOptionCombo decoc; + + if ( deSelection.equalsIgnoreCase( OPTIONCOMBO ) ) + + // if( dataElement.isMultiDimensional() ) + { + decoc = decocList.get( serviceCount ); + + series[serviceCount] = dataElement.getName() + " : " + decoc.getName(); + yseriesList.add( dataElement.getName() + " : " + decoc.getName() ); + } + else + { + decoc = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo(); + series[serviceCount] = dataElement.getName(); + + yseriesList.add( dataElement.getName() ); + } + + int periodCount = 0; + for( Date startDate : selStartPeriodList ) + { + Date endDate = selEndPeriodList.get( periodCount ); + + categories[periodCount] = periodNames.get( periodCount ); + + Double aggDataValue = 0.0; + if( aggDataCB != null ) + { + aggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, startDate, endDate, orgUnit ); + //System.out.println( "Agg data value before is : " + aggDataValue ); + if(aggDataValue == null ) aggDataValue = 0.0; + //System.out.println( "Agg data value after zero assign is : " + aggDataValue ); + } + else + { + PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB ); + Collection periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate ); + + for( Period period : periods ) + { + DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period, decoc ); + + try + { + aggDataValue += Double.parseDouble( dataValue.getValue() ); + } + catch( Exception e ) + { + + } + } + } + + data[serviceCount][periodCount] = aggDataValue; + + periodCount++; + } + + serviceCount++; + } + + dataElementChartResult = new DataElementChartResult( series, categories, data, chartTitle, xAxis_Title, yAxis_Title ); + return dataElementChartResult; + } + + // ------------------------------------------------------------------------- + // Methods for getting Chart Data only Period Wise end + // ------------------------------------------------------------------------- + + + // ------------------------------------------------------------------------- + // Methods for getting Chart Data With Children Wise start + // ------------------------------------------------------------------------- + + public DataElementChartResult generateChartDataWithChildrenWise( List selStartPeriodList,List selEndPeriodList,List periodNames,List dataElementList,List decocList,List childOrgUnitList ) throws Exception + { + DataElementChartResult dataElementChartResult; + + String[] series = new String[dataElementList.size()]; + String[] categories = new String[childOrgUnitList.size()]; + Double[][] data = new Double[dataElementList.size()][childOrgUnitList.size()]; + String chartTitle = "OrganisationUnit : " + selectedOrgUnit.getShortName(); + + // String chartTitle = "OrganisationUnit : " + orgUnit.getShortName(); + String xAxis_Title = "Facilities"; + String yAxis_Title = "Value"; + + // System.out.println("\n\n +++ \n decoc : " + decocList); + + int serviceCount = 0; + + for( DataElement dataElement : dataElementList ) + { + DataElementCategoryOptionCombo decoc; + + if ( deSelection.equalsIgnoreCase( OPTIONCOMBO ) ) + + // if( dataElement.isMultiDimensional() ) + { + decoc = decocList.get( serviceCount ); + + series[serviceCount] = dataElement.getName() + " : " + decoc.getName(); + yseriesList.add( dataElement.getName() + " : " + decoc.getName() ); + } + else + { + decoc = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo(); + series[serviceCount] = dataElement.getName(); + + yseriesList.add( dataElement.getName() ); + } + + int childCount = 0; + for( OrganisationUnit orgChild : childOrgUnitList ) + { + + categories[childCount] = orgChild.getName(); + + Double aggDataValue = 0.0; + + int periodCount = 0; + for( Date startDate : selStartPeriodList ) + { + Date endDate = selEndPeriodList.get( periodCount ); + PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB ); + Collection periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate ); + + for( Period period : periods ) + { + + if( aggDataCB != null ) + { + Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, period.getStartDate(), period.getEndDate(), orgChild ); + // System.out.println( "Agg data value before is : " + aggDataValue ); + + if(tempAggDataValue != null ) aggDataValue += tempAggDataValue; + // System.out.println( "Agg data value after zero assign is : " + aggDataValue ); + } + else + { + DataValue dataValue = dataValueService.getDataValue( orgChild, dataElement, period, decoc ); + + try + { + aggDataValue += Double.parseDouble( dataValue.getValue() ); + } + catch( Exception e ) + { + + } + + } + } + periodCount++; + } + + data[serviceCount][childCount] = aggDataValue; + childCount++; + + } + + serviceCount++; + } + + dataElementChartResult = new DataElementChartResult( series, categories, data, chartTitle, xAxis_Title, yAxis_Title ); + return dataElementChartResult; + } + // ------------------------------------------------------------------------- + // Methods for getting Chart Data With Children Wise end + // ------------------------------------------------------------------------- + + + // ------------------------------------------------------------------------- + // Methods for getting Chart Data With Selected Wise start + // ------------------------------------------------------------------------- + + public DataElementChartResult generateChartDataSelectedOrgUnitWise( List selStartPeriodList,List selEndPeriodList,List periodNames,List dataElementList,List decocList,List selOUList ) throws Exception + { + DataElementChartResult dataElementChartResult; + + String[] series = new String[dataElementList.size()]; + String[] categories = new String[selOUList.size()]; + Double[][] data = new Double[dataElementList.size()][selOUList.size()]; + String chartTitle = "OrganisationUnit : -----" ; + + // String chartTitle = "OrganisationUnit : " + orgUnit.getShortName(); + String xAxis_Title = "Facilities"; + String yAxis_Title = "Value"; + + // System.out.println("\n\n +++ \n decoc : " + decocList); + + int serviceCount = 0; + + for( DataElement dataElement : dataElementList ) + { + DataElementCategoryOptionCombo decoc; + + if ( deSelection.equalsIgnoreCase( OPTIONCOMBO ) ) + + // if( dataElement.isMultiDimensional() ) + { + decoc = decocList.get( serviceCount ); + + series[serviceCount] = dataElement.getName() + " : " + decoc.getName(); + yseriesList.add( dataElement.getName() + " : " + decoc.getName() ); + } + else + { + decoc = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo(); + series[serviceCount] = dataElement.getName(); + + yseriesList.add( dataElement.getName() ); + } + + int orgUnitCount = 0; + for( OrganisationUnit orgunit : selOUList ) + { + categories[orgUnitCount] = orgunit.getName(); + + Double aggDataValue = 0.0; + + int periodCount = 0; + for( Date startDate : selStartPeriodList ) + { + Date endDate = selEndPeriodList.get( periodCount ); + PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB ); + Collection periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate ); + + for( Period period : periods ) + { + + if( aggDataCB != null ) + { + Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, period.getStartDate(), period.getEndDate(), orgunit ); + //System.out.println( "Agg data value before is : " + aggDataValue ); + + if(tempAggDataValue != null ) aggDataValue += tempAggDataValue; + // System.out.println( "Agg data value after zero assign is : " + aggDataValue ); + } + else + { + + DataValue dataValue = dataValueService.getDataValue( orgunit, dataElement, period, decoc ); + + try + { + aggDataValue += Double.parseDouble( dataValue.getValue() ); + } + catch( Exception e ) + { + + } + + } + } + periodCount++; + } + + data[serviceCount][orgUnitCount] = aggDataValue; + orgUnitCount++; + + } + + serviceCount++; + } + + dataElementChartResult = new DataElementChartResult( series, categories, data, chartTitle, xAxis_Title, yAxis_Title ); + return dataElementChartResult; + } + // ------------------------------------------------------------------------- + // Methods for getting Chart Data With Selected Wise end + // ------------------------------------------------------------------------- + + // ------------------------------------------------------------------------- + // Methods for getting Chart Data OrgGroup Period Wise start + // ------------------------------------------------------------------------- + + public DataElementChartResult generateChartDataOrgGroupPeriodWise( List selStartPeriodList,List selEndPeriodList,List periodNames,List dataElementList,List decocList,List selOUGroupMemberList ) throws Exception + { + DataElementChartResult dataElementChartResult; + + String[] series = new String[dataElementList.size()]; + String[] categories = new String[selStartPeriodList.size()]; + Double[][] data = new Double[dataElementList.size()][selStartPeriodList.size()]; + String chartTitle = "OrganisationUnit : " + selectedOrgUnit.getShortName()+ "(" + selOrgUnitGroup.getName() + ")"; + String xAxis_Title = "Time Line"; + String yAxis_Title = "Value"; + + + int serviceCount = 0; + + for( DataElement dataElement : dataElementList ) + { + DataElementCategoryOptionCombo decoc; + + if ( deSelection.equalsIgnoreCase( OPTIONCOMBO ) ) + + // if( dataElement.isMultiDimensional() ) + { + decoc = decocList.get( serviceCount ); + + series[serviceCount] = dataElement.getName() + " : " + decoc.getName(); + yseriesList.add( dataElement.getName() + " : " + decoc.getName() ); + } + else + { + decoc = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo(); + series[serviceCount] = dataElement.getName(); + + yseriesList.add( dataElement.getName() ); + } + + Double aggDataValue = 0.0; + + int periodCount = 0; + for( Date startDate : selStartPeriodList ) + { + Date endDate = selEndPeriodList.get( periodCount ); + categories[periodCount] = periodNames.get( periodCount ); + + PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB ); + Collection periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate ); + + for( Period period : periods ) + { + int orgGroupCount = 0; + + for( OrganisationUnit orgUnit : selOUGroupMemberList ) + { + + if( aggDataCB != null ) + { + Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, period.getStartDate(), period.getEndDate(), orgUnit ); + // System.out.println( "Agg data value before is : " + aggDataValue ); + + if(tempAggDataValue != null ) aggDataValue += tempAggDataValue; + // System.out.println( "Agg data value after zero assign is : " + aggDataValue ); + } + else + { + + DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period, decoc ); + + try + { + aggDataValue += Double.parseDouble( dataValue.getValue() ); + } + catch( Exception e ) + { + + } + + } + orgGroupCount++; + } + + + } + + data[serviceCount][periodCount] = aggDataValue; + periodCount++; + } + + serviceCount++; + } + + dataElementChartResult = new DataElementChartResult( series, categories, data, chartTitle, xAxis_Title, yAxis_Title ); + + return dataElementChartResult; + + } + // ------------------------------------------------------------------------- + // Methods for getting Chart Data OrgGroup Period Wise end + // ------------------------------------------------------------------------- + + // ------------------------------------------------------------------------- + // Methods for getting Chart Data OrgGroup Selected orgUnit Wise start + // ------------------------------------------------------------------------- + + public DataElementChartResult generateChartDataSelectedOrgUnitGroupWise( List selStartPeriodList,List selEndPeriodList,List periodNames,List dataElementList,List decocList,Map> orgUnitGroupMap ) throws Exception + { + DataElementChartResult dataElementChartResult; + + String[] series = new String[dataElementList.size()]; + String[] categories = new String[orgUnitGroupMap.keySet().size()]; + Double[][] data = new Double[dataElementList.size()][orgUnitGroupMap.keySet().size()]; + String chartTitle = "OrganisationUnit : " + selectedOrgUnit.getShortName() +" - "; + String xAxis_Title = "Organisation Unit Group"; + String yAxis_Title = "Value"; + + + int serviceCount = 0; + + for( DataElement dataElement : dataElementList ) + { + DataElementCategoryOptionCombo decoc; + + if ( deSelection.equalsIgnoreCase( OPTIONCOMBO ) ) + + // if( dataElement.isMultiDimensional() ) + { + decoc = decocList.get( serviceCount ); + + series[serviceCount] = dataElement.getName() + " : " + decoc.getName(); + yseriesList.add( dataElement.getName() + " : " + decoc.getName() ); + } + else + { + decoc = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo(); + series[serviceCount] = dataElement.getName(); + + yseriesList.add( dataElement.getName() ); + } + + int orgGroupCount = 0; + // int orgGroupCount1 = 0; + Double aggDataValue = 0.0; + + for( OrganisationUnitGroup orgUnitGroup : orgUnitGroupMap.keySet() ) + { + // Double aggDataValue = 0.0; + categories[orgGroupCount] = orgUnitGroup.getName(); + + if( serviceCount == 0 ) + { + chartTitle += orgUnitGroup.getName() + ","; + } + Collection orgUnitGroupMembers = orgUnitGroup.getMembers(); + if( orgUnitGroupMembers == null || orgUnitGroupMembers.size() == 0 ) + { + data[serviceCount][orgGroupCount] = aggDataValue; + orgGroupCount++; + continue; + } + for( OrganisationUnit orgUnit : orgUnitGroup.getMembers() ) + { + + int periodCount = 0; + for( Date startDate : selStartPeriodList ) + { + Date endDate = selEndPeriodList.get( periodCount ); + + PeriodType periodType = periodService.getPeriodTypeByName( periodTypeLB ); + Collection periods = periodService.getPeriodsBetweenDates( periodType, startDate, endDate ); + + for( Period period : periods ) + { + + if( aggDataCB != null ) + { + Double tempAggDataValue = aggregationService.getAggregatedDataValue( dataElement, decoc, period.getStartDate(), period.getEndDate(), orgUnit ); + // System.out.println( "Agg data value before is : " + aggDataValue ); + + if(tempAggDataValue != null ) aggDataValue += tempAggDataValue; + // System.out.println( "Agg data value after zero assign is : " + aggDataValue ); + } + else + { + DataValue dataValue = dataValueService.getDataValue( orgUnit, dataElement, period, decoc ); + + try + { + aggDataValue += Double.parseDouble( dataValue.getValue() ); + } + catch( Exception e ) + { + + } + } + + } + periodCount++; + } + + } + + data[serviceCount][orgGroupCount] = aggDataValue; + + orgGroupCount++; + } + + serviceCount++; + } + + dataElementChartResult = new DataElementChartResult( series, categories, data, chartTitle, xAxis_Title, yAxis_Title ); + + return dataElementChartResult; + + } + // ------------------------------------------------------------------------- + // Methods for getting Chart Data OrgGroup Selected orgUnit Wise end + // ------------------------------------------------------------------------- } === modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/AreaChart.java' --- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/AreaChart.java 2010-06-04 11:50:05 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/AreaChart.java 2010-11-02 11:35:05 +0000 @@ -27,7 +27,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.awt.Color; import java.awt.Font; import org.jfree.chart.ChartFactory; @@ -134,4 +133,75 @@ return chart; }// getChartViewer end + // getChartViewer DataElement wise method + @SuppressWarnings("deprecation") + public JFreeChart getChartViewergetChartViewerDataElement( double[][] data1, String[] series1, String[] categories1, String chartTitle, String xAxis_Title, String yAxis_Title ) + { + System.out.println("\n inside Area chart"); + DefaultCategoryDataset dataset1 = getDataset( data1, series1, categories1 ); + // create the chart... + final JFreeChart chart = ChartFactory.createAreaChart( "", // chart + // title + "Category", // domain axis label + "Value", // range axis label + dataset1, // data + PlotOrientation.VERTICAL, // orientation + true, // include legend + true, // tooltips? + false // URLs? + ); + + // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... + + /* TITLE */ + final TextTitle mainTitle = new TextTitle( "Area Chart" ); + mainTitle.setFont( new Font( "times", Font.BOLD, 13 ) ); + mainTitle.setPosition( RectangleEdge.TOP ); + mainTitle.setVerticalAlignment( VerticalAlignment.BOTTOM ); + chart.addSubtitle( mainTitle ); + + /* SUB TITLE */ + final TextTitle subtitle = new TextTitle( chartTitle ); + subtitle.setFont( new Font( "times", Font.BOLD, 13 ) ); + subtitle.setPosition( RectangleEdge.TOP ); + subtitle.setVerticalAlignment( VerticalAlignment.BOTTOM ); + chart.addSubtitle( subtitle ); + + final CategoryPlot plot = chart.getCategoryPlot(); + plot.setForegroundAlpha( 0.5f ); + plot.setNoDataMessage( "No data to display" ); + + // set the range axis to display integers only... + final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); + rangeAxis.setStandardTickUnits( NumberAxis.createIntegerTickUnits() ); + rangeAxis.setUpperMargin( 0.15 ); + rangeAxis.setLowerMargin( 0.15 ); + rangeAxis.setLabel( yAxis_Title ); + + // disable bar outlines... + final CategoryItemRenderer renderer = plot.getRenderer(); + renderer.setItemLabelGenerator( new StandardCategoryItemLabelGenerator() ); + + renderer.setPositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER) ); + renderer.setItemLabelsVisible( true ); + + final CategoryAxis domainAxis = plot.getDomainAxis(); + domainAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45 ); + domainAxis.setLabel( xAxis_Title ); + + // For Line Chart - ie for Target Line + /* + final CategoryDataset dataset2 = getDataset( data2, series2, categories2 ); + + final CategoryItemRenderer renderer2 = new LineAndShapeRenderer(); + renderer2.setSeriesStroke( 0, new BasicStroke( 2.0f ) ); + renderer2.setSeriesStroke( 1, new BasicStroke( 2.0f ) ); + plot.setDataset( 1, dataset2 ); + plot.setRenderer( 1, renderer2 ); + plot.setDatasetRenderingOrder( DatasetRenderingOrder.FORWARD ); + */ + + return chart; + }// getChartViewer DataElement wise end + } === modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/DualAxisChart.java' --- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/DualAxisChart.java 2010-06-04 11:50:05 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/DualAxisChart.java 2010-11-02 11:35:05 +0000 @@ -27,7 +27,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.awt.Color; import java.awt.Font; import org.jfree.chart.ChartFactory; @@ -43,10 +42,12 @@ import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.DatasetRenderingOrder; import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.jfree.chart.title.TextTitle; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.ui.HorizontalAlignment; import org.jfree.ui.RectangleEdge; import org.jfree.ui.TextAnchor; import org.jfree.ui.VerticalAlignment; @@ -146,5 +147,76 @@ return chart; }// getChartViewer end + + @SuppressWarnings("deprecation") + public JFreeChart getChartViewergetChartViewerDataElement( double[][] data1, String[] series1, String[] categories1, String chartTitle, String xAxis_Title, String yAxis_Title ) + { + DefaultCategoryDataset dataset1 = getDataset( data1, series1, categories1 ); + // create the chart... + final JFreeChart chart = ChartFactory.createBarChart3D( "", // chart + // title + "Category", // domain axis label + "Value", // range axis label + dataset1, // data + PlotOrientation.VERTICAL, // orientation + true, // include legend + true, // tooltips? + false // URLs? + ); + + // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... + + /* TITLE */ + final TextTitle mainTitle = new TextTitle( "3D BarChart" ); + mainTitle.setFont( new Font( "times", Font.BOLD, 13 ) ); + mainTitle.setPosition( RectangleEdge.TOP ); + mainTitle.setVerticalAlignment( VerticalAlignment.BOTTOM ); + chart.addSubtitle( mainTitle ); + + /* SUB TITLE */ + final TextTitle subtitle = new TextTitle( chartTitle ); + subtitle.setFont( new Font( "times", Font.BOLD, 13 ) ); + subtitle.setPosition( RectangleEdge.TOP ); + subtitle.setHorizontalAlignment( HorizontalAlignment.CENTER ); + chart.addSubtitle( subtitle ); + + // get a reference to the plot for further customisation... + final CategoryPlot plot = chart.getCategoryPlot(); + plot.setNoDataMessage( "No data to display" ); + + // set the range axis to display integers only... + final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); + rangeAxis.setStandardTickUnits( NumberAxis.createIntegerTickUnits() ); + rangeAxis.setUpperMargin( 0.15 ); + rangeAxis.setLowerMargin( 0.15 ); + rangeAxis.setLabel( yAxis_Title ); + + + // disable bar outlines... + final CategoryItemRenderer renderer = plot.getRenderer(); + renderer.setItemLabelGenerator( new StandardCategoryItemLabelGenerator() ); + renderer.setItemLabelFont (new Font ("Bold", Font.BOLD, 10)); + + renderer.setPositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER) ); + renderer.setItemLabelsVisible( true ); + + final CategoryAxis domainAxis = plot.getDomainAxis(); + domainAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45 ); + domainAxis.setLabel( xAxis_Title ); + + // For Line Chart - ie for Target Line + /* + final CategoryDataset dataset2 = getDataset( data2, series2, categories2 ); + + final CategoryItemRenderer renderer2 = new LineAndShapeRenderer(); + renderer2.setSeriesStroke( 0, new BasicStroke( 2.0f ) ); + renderer2.setSeriesStroke( 1, new BasicStroke( 2.0f ) ); + plot.setDataset( 1, dataset2 ); + plot.setRenderer( 1, renderer2 ); + plot.setDatasetRenderingOrder( DatasetRenderingOrder.FORWARD ); + */ + + return chart; + }// getChartViewer DataElement wise end } === modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/Horizontal3DBarChart.java' --- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/Horizontal3DBarChart.java 2010-06-04 11:50:05 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/Horizontal3DBarChart.java 2010-11-02 11:35:05 +0000 @@ -27,7 +27,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.awt.Color; import java.awt.Font; import org.jfree.chart.ChartFactory; @@ -135,4 +134,75 @@ return chart; }// getChartViewer end + + @SuppressWarnings("deprecation") + public JFreeChart getChartViewergetChartViewerDataElement( double[][] data1, String[] series1, String[] categories1, String chartTitle, String xAxis_Title, String yAxis_Title ) + { + System.out.println("\n inside Horizantal 3 d Bar chart chart"); + DefaultCategoryDataset dataset1 = getDataset( data1, series1, categories1 ); + // create the chart... + final JFreeChart chart = ChartFactory.createBarChart3D( "", // chart + // title + "Category", // domain axis label + "Value", // range axis label + dataset1, // data + PlotOrientation.HORIZONTAL, // orientation + true, // include legend + true, // tooltips? + false // URLs? + ); + + // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... + + /* TITLE */ + final TextTitle mainTitle = new TextTitle( "3D BarChart" ); + mainTitle.setFont( new Font( "times", Font.BOLD, 13 ) ); + mainTitle.setPosition( RectangleEdge.TOP ); + mainTitle.setVerticalAlignment( VerticalAlignment.BOTTOM ); + chart.addSubtitle( mainTitle ); + + /* SUB TITLE */ + final TextTitle subtitle = new TextTitle( chartTitle ); + subtitle.setFont( new Font( "times", Font.BOLD, 13 ) ); + subtitle.setPosition( RectangleEdge.TOP ); + subtitle.setVerticalAlignment( VerticalAlignment.BOTTOM ); + chart.addSubtitle( subtitle ); + + // get a reference to the plot for further customisation... + final CategoryPlot plot = chart.getCategoryPlot(); + plot.setNoDataMessage( "No data to display" ); + + // set the range axis to display integers only... + final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); + rangeAxis.setStandardTickUnits( NumberAxis.createIntegerTickUnits() ); + rangeAxis.setUpperMargin( 0.15 ); + rangeAxis.setLowerMargin( 0.15 ); + rangeAxis.setLabel( yAxis_Title ); + + // disable bar outlines... + final CategoryItemRenderer renderer = plot.getRenderer(); + renderer.setItemLabelGenerator( new StandardCategoryItemLabelGenerator() ); + renderer.setItemLabelFont (new Font ("Bold", Font.BOLD, 10)); + + renderer.setPositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER) ); + renderer.setItemLabelsVisible( true ); + + final CategoryAxis domainAxis = plot.getDomainAxis(); + domainAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45 ); + domainAxis.setLabel( xAxis_Title ); + + // For Line Chart - ie for Target Line + /* + final CategoryDataset dataset2 = getDataset( data2, series2, categories2 ); + + final CategoryItemRenderer renderer2 = new LineAndShapeRenderer(); + renderer2.setSeriesStroke( 0, new BasicStroke( 2.0f ) ); + renderer2.setSeriesStroke( 1, new BasicStroke( 2.0f ) ); + plot.setDataset( 1, dataset2 ); + plot.setRenderer( 1, renderer2 ); + plot.setDatasetRenderingOrder( DatasetRenderingOrder.FORWARD ); + */ + + return chart; + }// getChartViewer DataElement wise end } === modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/LineAndBarChart.java' --- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/LineAndBarChart.java 2010-06-04 11:50:05 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/LineAndBarChart.java 2010-11-02 11:35:05 +0000 @@ -27,7 +27,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.awt.Color; import java.awt.Font; import org.jfree.chart.JFreeChart; @@ -126,5 +125,64 @@ return chart; }// getChartViewer end + + @SuppressWarnings("deprecation") + public JFreeChart getChartViewergetChartViewerDataElement( double[][] data1, String[] series1, String[] categories1, String chartTitle, String xAxis_Title, String yAxis_Title ) + { + System.out.println("\n inside Line and bar chart"); + final CategoryDataset dataset1 = getDataset( data1, series1, categories1 ); + final NumberAxis rangeAxis1 = new NumberAxis( yAxis_Title ); + rangeAxis1.setStandardTickUnits( NumberAxis.createIntegerTickUnits() ); + rangeAxis1.setUpperMargin( 0.15 ); + rangeAxis1.setLowerMargin( 0.15 ); + + final LineAndShapeRenderer renderer1 = new LineAndShapeRenderer(); + renderer1.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator() ); + renderer1.setItemLabelGenerator( new StandardCategoryItemLabelGenerator() ); + renderer1.setItemLabelsVisible( true ); + final CategoryPlot subplot1 = new CategoryPlot( dataset1, null, rangeAxis1, renderer1 ); + subplot1.setDomainGridlinesVisible( true ); + + final CategoryDataset dataset2 = getDataset( data1, series1, categories1 ); + final NumberAxis rangeAxis2 = new NumberAxis( yAxis_Title ); + rangeAxis2.setStandardTickUnits( NumberAxis.createIntegerTickUnits() ); + rangeAxis2.setUpperMargin( 0.30 ); + rangeAxis1.setLowerMargin( 0.30 ); + + final BarRenderer renderer2 = new BarRenderer(); + renderer2.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator() ); + renderer2.setItemLabelGenerator( new StandardCategoryItemLabelGenerator() ); + renderer2.setItemLabelFont (new Font ("Bold", Font.BOLD, 10)); + renderer2.setPositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER) ); + renderer2.setItemLabelsVisible( true ); + final CategoryPlot subplot2 = new CategoryPlot( dataset2, null, rangeAxis2, renderer2 ); + subplot2.setDomainGridlinesVisible( true ); + + final CategoryAxis domainAxis = new CategoryAxis( xAxis_Title ); + domainAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45 ); + + final CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot( domainAxis ); + plot.setNoDataMessage( "No data to display" ); + plot.add( subplot1, 2 ); + plot.add( subplot2, 1 ); + + final JFreeChart chart = new JFreeChart( "", new Font( "SansSerif", Font.BOLD, 12 ), plot, true ); + + /* TITLE */ + final TextTitle mainTitle = new TextTitle( "Combined (Line and Bar) Chart" ); + mainTitle.setFont( new Font( "times", Font.BOLD, 13 ) ); + mainTitle.setPosition( RectangleEdge.TOP ); + mainTitle.setVerticalAlignment( VerticalAlignment.BOTTOM ); + chart.addSubtitle( mainTitle ); + + /* SUB TITLE */ + final TextTitle subtitle = new TextTitle( chartTitle ); + subtitle.setFont( new Font( "times", Font.BOLD, 13 ) ); + subtitle.setPosition( RectangleEdge.TOP ); + subtitle.setVerticalAlignment( VerticalAlignment.BOTTOM ); + chart.addSubtitle( subtitle ); + + return chart; + }// getChartViewer DataElement wise end } === modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/LineChart.java' --- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/LineChart.java 2010-06-04 11:50:05 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/LineChart.java 2010-11-02 11:35:05 +0000 @@ -126,5 +126,71 @@ return chart; }// getChartViewer end + + @SuppressWarnings("deprecation") + public JFreeChart getChartViewergetChartViewerDataElement( double[][] data1, String[] series1, String[] categories1, String chartTitle, String xAxis_Title, String yAxis_Title ) + { + System.out.println("\n inside Line chart"); + DefaultCategoryDataset dataset1 = getDataset( data1, series1, categories1 ); + + // create the first plot... + final CategoryItemRenderer renderer = new LineAndShapeRenderer(); + renderer.setToolTipGenerator( new StandardCategoryToolTipGenerator() ); + renderer.setItemLabelGenerator( new StandardCategoryItemLabelGenerator() ); + renderer.setItemLabelsVisible( true ); + + + final CategoryPlot plot = new CategoryPlot(); + plot.setNoDataMessage( "No data to display" ); + plot.setDataset( dataset1 ); + plot.setRenderer( renderer ); + + plot.setDomainAxis( new CategoryAxis( xAxis_Title ) ); + plot.setRangeAxis( new NumberAxis( yAxis_Title ) ); + + plot.setOrientation( PlotOrientation.VERTICAL ); + plot.setRangeGridlinesVisible( true ); + plot.setDomainGridlinesVisible( true ); + + + // customise the range axis... + final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); + rangeAxis.setStandardTickUnits( NumberAxis.createIntegerTickUnits() ); + rangeAxis.setAutoRangeIncludesZero( true ); + rangeAxis.setUpperMargin( 0.15 ); + rangeAxis.setLowerMargin( 0.15 ); + + /* + final CategoryDataset dataset2 = getDataset( data2, series2, categories2 ); + + final CategoryItemRenderer renderer2 = new LineAndShapeRenderer(); + renderer2.setSeriesStroke( 0, new BasicStroke( 2.0f ) ); + renderer2.setSeriesStroke( 1, new BasicStroke( 2.0f ) ); + plot.setDataset( 1, dataset2 ); + plot.setRenderer( 1, renderer2 ); + plot.setDatasetRenderingOrder( DatasetRenderingOrder.FORWARD ); + */ + + final JFreeChart chart = new JFreeChart( plot ); + + /* TITLE */ + final TextTitle mainTitle = new TextTitle( "Line Chart" ); + mainTitle.setFont( new Font( "times", Font.BOLD, 13 ) ); + mainTitle.setPosition( RectangleEdge.TOP ); + mainTitle.setVerticalAlignment( VerticalAlignment.BOTTOM ); + chart.addSubtitle( mainTitle ); + + /* SUB TITLE */ + final TextTitle subtitle = new TextTitle( chartTitle ); + subtitle.setFont( new Font( "times", Font.BOLD, 13 ) ); + subtitle.setPosition( RectangleEdge.TOP ); + subtitle.setVerticalAlignment( VerticalAlignment.BOTTOM ); + chart.addSubtitle( subtitle ); + + final CategoryAxis domainAxis = plot.getDomainAxis(); + domainAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45 ); + + return chart; + }// getChartViewer DataElement wise end } === modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/PieChart3D.java' --- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/PieChart3D.java 2010-06-04 11:50:05 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/PieChart3D.java 2010-11-02 11:35:05 +0000 @@ -31,10 +31,20 @@ import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.CategoryLabelPositions; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.labels.ItemLabelAnchor; +import org.jfree.chart.labels.ItemLabelPosition; +import org.jfree.chart.labels.StandardCategoryItemLabelGenerator; +import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PiePlot3D; +import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.title.TextTitle; import org.jfree.data.general.DefaultPieDataset; +import org.jfree.ui.HorizontalAlignment; import org.jfree.ui.RectangleEdge; +import org.jfree.ui.TextAnchor; import org.jfree.ui.VerticalAlignment; import org.jfree.util.Rotation; @@ -89,5 +99,74 @@ return chart; }// getChartViewer end + + + // getChartViewer DataElement wise method + @SuppressWarnings("deprecation") + public JFreeChart getChartViewergetChartViewerDataElement( double[][] data1, String[] series1, String[] categories1, String chartTitle, String xAxis_Title, String yAxis_Title ) + { + DefaultPieDataset dataset1 = getDataset( data1, categories1 ); + // create the chart... + final JFreeChart chart = ChartFactory.createPieChart3D( "", // chart + dataset1, // data + true, // include legend + true, // tooltips? + false // URLs? + ); + + // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... + + /* TITLE */ + final TextTitle mainTitle = new TextTitle( "3D BarChart" ); + mainTitle.setFont( new Font( "times", Font.BOLD, 13 ) ); + mainTitle.setPosition( RectangleEdge.TOP ); + mainTitle.setVerticalAlignment( VerticalAlignment.BOTTOM ); + chart.addSubtitle( mainTitle ); + + /* SUB TITLE */ + final TextTitle subtitle = new TextTitle( chartTitle ); + subtitle.setFont( new Font( "times", Font.BOLD, 13 ) ); + subtitle.setPosition( RectangleEdge.TOP ); + subtitle.setHorizontalAlignment( HorizontalAlignment.CENTER ); + chart.addSubtitle( subtitle ); + + // get a reference to the plot for further customisation... + final CategoryPlot plot = chart.getCategoryPlot(); + plot.setNoDataMessage( "No data to display" ); + + // set the range axis to display integers only... + final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); + rangeAxis.setStandardTickUnits( NumberAxis.createIntegerTickUnits() ); + rangeAxis.setUpperMargin( 0.15 ); + rangeAxis.setLowerMargin( 0.15 ); + rangeAxis.setLabel( yAxis_Title ); + + + // disable bar outlines... + final CategoryItemRenderer renderer = plot.getRenderer(); + renderer.setItemLabelGenerator( new StandardCategoryItemLabelGenerator() ); + renderer.setItemLabelFont (new Font ("Bold", Font.BOLD, 10)); + + renderer.setPositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER) ); + renderer.setItemLabelsVisible( true ); + + final CategoryAxis domainAxis = plot.getDomainAxis(); + domainAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45 ); + domainAxis.setLabel( xAxis_Title ); + + // For Line Chart - ie for Target Line + /* + final CategoryDataset dataset2 = getDataset( data2, series2, categories2 ); + + final CategoryItemRenderer renderer2 = new LineAndShapeRenderer(); + renderer2.setSeriesStroke( 0, new BasicStroke( 2.0f ) ); + renderer2.setSeriesStroke( 1, new BasicStroke( 2.0f ) ); + plot.setDataset( 1, dataset2 ); + plot.setRenderer( 1, renderer2 ); + plot.setDatasetRenderingOrder( DatasetRenderingOrder.FORWARD ); + */ + + return chart; + }// getChartViewer DataElement wise end } === modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/StandardChart.java' --- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/StandardChart.java 2010-06-04 11:50:05 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/StandardChart.java 2010-11-02 11:35:05 +0000 @@ -33,4 +33,6 @@ { JFreeChart getChartViewer( double[][] data1, String[] series1, String[] categories1, double[][] data2, String[] series2, String[] categories2, String chartTitle, String xAxis_Title, String yAxis_Title ); + + JFreeChart getChartViewergetChartViewerDataElement( double[][] data1, String[] series1, String[] categories1, String chartTitle, String xAxis_Title, String yAxis_Title ); } === modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/SurveyChart.java' --- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/SurveyChart.java 2010-06-04 11:50:05 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/SurveyChart.java 2010-11-02 11:35:05 +0000 @@ -1,7 +1,6 @@ package org.hisp.dhis.dashboard.ga.charts; import java.awt.BasicStroke; -import java.awt.Color; import java.awt.Font; import org.jfree.chart.ChartFactory; @@ -20,6 +19,7 @@ import org.jfree.chart.title.TextTitle; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.ui.HorizontalAlignment; import org.jfree.ui.RectangleEdge; import org.jfree.ui.TextAnchor; import org.jfree.ui.VerticalAlignment; @@ -109,4 +109,77 @@ return chart; }// getChartViewer end + + + // getChartViewer DataElement wise method + @SuppressWarnings("deprecation") + public JFreeChart getChartViewergetChartViewerDataElement( double[][] data1, String[] series1, String[] categories1, String chartTitle, String xAxis_Title, String yAxis_Title ) + { + DefaultCategoryDataset dataset1 = getDataset( data1, series1, categories1 ); + // create the chart... + final JFreeChart chart = ChartFactory.createBarChart3D( "", // chart + // title + "Category", // domain axis label + "Value", // range axis label + dataset1, // data + PlotOrientation.VERTICAL, // orientation + true, // include legend + true, // tooltips? + false // URLs? + ); + + // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... + + /* TITLE */ + final TextTitle mainTitle = new TextTitle( "3D BarChart" ); + mainTitle.setFont( new Font( "times", Font.BOLD, 13 ) ); + mainTitle.setPosition( RectangleEdge.TOP ); + mainTitle.setVerticalAlignment( VerticalAlignment.BOTTOM ); + chart.addSubtitle( mainTitle ); + + /* SUB TITLE */ + final TextTitle subtitle = new TextTitle( chartTitle ); + subtitle.setFont( new Font( "times", Font.BOLD, 13 ) ); + subtitle.setPosition( RectangleEdge.TOP ); + subtitle.setHorizontalAlignment( HorizontalAlignment.CENTER ); + chart.addSubtitle( subtitle ); + + // get a reference to the plot for further customisation... + final CategoryPlot plot = chart.getCategoryPlot(); + plot.setNoDataMessage( "No data to display" ); + + // set the range axis to display integers only... + final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); + rangeAxis.setStandardTickUnits( NumberAxis.createIntegerTickUnits() ); + rangeAxis.setUpperMargin( 0.15 ); + rangeAxis.setLowerMargin( 0.15 ); + rangeAxis.setLabel( yAxis_Title ); + + + // disable bar outlines... + final CategoryItemRenderer renderer = plot.getRenderer(); + renderer.setItemLabelGenerator( new StandardCategoryItemLabelGenerator() ); + renderer.setItemLabelFont (new Font ("Bold", Font.BOLD, 10)); + + renderer.setPositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER) ); + renderer.setItemLabelsVisible( true ); + + final CategoryAxis domainAxis = plot.getDomainAxis(); + domainAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45 ); + domainAxis.setLabel( xAxis_Title ); + + // For Line Chart - ie for Target Line + /* + final CategoryDataset dataset2 = getDataset( data2, series2, categories2 ); + + final CategoryItemRenderer renderer2 = new LineAndShapeRenderer(); + renderer2.setSeriesStroke( 0, new BasicStroke( 2.0f ) ); + renderer2.setSeriesStroke( 1, new BasicStroke( 2.0f ) ); + plot.setDataset( 1, dataset2 ); + plot.setRenderer( 1, renderer2 ); + plot.setDatasetRenderingOrder( DatasetRenderingOrder.FORWARD ); + */ + + return chart; + }// getChartViewer DataElement wise end } === modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/Vertical3DBarChart.java' --- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/Vertical3DBarChart.java 2010-06-04 11:50:05 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ga/charts/Vertical3DBarChart.java 2010-11-02 11:35:05 +0000 @@ -27,7 +27,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.awt.Color; import java.awt.Font; import org.jfree.chart.ChartFactory; @@ -138,4 +137,78 @@ return chart; }// getChartViewer end + + // getChartViewer DataElement wise method + @SuppressWarnings("deprecation") + public JFreeChart getChartViewergetChartViewerDataElement( double[][] data1, String[] series1, String[] categories1, String chartTitle, String xAxis_Title, String yAxis_Title ) + { + DefaultCategoryDataset dataset1 = getDataset( data1, series1, categories1 ); + // create the chart... + final JFreeChart chart = ChartFactory.createBarChart3D( "", // chart + // title + "Category", // domain axis label + "Value", // range axis label + dataset1, // data + PlotOrientation.VERTICAL, // orientation + true, // include legend + true, // tooltips? + false // URLs? + ); + + // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... + + /* TITLE */ + final TextTitle mainTitle = new TextTitle( "3D BarChart" ); + mainTitle.setFont( new Font( "times", Font.BOLD, 13 ) ); + mainTitle.setPosition( RectangleEdge.TOP ); + mainTitle.setVerticalAlignment( VerticalAlignment.BOTTOM ); + chart.addSubtitle( mainTitle ); + + /* SUB TITLE */ + final TextTitle subtitle = new TextTitle( chartTitle ); + subtitle.setFont( new Font( "times", Font.BOLD, 13 ) ); + subtitle.setPosition( RectangleEdge.TOP ); + subtitle.setHorizontalAlignment( HorizontalAlignment.CENTER ); + chart.addSubtitle( subtitle ); + + // get a reference to the plot for further customisation... + final CategoryPlot plot = chart.getCategoryPlot(); + plot.setNoDataMessage( "No data to display" ); + + // set the range axis to display integers only... + final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); + rangeAxis.setStandardTickUnits( NumberAxis.createIntegerTickUnits() ); + rangeAxis.setUpperMargin( 0.15 ); + rangeAxis.setLowerMargin( 0.15 ); + rangeAxis.setLabel( yAxis_Title ); + + + // disable bar outlines... + final CategoryItemRenderer renderer = plot.getRenderer(); + renderer.setItemLabelGenerator( new StandardCategoryItemLabelGenerator() ); + renderer.setItemLabelFont (new Font ("Bold", Font.BOLD, 10)); + + renderer.setPositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER) ); + renderer.setItemLabelsVisible( true ); + + final CategoryAxis domainAxis = plot.getDomainAxis(); + domainAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45 ); + domainAxis.setLabel( xAxis_Title ); + + // For Line Chart - ie for Target Line + /* + final CategoryDataset dataset2 = getDataset( data2, series2, categories2 ); + + final CategoryItemRenderer renderer2 = new LineAndShapeRenderer(); + renderer2.setSeriesStroke( 0, new BasicStroke( 2.0f ) ); + renderer2.setSeriesStroke( 1, new BasicStroke( 2.0f ) ); + plot.setDataset( 1, dataset2 ); + plot.setRenderer( 1, renderer2 ); + plot.setDatasetRenderingOrder( DatasetRenderingOrder.FORWARD ); + */ + + return chart; + }// getChartViewer DataElement wise end } + + === modified file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ta/action/GenerateTabularAnalysisResultAction.java' --- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ta/action/GenerateTabularAnalysisResultAction.java 2010-09-27 10:33:48 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/ta/action/GenerateTabularAnalysisResultAction.java 2010-11-02 11:35:05 +0000 @@ -305,6 +305,7 @@ SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "MMM-yyyy" ); + periodNames = new ArrayList(); for ( String year : yearLB ) === added file 'local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/util/DataElementChartResult.java' --- local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/util/DataElementChartResult.java 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-dashboard/src/main/java/org/hisp/dhis/dashboard/util/DataElementChartResult.java 2010-11-02 11:35:05 +0000 @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2004-2010, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.hisp.dhis.dashboard.util; + +/** + * @author Mithilesh Kumar Thakur + * + * @version DataElementChartResult.java Oct 26, 2010 2:00:48 PM + */ +public class DataElementChartResult +{ + + //------------------------------------------------------------------------- + // Constructor + //------------------------------------------------------------------------- + + public DataElementChartResult() + { + + } + + public DataElementChartResult( String[] series, String[] categories, Double data[][],String chartTitle,String xAxis_Title,String yAxis_Title ) + { + this.series = series; + this.categories = categories; + this.data = data; + this.chartTitle = chartTitle; + this.xAxis_Title = xAxis_Title; + this.yAxis_Title = yAxis_Title; + //this.xseriesList = xseriesList; + //this.yseriesList = yseriesList; + } + //--------------------------------------------------------------- + // Getters and Setters + //--------------------------------------------------------------- + + + private String[] series; + + public String[] getSeries() + { + return series; + } + + public void setSeries( String[] series ) + { + this.series = series; + } + + private String[] categories; + + public String[] getCategories() + { + return categories; + } + + public void setCategories( String[] categories ) + { + this.categories = categories; + } + + Double data[][]; + + public Double[][] getData() + { + return data; + } + + public void setData( Double[][] data ) + { + this.data = data; + } + + private String chartTitle; + + public String getChartTitle() + { + return chartTitle; + } + + public void setChartTitle( String chartTitle ) + { + this.chartTitle = chartTitle; + } + + private String xAxis_Title; + + public String getXAxis_Title() + { + return xAxis_Title; + } + + public void setXAxis_Title( String axis_Title ) + { + xAxis_Title = axis_Title; + } + private String yAxis_Title; + + public String getYAxis_Title() + { + return yAxis_Title; + } + + public void setYAxis_Title( String axis_Title ) + { + yAxis_Title = axis_Title; + } + + + /* + List xseriesList; + + public List getXseriesList() + { + return xseriesList; + } + + public void setXseriesList( List xseriesList ) + { + this.xseriesList = xseriesList; + } + + List yseriesList; + + public List getYseriesList() + { + return yseriesList; + } + + public void setYseriesList( List yseriesList ) + { + this.yseriesList = yseriesList; + } + */ +} === modified file 'local/in/dhis-web-dashboard/src/main/resources/META-INF/dhis/beans.xml' --- local/in/dhis-web-dashboard/src/main/resources/META-INF/dhis/beans.xml 2010-10-28 09:17:13 +0000 +++ local/in/dhis-web-dashboard/src/main/resources/META-INF/dhis/beans.xml 2010-11-02 11:35:05 +0000 @@ -40,14 +40,42 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - @@ -742,7 +770,11 @@ - + + + + - - /dhis-web-dashboard/graphicalAnalysisDataElementResult.vm - - ../dhis-web-commons/ouwt/ouwt.js,../dhis-web-commons/lists/lists.js,javascript/ga.js,javascript/hashtable.js,javascript/gadataelement.js + /popup.vm + /dhis-web-dashboard/graphicalAnalysisDataElementResult.vm + + ../dhis-web-commons/ouwt/ouwt.js,../dhis-web-commons/lists/lists.js,javascript/ga.js,javascript/hashtable.js,javascript/gadataelement.js css/StylesForTags.css + + + + 700 + 500 + + + + + + + application/vnd.ms-excel + inputStream + filename="${fileName}" + 1024 + + + + === modified file 'local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/annualAnalysisResult.vm' --- local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/annualAnalysisResult.vm 2010-06-04 11:50:05 +0000 +++ local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/annualAnalysisResult.vm 2010-11-02 11:35:05 +0000 @@ -1,7 +1,7 @@ -Anual Analysis Result Screen +Annual Analysis Result Screen - - - - - - - - - -
- - #if($selectedButton.equals("ViewSummary")) - - Export To WorkBook -    - -    - -

- - #else - Export To Excel -    - -    - - -
- #end -
-
-
- -
- -
-
- #if($riRadio.equals("indicatorsRadio1") && $categoryLB.equals( "period" )) - - - - #foreach($xaxisvalue in $xseriesList) - - #end - - - #foreach($xaxisvalue in $xseriesList) - - - - #end - - #set($count1 = 0) - #foreach($onedataList in $dataList) - #set($oneNumList = $numList.get($count1)) - #set($oneDenList = $denList.get($count1)) - - - #set($count2 = 0) - #foreach($data in $onedataList) - - - - #set($count2 = $count2 + 1) - #end - #set($count1 = $count1 + 1) - - #end -
Service Name$xaxisvalue
NumDenVal
$yseriesList.get($count1)$oneNumList.get($count2)$oneDenList.get($count2)$data
- - #else -
- - - - #foreach($xaxisvalue in $xseriesList) - - #end - - - #set($count1 = 0) - #set( $count3 = 0 ) - #foreach($onedataList in $dataList) - - - - #foreach($data in $onedataList) - #if( $categoryLB.equals( "period" ) && !$ougSetCB && $riRadio.equals( "dataElementsRadio" ) && $selectedStatus.get($count3).equals("yes") ) - - #set( $count3 = $count3 + 1 ) - #else - - #end - #end - #set( $count1 = $count1 + 1 ) - - #end -
Service Name$xaxisvalue
$yseriesList.get($count1)$data$data
-
- #end - - #if($selectedButton.equals("ViewSummary")) -

+ { + // alert("inside Viw Summary" + summaryOption ); + var chartDisplayOptionList = document.getElementById("chartDisplayOption"); + var chartDisplayOptionValue = chartDisplayOptionList.options[ chartDisplayOptionList.selectedIndex ].value; + + document.getElementById("exportExcelAnchor2").href="exportDataElementsToExcel.action?viewSummary="+summaryOption+"&chartDisplayOption="+chartDisplayOptionValue; + + } + + +
+ + + + + + #else + + + + + #end +
+ #if($selectedButton.equals("ViewSummary")) + + Export To WorkBook   + +    +

+
Export To Excel   + +    + +
+
+
+
+ + + + #foreach($xaxisvalue in $dataElementChartResult.categories) + + #end + + #set($count1 = 0) + #set( $count3 = 0 ) + #foreach($onedataList in $dataElementChartResult.data) + + + + + + #foreach($data in $onedataList) + + + #end + #end + #set( $count1 = $count1 + 1 ) + + #end +
Data Element Name$xaxisvalue
$yseriesList.get($count1)$data
+
+#if($selectedButton.equals("ViewSummary")) +

#else -
+
- +

#end
- #if($riRadio.equals("indicatorsRadio")) - - - - - - - #set($count1 = 0) - #foreach($service in $selectedServiceList) - - - - - - - #set($count1 = $count1 + 1) - #end -
Indicator NamesFormula
$service.getName()$service.getNumeratorDescription()
$service.getDenominatorDescription()
 X $service.getIndicatorType().getFactor()
- #end - - - + + - - \ No newline at end of file + \ No newline at end of file === modified file 'local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/javascript/gadataelement.js' --- local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/javascript/gadataelement.js 2010-10-28 09:25:22 +0000 +++ local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/javascript/gadataelement.js 2010-11-02 11:35:05 +0000 @@ -2,7 +2,7 @@ function getOUDeatilsForGADataElements(orgUnitIds) { document.getElementById( "ougGroupSetCB" ).disabled = false; - document.getElementById( "orgUnitGroup" ).disabled = false; + document.getElementById( "orgUnitGroupList" ).disabled = false; $.post("getOrgUnitDetails.action", { orgUnitId:orgUnitIds @@ -115,14 +115,14 @@ function getOrgUnitGroupsDataElements() { var checked = byId('ougGroupSetCB').checked; - clearListById('orgUnitGroup'); + clearListById('orgUnitGroupList'); clearListById('orgUnitListCB'); document.ChartGenerationForm.orgUnitListCB.options[0] = new Option(currentOrgUnitName,currentOrgUnitId,false,false); if (checked) { - var ouGroupId = document.getElementById("orgUnitGroup"); + var ouGroupId = document.getElementById("orgUnitGroupList"); for ( var i = 0; i < orgUnitGroupIds.length; i++) { @@ -178,7 +178,7 @@ var categoryObj = document.getElementById( 'categoryLB' );// view by var categoryVal = categoryObj.options[ categoryObj.selectedIndex ].value; - var orgGroupObj = document.getElementById( 'orgUnitGroup' ); // org unit group + var orgGroupObj = document.getElementById( 'orgUnitGroupList' ); // org unit group var orgGroupVal = orgGroupObj.options[ orgGroupObj.selectedIndex ].value; // var categoryObj = document.getElementById( 'categoryLB' ); @@ -186,7 +186,7 @@ if( document.getElementById( 'ougGroupSetCB' ).checked && categoryVal == "period" ) { - var orgUnitGroupListObj = document.getElementById('orgUnitGroup'); + var orgUnitGroupListObj = document.getElementById('orgUnitGroupList'); for( var i = 0; i < orgUnitGroupListObj.length; i++ ) { @@ -219,11 +219,20 @@ } } */ + +// Selected Button (ie ViewSummary or ViewChart) Function +function selButtonFunction1(selButton) +{ + document.ChartGenerationForm.selectedButton.value = selButton; +} + // selButtonFunction end + + //Graphical Analysis Form Validations function formValidationsDataElement() { - var selectedServices = document.getElementById("selectedServices"); + //var selectedServices = document.getElementById("selectedServices"); var selOUListLength = document.ChartGenerationForm.orgUnitListCB.options.length;//alert(selOUListLength); var selDEListSize = document.ChartGenerationForm.selectedDataElements.options.length;//alert(selDEListSize); @@ -231,9 +240,9 @@ var orgUnitListCB = document.getElementById("orgUnitListCB"); var selectedDataElements = document.getElementById("selectedDataElements"); - var orgUnitGroupCB = document.getElementById("orgUnitGroup"); + var orgUnitGroupCB = document.getElementById("orgUnitGroupList"); - var selOUGroupListLength = document.ChartGenerationForm.orgUnitGroup.options.length; + var selOUGroupListLength = document.ChartGenerationForm.orgUnitGroupList.options.length; var selyearLB = document.getElementById("yearLB"); var selperiodLB = document.getElementById("periodLB"); @@ -243,7 +252,7 @@ var k = 0; - if( selectedDataElements.selectedIndex < 0 ) + if( selDEListSize <= 0 ) { alert( "Please Select DataElement(s)" ); return false; @@ -255,22 +264,16 @@ return false; } - else if(document.getElementById( 'ougGroupSetCB' ).checked ) + else if(document.getElementById( 'ougGroupSetCB' ).checked && orgUnitGroupCB.selectedIndex < 0 ) { - if( orgUnitGroupCB.selectedIndex < 0 ) + alert( "Please select OrgUnitGroup" ); + return false; + /*if( orgUnitGroupCB.selectedIndex < 0 ) { alert( "Please select OrgUnitGroup" ); - return false; - } - else - { - for( k=0;k$i18n.getString( "dashboard" )DashBoard +

$i18n.getString( "dashboard" )

  • $i18n.getString( "graphical_analysis" )