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

« back to all changes in this revision

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