1 <?xml version=
"1.0" standalone=
"no"?>
2 <!DOCTYPE svg PUBLIC
"-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
5 Copyright (C) 2006 Jonathan Zarate
6 http://www.polarcloud.com/tomato/
8 For use with Tomato Firmware only.
9 No part of this file may be used without permission.
11 <svg width=
"100%" height=
"100%" version=
"1.1" xmlns=
"http://www.w3.org/2000/svg" onload=
"init(evt)" onmouseout=
"mOut()">
12 <style type='text/css'
>
22 font:
11px sans-serif;
31 font:
11px sans-serif;
35 <script type='text/ecmascript'
><![CDATA[
48 if (typeof(svgDocument) == 'undefined') svgDocument = evt.target.ownerDocument;
50 e = document.getElementsByTagName('path');
51 for (i =
0; i <
11; ++i) {
52 l = document.getElementById('lg' + i);
53 l.setAttribute('x1', '
0%');
54 l.setAttribute('x2', '
100%');
55 l.setAttribute('y1', '
0%');
56 l.setAttribute('y2', '
100%');
58 s = l.getElementsByTagName('stop');
59 s.item(
0).setAttribute('offset', '
0');
60 s.item(
0).setAttribute('stop-opacity', '
0.7');
61 s.item(
0).setAttribute('stop-color', '#' + top.colors[i]);
62 s.item(
1).setAttribute('offset', '
100%');
63 s.item(
1).setAttribute('stop-opacity', '
1');
64 s.item(
1).setAttribute('stop-color', '#' + top.colors[i]);
66 e.item(i).setAttribute('fill', 'url(#lg' + i + ')');
69 info = document.getElementById('info');
70 tipGroup = document.getElementById('tip-group');
71 tipMask = document.getElementById('tip-mask')
72 tipText = document.getElementById('tip-text')
77 function updateSVG(data, abc)
79 var path, i, e, r, x, y, cx, cy, nx, ny, t, p, total;
84 for (i =
0; i <
11; ++i)
85 total += data[i] ||
0;
86 if (total ==
0) return;
93 path = document.getElementsByTagName('path');
95 for (i =
0; i <
11; ++i) {
98 p = (data[i] ||
0) / total;
103 nx = cx + (r * Math.sin(t * Math.PI *
2));
104 ny = cy + (r * Math.cos(t * Math.PI *
2));
107 e.setAttribute('d', '');
110 e.setAttribute('d', 'M5,' + cy + 'A' + r + ',' + r + '
0 1,
1 5,' + (cy +
1) + 'z');
113 e.setAttribute('d', 'M' + cx + ',' + cy + 'L' + x + ',' + y + 'A' + r + ',' + r + '
0 ' + ((p
> 0.5) ? '
1' : '
0') + ',
0 ' + nx + ',' + ny + 'Z');
116 tipInfo[i] = abc[i] + ' ' + (p *
100).toFixed(
2) + '%' + ((data[i] == parseInt(data[i])) ? ' (' + (data[i] ||
0) + ')' : '' );
118 e.setAttribute('onclick', 'mClick(' + i + ')');
119 e.setAttribute('onmousemove', 'mMove(evt,' + i + ')');
120 e.setAttribute('onmouseout', 'mOut()');
129 function setText(e, text)
131 if (e.firstChild) e.removeChild(e.firstChild);
132 e.appendChild(document.createTextNode(text));
137 setText(tipText, tipInfo[tipT]);
139 tipMask.setAttribute('width', tipText.getComputedTextLength() +
10);
141 if (tipY
> (vHeight -
35)) tipY -=
20;
143 if (tipX
> (vWidth -
165)) tipX = vWidth -
170;
144 tipGroup.setAttribute('transform', 'translate(' + tipX + ',' + tipY + ')');
145 tipGroup.setAttribute('visibility', 'visible');
149 clearTimeout(tipTimer);
153 function mMove(evt, n)
155 if (n == tipLastN) return;
159 setText(tipText, tipT + ' ' + tipX + 'x' + tipY );
161 if (tipTimer) clearTimeout(tipTimer);
162 tipTimer = setTimeout(showTip,
250); // doesn't work properly under Adobe/IE
167 if (tipLastN != -
1) {
169 tipGroup.setAttribute('visibility', 'hidden');
172 clearTimeout(tipTimer);
180 <linearGradient id=
"lg0"><stop/><stop/></linearGradient>
181 <linearGradient id=
"lg1"><stop/><stop/></linearGradient>
182 <linearGradient id=
"lg2"><stop/><stop/></linearGradient>
183 <linearGradient id=
"lg3"><stop/><stop/></linearGradient>
184 <linearGradient id=
"lg4"><stop/><stop/></linearGradient>
185 <linearGradient id=
"lg5"><stop/><stop/></linearGradient>
186 <linearGradient id=
"lg6"><stop/><stop/></linearGradient>
187 <linearGradient id=
"lg7"><stop/><stop/></linearGradient>
188 <linearGradient id=
"lg8"><stop/><stop/></linearGradient>
189 <linearGradient id=
"lg9"><stop/><stop/></linearGradient>
190 <linearGradient id=
"lg10"><stop/><stop/></linearGradient>
194 <g transform=
"rotate(135, 155, 155)">
208 <g id=
"tip-group" visibility=
"hidden">
209 <rect id=
"tip-mask" x=
"0" y=
"0" width=
"160" height=
"18" />
210 <text id=
"tip-text" x=
"5" y=
"13">Unclassified
100.00% (
9999)
</text>