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[
43 // <% nvram(
"qos_classnames,qos_enable,qos_orules"); %
>
45 // var Unclassified = ['Unclassified']; // Todo - Toastman - assign Class Labels
46 // var classNames = nvram.qos_classnames.split(' '); // How to fetch nvram variable in SVG ?
47 // var abc = Unclassified.concat(classNames); // var abc = Unclassified + the NVRAM variable
49 var abc = ['Unclassified', 'Class
1', 'Class
2', 'Class
3', 'Class
4', 'Class
5', 'Class
6','Class
7','Class
8','Class
9','Class
10'];
66 if (typeof(svgDocument) == 'undefined') svgDocument = evt.target.ownerDocument;
68 e = document.getElementsByTagName('path');
69 for (i =
0; i <
11; ++i) {
70 l = document.getElementById('lg' + i);
71 l.setAttribute('x1', '
0%');
72 l.setAttribute('x2', '
100%');
73 l.setAttribute('y1', '
0%');
74 l.setAttribute('y2', '
100%');
76 s = l.getElementsByTagName('stop');
77 s.item(
0).setAttribute('offset', '
0');
78 s.item(
0).setAttribute('stop-opacity', '
0.7');
79 s.item(
0).setAttribute('stop-color', '#' + top.colors[i]);
80 s.item(
1).setAttribute('offset', '
100%');
81 s.item(
1).setAttribute('stop-opacity', '
1');
82 s.item(
1).setAttribute('stop-color', '#' + top.colors[i]);
84 e.item(i).setAttribute('fill', 'url(#lg' + i + ')');
87 info = document.getElementById('info');
88 tipGroup = document.getElementById('tip-group');
89 tipMask = document.getElementById('tip-mask')
90 tipText = document.getElementById('tip-text')
95 function updateSVG(data, abc)
97 var path, i, e, r, x, y, cx, cy, nx, ny, t, p, total;
102 for (i =
0; i <
11; ++i)
103 total += data[i] ||
0;
104 if (total ==
0) return;
111 path = document.getElementsByTagName('path');
113 for (i =
0; i <
11; ++i) {
116 p = (data[i] ||
0) / total;
121 nx = cx + (r * Math.sin(t * Math.PI *
2));
122 ny = cy + (r * Math.cos(t * Math.PI *
2));
125 e.setAttribute('d', '');
128 e.setAttribute('d', 'M5,' + cy + 'A' + r + ',' + r + '
0 1,
1 5,' + (cy +
1) + 'z');
131 e.setAttribute('d', 'M' + cx + ',' + cy + 'L' + x + ',' + y + 'A' + r + ',' + r + '
0 ' + ((p
> 0.5) ? '
1' : '
0') + ',
0 ' + nx + ',' + ny + 'Z');
134 tipInfo[i] = abc[i] + ' ' + (p *
100).toFixed(
2) + '% (' + (data[i] ||
0) + ')';
136 e.setAttribute('onclick', 'mClick(' + i + ')');
137 e.setAttribute('onmousemove', 'mMove(evt,' + i + ')');
138 e.setAttribute('onmouseout', 'mOut()');
147 function setText(e, text)
149 if (e.firstChild) e.removeChild(e.firstChild);
150 e.appendChild(document.createTextNode(text));
155 setText(tipText, tipInfo[tipT]);
157 tipMask.setAttribute('width', tipText.getComputedTextLength() +
10);
159 if (tipY
> (vHeight -
35)) tipY -=
20;
161 if (tipX
> (vWidth -
165)) tipX = vWidth -
170;
162 tipGroup.setAttribute('transform', 'translate(' + tipX + ',' + tipY + ')');
163 tipGroup.setAttribute('visibility', 'visible');
167 clearTimeout(tipTimer);
171 function mMove(evt, n)
173 if (n == tipLastN) return;
177 setText(tipText, tipT + ' ' + tipX + 'x' + tipY );
179 if (tipTimer) clearTimeout(tipTimer);
180 tipTimer = setTimeout(showTip,
250); // doesn't work properly under Adobe/IE
185 if (tipLastN != -
1) {
187 tipGroup.setAttribute('visibility', 'hidden');
190 clearTimeout(tipTimer);
198 <linearGradient id=
"lg0"><stop/><stop/></linearGradient>
199 <linearGradient id=
"lg1"><stop/><stop/></linearGradient>
200 <linearGradient id=
"lg2"><stop/><stop/></linearGradient>
201 <linearGradient id=
"lg3"><stop/><stop/></linearGradient>
202 <linearGradient id=
"lg4"><stop/><stop/></linearGradient>
203 <linearGradient id=
"lg5"><stop/><stop/></linearGradient>
204 <linearGradient id=
"lg6"><stop/><stop/></linearGradient>
205 <linearGradient id=
"lg7"><stop/><stop/></linearGradient>
206 <linearGradient id=
"lg8"><stop/><stop/></linearGradient>
207 <linearGradient id=
"lg9"><stop/><stop/></linearGradient>
208 <linearGradient id=
"lg10"><stop/><stop/></linearGradient>
212 <g transform=
"rotate(135, 155, 155)">
226 <g id=
"tip-group" visibility=
"hidden">
227 <rect id=
"tip-mask" x=
"0" y=
"0" width=
"160" height=
"18" />
228 <text id=
"tip-text" x=
"5" y=
"13">Unclassified
100.00% (
9999)
</text>