~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to local/in/dhis-web-ga/barchart1.jsp

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<%@ page import="java.sql.*,java.util.*" %>
 
2
<%@ page session="true"%>
 
3
 
 
4
<jsp:useBean id="ViewChartBean" scope="session" class="org.hisp.gtool.action.ViewChartBean" />
 
5
 
 
6
<html>
 
7
<head>
 
8
                <title>Graphical Analyser</title>
 
9
                <link rel="stylesheet" type="text/css" href="css/StylesForTags.css" />
 
10
        </head>
 
11
        <body>
 
12
        
 
13
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-style: dotted" bordercolor="#111111" width="100%">
 
14
 
 
15
     <%
 
16
     
 
17
        String categoryType = ViewChartBean.getI_category();
 
18
     String ideType = ViewChartBean.getIde_type();
 
19
     
 
20
     String monthNames[]={"","Jan-","Feb-","Mar-","Apr-","May-","Jun-","Jul-","Aug-","Sep-","Oct-","Nov-","Dec-"};
 
21
     String tempForSDate = "";
 
22
 
 
23
         String chartTitle = "Indicator : ";    
 
24
         String xAxisTitle = "";
 
25
         String yAxisTitle = "";
 
26
         if(categoryType.equals("Period"))  xAxisTitle = "Time Line";
 
27
         else xAxisTitle = "Facilities";
 
28
         
 
29
         if(ideType.equals("indicatorsRadio"))  yAxisTitle="Percentage/Rate";
 
30
         else yAxisTitle="Value";
 
31
 
 
32
                                                                
 
33
    // Indicator IDs
 
34
                
 
35
        Hashtable htForIndicator = ViewChartBean.setIndicatorIDs();
 
36
        Enumeration keysForIndicator = htForIndicator.keys();
 
37
                        
 
38
        int count = 0;
 
39
        String[] series1 = new String[htForIndicator.size()];
 
40
        String[] series2 = new String[htForIndicator.size()];
 
41
        
 
42
        while(keysForIndicator.hasMoreElements())
 
43
        {
 
44
                String keyI = (String) keysForIndicator.nextElement();
 
45
                int iID = ((Integer)htForIndicator.get(keyI)).intValue();
 
46
                series1[count] = keyI;  
 
47
                series2[count++]=keyI;
 
48
                
 
49
                chartTitle+=keyI+",";   
 
50
                
 
51
                                
 
52
        }// while loop end
 
53
        
 
54
        chartTitle += "\n Facility : "+ViewChartBean.getOrgUnitName()+"\nPeriod : "+ViewChartBean.getS_Date()+" To "+ViewChartBean.getE_Date();
 
55
        
 
56
        //Perid IDs
 
57
        count = 0;
 
58
        Hashtable htForPeriods = ViewChartBean.setPeriodIDs();
 
59
        //Enumeration keysForPeriod = htForPeriods.keys();
 
60
        
 
61
        Vector vForPeriods = new Vector(htForPeriods.keySet());
 
62
        Collections.sort(vForPeriods);
 
63
        Iterator iteratorForPeriod = vForPeriods.iterator();
 
64
 
 
65
    String[] categories1 = new String[htForPeriods.size()];
 
66
    String[] categories2 = new String[htForPeriods.size()];
 
67
        %>
 
68
        <tr><td class="TableHeadingCellStyles" style="border-style: dotted; border-width: 1" bordercolor="#111111">Indicator Name</td>
 
69
                <td class="TableHeadingCellStyles" style="border-style: dotted; border-width: 1" bordercolor="#111111"><font color="Maroon">Target</font></td>
 
70
        <%
 
71
        while(iteratorForPeriod.hasNext())
 
72
        {                               
 
73
                String keyP = (String) iteratorForPeriod.next();
 
74
                int pID = ((Integer)htForPeriods.get(keyP)).intValue();
 
75
                if(categoryType.equals("Period"))
 
76
                                {
 
77
                                        String partsOfTempForSDate[] = keyP.split("-");
 
78
                                        tempForSDate = monthNames[Integer.parseInt(partsOfTempForSDate[1])]+partsOfTempForSDate[0];
 
79
                                }       
 
80
                else tempForSDate =     keyP;
 
81
                
 
82
                categories1[count]=tempForSDate;
 
83
                categories2[count++]=tempForSDate;
 
84
                        
 
85
                %>
 
86
                <td class="TableHeadingCellStyles"><%=tempForSDate%></td>                               
 
87
                <%
 
88
 
 
89
        }// while loop end
 
90
        %>
 
91
        </tr>
 
92
        <%
 
93
        //Indicator Values & Targets
 
94
        
 
95
        Hashtable htForIndicatorValues = ViewChartBean.getValuesByPeriod();
 
