001  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
002  
003  <html>
004  <head>
005   <title>Untitled</title>
006  </head>
007  
008  <body>
009  
010  <%
011  Dim Anz
012  Dim name(12), wert(12)
013  Dim nI
014  Dim width, height, colwidth, barwidth
015  
016  ' Anzahl der Werte
017  Anz = 12
018  
019  ' Werte:
020  nI = 0
021  nI = nI + 1: name(nI)="Jan" : wert(nI)=15
022  nI = nI + 1: name(nI)="Feb" : wert(nI)=9
023  nI = nI + 1: name(nI)="Mar" : wert(nI)=12
024  nI = nI + 1: name(nI)="Apr" : wert(nI)=3
025  nI = nI + 1: name(nI)="Mai" : wert(nI)=-2
026  nI = nI + 1: name(nI)="Jun" : wert(nI)=1
027  nI = nI + 1: name(nI)="Jul" : wert(nI)=-3
028  nI = nI + 1: name(nI)="Aug" : wert(nI)=5
029  nI = nI + 1: name(nI)="Sep" : wert(nI)=14
030  nI = nI + 1: name(nI)="Okt" : wert(nI)=17
031  nI = nI + 1: name(nI)="Nov" : wert(nI)=11
032  nI = nI + 1: name(nI)="Dez" : wert(nI)=6
033  
034  ' Suche Max und Min Werte
035  max=0 : min=0
036  For nI=1 To UBound(wert)
037   If wert(nI) > max Then
038   max = wert(nI)
039   ElseIf wert(nI) < min Then
040   min = wert(nI)
041   End If
042  Next
043  
044  
045  
046  ' Konstruiere waagrechtes Balkendiagramm
047  ' Gesamtbreite der Balkengrafik
048  width = 450
049  
050  ' Suche Multiplikator fuer Balken
051  If (max - min) < 1 Then
052   k = 1
053  Else
054   k = width / (max - min)
055  End If
056  
057  Response.Write "<h2>Waagrechtes Balkendiagramm</h2>"
058  Response.Write "<table border=0 cellspacing=0 cellpadding=0>" & VbCrLf
059  
060  For nI = 1 to Anz
061   Response.Write "<tr>" & VbCrLf
062   ' Bezeichnung:
063   Response.Write " <td>" & Server.HTMLEncode(name(nI)) & ": </td>" & VbCrLf
064   ' Negativer Bereich
065   If wert(nI) < 0 Then
066   Response.Write " <td align=""RIGHT"">"
067  
068   ' Wert hinaus schreiben
069   Response.Write wert(nI) & " "
070  
071   ' negativen Balken
072   Response.Write "<img src=""red.jpg"" border=0 "
073   Response.Write "width=" & int(abs(wert(nI)*k)+0.5)
074   Response.Write " height=15></td>" & VbCrLf
075   Else
076   Response.Write " <td> </td>" & VbCrLf
077   End If
078  
079   ' Nulllinie
080   Response.Write "<td><img src=""black.jpg"" border=0 width=2 height=25></td>" & VbCrLf
081  
082   ' Positiver Bereich
083   If wert(nI) > 0 Then
084   ' positiver Balken
085   Response.Write " <td><img src=""green.jpg"" border=0 "
086   Response.Write "width=" & int(abs(wert(nI)*k)+0.5)
087   Response.Write " height=15> "
088   ' positiver Wert
089   Response.Write wert(nI)
090   Response.Write "</td>" & VbCrLf
091   Else
092   Response.Write " <td> </td>" & VbCrLf
093   End If
094  
095   Response.Write "</tr>" & VbCrLf
096  Next
097  Response.Write "</table>" & VbCrLf
098  
099  
100  
101  ' Konstruiere senkrechtes Balkendiagramm
102  ' Gesamtbreite der Balkengrafik
103  width = 500
104  ' Gesamthoehe der Balkengrafik
105  height = 260
106  
107   ' Breite der Spalten
108  colwidth = int(width/anz+1)
109   ' Breite der Balken
110  barwidth = colwidth - 10
111  ' Suche Multiplikator fuer Balken
112  If (max - min) < 1 Then
113   k = 1
114  Else
115   k = height / (max - min)
116  End If
117  
118  Response.Write "<h2>Senkrechtes Balkendiagramm</h2>"
119  Response.Write "<table border=0 cellspacing=0 cellpadding=0>" & VbCrLf
120  
121  ' Positiver Bereich
122  Response.Write "<tr>" & VbCrLf
123  For nI = 1 to Anz
124   If wert(nI) > 0 Then
125   ' positiver Wert
126   Response.Write "<td align=""CENTER"" valign=""BOTTOM"">" & VbCrLf
127   Response.Write wert(nI)
128   Response.Write "<BR>" & VbCrLf
129   ' positiver Balken
130   Response.Write "<img src=""green.jpg"" border=0 "
131   Response.Write "width=" & barwidth
132   Response.Write " height=" & int(abs(wert(nI)*k)+0.5)
133   Response.Write ">"
134   Response.Write "</td>" & VbCrLf
135   Else
136   Response.Write "<td> </td>" & VbCrLf
137   End If
138  Next
139  Response.Write "</tr>" & VbCrLf
140  
141  ' Nulllinie
142  Response.Write "<tr>" & VbCrLf
143  For nI = 1 to Anz
144   Response.Write "<td align=""CENTER"" valign=""MIDDLE"">"
145   Response.Write "<img src=""black.jpg"" border=0 "
146   Response.Write "width=" & colwidth
147   Response.Write " height=2></td>" & VbCrLf
148  Next
149  Response.Write "</tr>" & VbCrLf
150  
151  
152  ' Negativer Bereich
153  Response.Write "<tr>" & VbCrLf
154  For nI = 1 to Anz
155   If wert(nI) < 0 Then
156   Response.Write "<td valign=""TOP"" align=""CENTER"">" & VbCrLf
157   ' negativen Balken
158   Response.Write "<img src=""red.jpg"" border=0 "
159   Response.Write "width=" & barwidth
160   Response.Write " height=" & int(abs(wert(nI)*k)+0.5)
161   Response.Write ">"
162   ' Wert hinaus schreiben
163   Response.Write "<BR>"
164   Response.Write wert(nI) & VbCrLf
165   Else
166   Response.Write "<td> </td>" & VbCrLf
167   End If
168  Next
169  Response.Write "</tr>" & VbCrLf
170  
171  ' Bezeichnungen:
172  Response.Write "<tr>" & VbCrLf
173  For nI = 1 to Anz
174   Response.Write "<td align=""CENTER""> "
175   Response.Write Server.HTMLEncode(name(nI))
176   Response.Write " </td>" & VbCrLf
177  Next
178  Response.Write "</tr>" & VbCrLf
179  
180  Response.Write "</table>" & VbCrLf
181  
182  %>

183  
184  
185  
186  
187  </body>
188  </html>