1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5 <%#
6 #include <fstream>
7 #include <hash_map>
8 #include <algorithm>
9 %><%
10
11 ifstream in("/home/terceiro/public_html/tpp/data");
12 int x, y, minX, maxX, maxY, nData;
13 nData minX
maxX = 0;
14
15 hash_map<int,int> histogram;
16 while (in >> x >> y, nData++, in)
17 {
18
19 histogram[x] = y;
20
21 if (nData <= 1)
22 {
23 minX maxX
x;
24 maxY = y;
25 }
26 else
27 {
28 minX = min(minX, x);
29 maxX = max(maxX, x);
30 maxY = max(maxY, y);
31 }
32 }
33 %>
34 <html>
35 <head>
36 <meta http-equiv="pragma" content="no-cache" />
37 <link rel="stylesheet" type="text/css" href="histogram.css" />
38 </head>
39 <body>
40 <div class="chart">
41 <h3>Histogram example application</h3>
42 <table class="histogram" align='center'>
43 <tr>
44 <%
45 for (int i = minX; i <= maxX; i++)
46 {
47 if (histogram[i] > 0)
48 {
49 %><td>
50 <div class="frequency"
51 style="height: <%= (histogram[i] * 100)/maxY %>%;">
52 <%= histogram[i] %>
53 </div>
54 </td><%
55 }
56 else
57 {
58 %><td><div class="nullFerquecy">0</div></td><%
59 }
60 }
61 %>
62 </tr>
63 <tr class="xAxis">
64 <%
65 for (int i = minX; i <= maxX; i++)
66 {
67 %><td><%= i %></div></td><%
68 }
69 %>
70 </tr>
71 </table>
72 </div>
73
74 <div class="panel">
75 <a href="edit.tpp">Edit</a> the data.
76 </div>
77 </body>
78 </html>