96
        if(htForIndicatorValues==null) {out.println("<h3>Select any Indicator</h3>");return;}
 
97
        Enumeration keysForIndicatorValues = htForIndicatorValues.keys();
 
98
        
 
99
        Hashtable htForTargets = ViewChartBean.getTargetValues();
 
100
        
 
101
        int count1=0;
 
102
        int count2=0;
 
103
                                
 
104
        double data1[][]= new double[htForIndicatorValues.size()][];
 
105
 
 
106
                
 
107
        while(keysForIndicatorValues.hasMoreElements())
 
108
        {
 
109
                String keyIV = (String) keysForIndicatorValues.nextElement();                                           
 
110
                List liForValues = (ArrayList) htForIndicatorValues.get(keyIV);
 
111
                data1[count1] = new double[liForValues.size()];
 
112
                Iterator itForValues = liForValues.iterator();
 
113
                count2 = 0;
 
114
                %>
 
115
                <tr><td class="TableHeadingCellStyles" style="border-style: dotted; border-width: 1" bordercolor="#111111"><%=keyIV%></td>
 
116
                        <td class="TableDataCellStyles"><font color="Maroon"><%=((Double)htForTargets.get(keyIV)).doubleValue()%></font></td>
 
117
                <%
 
118
                while(itForValues.hasNext())
 
119
                {               
 
120
                        double iValue = ((Double) itForValues.next()).doubleValue();
 
121
                        data1[count1][count2] = Math.round(iValue*Math.pow(10,2))/Math.pow(10,2);                                       
 
122
                        %>
 
123
                        <td class="TableDataCellStyles"><%=Math.round(iValue*Math.pow(10,2))/Math.pow(10,2)%></td>
 
124
                        <%
 
125
                        count2++;
 
126
                }// list while loop end
 
127
                %>
 
128
                </tr>
 
129
                <%
 
130
                count1++;
 
131
        }// indihashtable               
 
132
        
 
133
        
 
134
        
 
135
        
 
136
        
 
137
        /*htForTargets.put("Percentage of first trimester ANC registration",new Double(60.0));
 
138
        htForTargets.put("Percentage of Institutional Delivery",new Double(90.0));
 
139
        htForTargets.put("Percentage of Delivery by SBA",new Double(95.0));
 
140
        htForTargets.put("Percentage of Still Births",new Double(100.0));
 
141
        htForTargets.put("Percentage of Female Live Birth",new Double(50.0));
 
142
        htForTargets.put("Early Breast Feeding Rate",new Double(90.0));
 
143
        htForTargets.put("Percentage of Fully Immunised Children",new Double(90.0));
 
144
        htForTargets.put("Percentage of drop outs in BCG to Measles",new Double(10.0));
 
145
        htForTargets.put("Percentage of LBW Children at Birth",new Double(10.0));
 
146
        htForTargets.put("Infant Mortality Rate",new Double(50.0));
 
147
        htForTargets.put("Percentage of Neonatal Deaths",new Double(25.0));
 
148
        htForTargets.put("Total Sterilization Rate",new Double(65.0)); */
 
149
        
 
150
        double data2[][]= new double[count1][count2];
 
151
        count1=0;
 
152
        
 
153
        while(count1<data2.length)
 
154
          {     
 
155
            count2=0;    
 
156
            
 
157
            while(count2<data2[count1].length)
 
158
             {
 
159
              data2[count1][count2++]= ((Double)htForTargets.get(series1[count1])).doubleValue();
 
160
             }
 
161
             count1++;
 
162
            }  
 
163
             
 
164
%>
 
165
        
 
166
</table>
 
167
<br>
 
168
<jsp:useBean id="myChart" scope="request" class='org.hisp.gtool.charts.BarChart1' />
 
169
 
 
170
<jsp:setProperty name="myChart" property="series" value="<%=series1%>"/>
 
171
<jsp:setProperty name="myChart" property="categories" value="<%=categories1%>"/>
 
172
<jsp:setProperty name="myChart" property="data" value="<%=data1%>"/>
 
173
<jsp:setProperty name="myChart" property="chartTitle" value="<%=chartTitle%>"/>
 
174
 
 
175
<%
 
176
        myChart.setXAxis_Title(xAxisTitle);
 
177
        myChart.setYAxis_Title(yAxisTitle);
 
178
%>
 
179
 
 
180
 
 
181
<%String chartViewer = myChart.getChartViewer(request, response);%>
 
182
<center>
 
183
<img src="<%=chartViewer%>" border=0 usemap="#imageMap">
 
184
</center>
 
185
 
 
186
 
 
187
 
 
188
</body>
 
189
</html>
 
190
 
 
191