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[
39 var abc = ['Unclassified', 'Highest', 'High', 'Medium', 'Low', 'Lowest', 'Class A', 'Class B', 'Class C', 'Class D', 'Class E'];
49 if (typeof(svgDocument) == 'undefined') svgDocument = evt.target.ownerDocument;
51 e = document.getElementsByTagName('path');
52 for (i =
0; i <
11; ++i) {
53 l = document.getElementById('lg' + i);
54 l.setAttribute('x1', '
0%');
55 l.setAttribute('x2', '
100%');
56 l.setAttribute('y1', '
0%');
57 l.setAttribute('y2', '
100%');
59 s = l.getElementsByTagName('stop');
60 s.item(
0).setAttribute('offset', '
0');
61 s.item(
0).setAttribute('stop-opacity', '
0.7');
62 s.item(
0).setAttribute('stop-color', '#' + top.colors[i]);
63 s.item(
1).setAttribute('offset', '
100%');
64 s.item(
1).setAttribute('stop-opacity', '
1');
65 s.item(
1).setAttribute('stop-color', '#' + top.colors[i]);
67 e.item(i).setAttribute('fill', 'url(#lg' + i + ')');
70 info = document.getElementById('info');
71 tipGroup = document.getElementById('tip-group');
72 tipMask = document.getElementById('tip-mask')
73 tipText = document.getElementById('tip-text')
78 function updateSVG(data)
80 var path, i, e, r, x, y, cx, cy, nx, ny, t, p, total;
85 for (i =
0; i <
11; ++i)
86 total += data[i] ||
0;
87 if (total ==
0) return;
94 path = document.getElementsByTagName('path');
96 for (i =
0; i <
11; ++i) {
99 p = (data[i] ||
0) / total;
104 nx = cx + (r * Math.sin(t * Math.PI *
2));
105 ny = cy + (r * Math.cos(t * Math.PI *
2));
108 e.setAttribute('d', '');
111 e.setAttribute('d', 'M5,' + cy + 'A' + r + ',' + r + '
0 1,
1 5,' + (cy +
1) + 'z');
114 e.setAttribute('d', 'M' + cx + ',' + cy + 'L' + x + ',' + y + 'A' + r + ',' + r + '
0 ' + ((p
> 0.5) ? '
1' : '
0') + ',
0 ' + nx + ',' + ny + 'Z');
117 tipInfo[i] = abc[i] + ' ' + (p *
100).toFixed(
2) + '% (' + (data[i] ||
0) + ')';
119 e.setAttribute('onclick', 'mClick(' + i + ')');
120 e.setAttribute('onmousemove', 'mMove(evt,' + i + ')');
121 e.setAttribute('onmouseout', 'mOut()');
130 function setText(e, text)
132 if (e.firstChild) e.removeChild(e.firstChild);
133 e.appendChild(document.createTextNode(text));
138 setText(tipText, tipInfo[tipT]);
140 tipMask.setAttribute('width', tipText.getComputedTextLength() +
10);
142 if (tipY
> (vHeight -
35)) tipY -=
20;
144 if (tipX
> (vWidth -
165)) tipX = vWidth -
170;
145 tipGroup.setAttribute('transform', 'translate(' + tipX + ',' + tipY + ')');
146 tipGroup.setAttribute('visibility', 'visible');
150 clearTimeout(tipTimer);
154 function mMove(evt, n)
156 if (n == tipLastN) return;
160 setText(tipText, tipT + ' ' + tipX + 'x' + tipY );
162 if (tipTimer) clearTimeout(tipTimer);
163 tipTimer = setTimeout(showTip,
250); // doesn't work properly under Adobe/IE
168 if (tipLastN != -
1) {
170 tipGroup.setAttribute('visibility', 'hidden');
173 clearTimeout(tipTimer);
181 <linearGradient id=
"lg0"><stop/><stop/></linearGradient>
182 <linearGradient id=
"lg1"><stop/><stop/></linearGradient>
183 <linearGradient id=
"lg2"><stop/><stop/></linearGradient>
184 <linearGradient id=
"lg3"><stop/><stop/></linearGradient>
185 <linearGradient id=
"lg4"><stop/><stop/></linearGradient>
186 <linearGradient id=
"lg5"><stop/><stop/></linearGradient>
187 <linearGradient id=
"lg6"><stop/><stop/></linearGradient>
188 <linearGradient id=
"lg7"><stop/><stop/></linearGradient>
189 <linearGradient id=
"lg8"><stop/><stop/></linearGradient>
190 <linearGradient id=
"lg9"><stop/><stop/></linearGradient>
191 <linearGradient id=
"lg10"><stop/><stop/></linearGradient>
195 <g transform=
"rotate(135, 155, 155)">
209 <g id=
"tip-group" visibility=
"hidden">
210 <rect id=
"tip-mask" x=
"0" y=
"0" width=
"160" height=
"18" />
211 <text id=
"tip-text" x=
"5" y=
"13">Unclassified
100.00% (
9999)
</text>