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

« back to all changes in this revision

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