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.
14 <svg width=
"100%" height=
"100%" version=
"1.1" xmlns=
"http://www.w3.org/2000/svg" onload=
"init(evt)" onmouseout=
"mOut()">
15 <style type='text/css'
>
25 font:
11px sans-serif;
34 font:
11px sans-serif;
41 <script type='text/ecmascript'
><![CDATA[
56 if (typeof(svgDocument) == 'undefined') svgDocument = evt.target.ownerDocument;
58 e = document.getElementsByTagName('path');
59 for (i =
0; i <
11; ++i) {
60 l = document.getElementById('lg' + i);
61 l.setAttribute('x1', '
0%');
62 l.setAttribute('x2', '
100%');
63 l.setAttribute('y1', '
0%');
64 l.setAttribute('y2', '
100%');
66 s = l.getElementsByTagName('stop');
67 s.item(
0).setAttribute('offset', '
0');
68 s.item(
0).setAttribute('stop-opacity', '
0.7');
69 s.item(
0).setAttribute('stop-color', '#' + top.colors[i]);
70 s.item(
1).setAttribute('offset', '
100%');
71 s.item(
1).setAttribute('stop-opacity', '
1');
72 s.item(
1).setAttribute('stop-color', '#' + top.colors[i]);
74 e.item(i).setAttribute('fill', 'url(#lg' + i + ')');
77 info = document.getElementById('info');
78 tipGroup = document.getElementById('tip-group');
79 tipMask = document.getElementById('tip-mask')
80 tipText = document.getElementById('tip-text')
85 function updateSVG(data, abc)
87 var path, i, e, r, x, y, cx, cy, nx, ny, t, p, total;
92 for (i =
0; i <
11; ++i)
93 total += data[i] ||
0;
94 if (total ==
0) return;
101 path = document.getElementsByTagName('path');
103 for (i =
0; i <
11; ++i) {
106 p = (data[i] ||
0) / total;
111 nx = cx + (r * Math.sin(t * Math.PI *
2));
112 ny = cy + (r * Math.cos(t * Math.PI *
2));
115 e.setAttribute('d', '');
118 e.setAttribute('d', 'M5,' + cy + 'A' + r + ',' + r + '
0 1,
1 5,' + (cy +
1) + 'z');
121 e.setAttribute('d', 'M' + cx + ',' + cy + 'L' + x + ',' + y + 'A' + r + ',' + r + '
0 ' + ((p
> 0.5) ? '
1' : '
0') + ',
0 ' + nx + ',' + ny + 'Z');
124 tipInfo[i] = abc[i] + ' ' + (p *
100).toFixed(
2) + '% (' + (data[i] ||
0) + ')';
126 e.setAttribute('onclick', 'mClick(' + i + ')');
127 e.setAttribute('onmousemove', 'mMove(evt,' + i + ')');
128 e.setAttribute('onmouseout', 'mOut()');
137 function setText(e, text)
139 if (e.firstChild) e.removeChild(e.firstChild);
140 e.appendChild(document.createTextNode(text));
145 setText(tipText, tipInfo[tipT]);
147 tipMask.setAttribute('width', tipText.getComputedTextLength() +
10);
149 if (tipY
> (vHeight -
35)) tipY -=
20;
151 if (tipX
> (vWidth -
165)) tipX = vWidth -
170;
152 tipGroup.setAttribute('transform', 'translate(' + tipX + ',' + tipY + ')');
153 tipGroup.setAttribute('visibility', 'visible');
157 clearTimeout(tipTimer);
161 function mMove(evt, n)
163 if (n == tipLastN) return;
167 setText(tipText, tipT + ' ' + tipX + 'x' + tipY );
169 if (tipTimer) clearTimeout(tipTimer);
170 tipTimer = setTimeout(showTip,
250); // doesn't work properly under Adobe/IE
175 if (tipLastN != -
1) {
177 tipGroup.setAttribute('visibility', 'hidden');
180 clearTimeout(tipTimer);
188 <linearGradient id=
"lg0"><stop/><stop/></linearGradient>
189 <linearGradient id=
"lg1"><stop/><stop/></linearGradient>
190 <linearGradient id=
"lg2"><stop/><stop/></linearGradient>
191 <linearGradient id=
"lg3"><stop/><stop/></linearGradient>
192 <linearGradient id=
"lg4"><stop/><stop/></linearGradient>
193 <linearGradient id=
"lg5"><stop/><stop/></linearGradient>
194 <linearGradient id=
"lg6"><stop/><stop/></linearGradient>
195 <linearGradient id=
"lg7"><stop/><stop/></linearGradient>
196 <linearGradient id=
"lg8"><stop/><stop/></linearGradient>
197 <linearGradient id=
"lg9"><stop/><stop/></linearGradient>
198 <linearGradient id=
"lg10"><stop/><stop/></linearGradient>
202 <g transform=
"rotate(135, 155, 155)">
216 <g id=
"tip-group" visibility=
"hidden">
217 <rect id=
"tip-mask" x=
"0" y=
"0" width=
"160" height=
"18" />
218 <text id=
"tip-text" x=
"5" y=
"13">Unclassified
100.00% (
9999)
</text>