Line 143... |
Line 143... |
143 |
$cl['tx_border'] = allocate_color($cs['tx_border']);
|
143 |
$cl['tx_border'] = allocate_color($cs['tx_border']);
|
144 |
|
144 |
|
145 |
svg_rect(0, 0, $iw, $ih, array( 'stroke' => 'none', 'stroke-width' => 0, 'fill' => $cl['image_background']['rgb']) );
|
145 |
svg_rect(0, 0, $iw, $ih, array( 'stroke' => 'none', 'stroke-width' => 0, 'fill' => $cl['image_background']['rgb']) );
|
146 |
svg_rect($xlm, $ytm, $iw-$xrm-$xlm, $ih-$ybm-$ytm, array( 'stroke' => 'none', 'stroke-width' => 0, 'fill' => $cl['background']['rgb']) );
|
146 |
svg_rect($xlm, $ytm, $iw-$xrm-$xlm, $ih-$ybm-$ytm, array( 'stroke' => 'none', 'stroke-width' => 0, 'fill' => $cl['background']['rgb']) );
|
147 |
|
147 |
|
148 |
$depth = 12;
|
148 |
$depth = 12*SVG_DEPTH_SCALING;
|
149 |
svg_group( array( 'stroke' => 'none', 'stroke-width' => 0, 'fill' => $cl['background_2']['rgb'], 'fill-opacity' => $cl['background_2']['opacity']) );
|
149 |
svg_group( array( 'stroke' => 'none', 'stroke-width' => 0, 'fill' => $cl['background_2']['rgb'], 'fill-opacity' => $cl['background_2']['opacity']) );
|
150 |
svg_poly(array($xlm, $ytm, $xlm, $ih - $ybm, $xlm - $depth, $ih - $ybm + $depth, $xlm - $depth, $ytm + $depth));
|
150 |
svg_poly(array($xlm, $ytm, $xlm, $ih - $ybm, $xlm - $depth, $ih - $ybm + $depth, $xlm - $depth, $ytm + $depth));
|
151 |
svg_poly(array($xlm, $ih - $ybm, $xlm - $depth, $ih - $ybm + $depth, $iw - $xrm - $depth, $ih - $ybm + $depth, $iw - $xrm, $ih - $ybm));
|
151 |
svg_poly(array($xlm, $ih - $ybm, $xlm - $depth, $ih - $ybm + $depth, $iw - $xrm - $depth, $ih - $ybm + $depth, $iw - $xrm, $ih - $ybm));
|
152 |
svg_group_end();
|
152 |
svg_group_end();
|
153 |
|
153 |
|
154 |
// draw title
|
154 |
// draw title
|
155 |
$text = T('Traffic data for')." $iface";
|
155 |
$text = T('Traffic data for')." $iface";
|
156 |
svg_text($iw / 2, ($ytm / 2), $text, array( 'stroke' => $cl['text'], 'fill' => $cl['text']['rgb'],'stroke-width' => 0, 'font-family' => SVG_FONT, 'font-weight' => 'bold', 'text-anchor' => 'middle' ));
|
156 |
svg_text($iw / 2, ($ytm / 2), $text, array( 'stroke' => 'none', 'fill' => $cl['text']['rgb'],'stroke-width' => 0, 'font-family' => SVG_FONT, 'font-weight' => 'bold', 'text-anchor' => 'middle' ));
|
157 |
}
|
157 |
}
|
158 |
|
158 |
|
159 |
function draw_border()
|
159 |
function draw_border()
|
160 |
{
|
160 |
{
|
161 |
global $cl, $iw, $ih;
|
161 |
global $cl, $iw, $ih;
|
Line 163... |
Line 163... |
163 |
}
|
163 |
}
|
164 |
|
164 |
|
165 |
function draw_grid($x_ticks, $y_ticks)
|
165 |
function draw_grid($x_ticks, $y_ticks)
|
166 |
{
|
166 |
{
|
167 |
global $cl, $iw, $ih, $xlm, $xrm, $ytm, $ybm;
|
167 |
global $cl, $iw, $ih, $xlm, $xrm, $ytm, $ybm;
|
168 |
$x_step = ($iw - $xlm - $xrm) / $x_ticks;
|
168 |
$x_step = ($iw - $xlm - $xrm) / ($x_ticks ?: 1);
|
169 |
$y_step = ($ih - $ytm - $ybm) / $y_ticks;
|
169 |
$y_step = ($ih - $ytm - $ybm) / $y_ticks;
|
170 |
|
170 |
|
171 |
$depth = 12;
|
171 |
$depth = 12*SVG_DEPTH_SCALING;
|
172 |
|
172 |
|
173 |
svg_group( array( 'stroke' => $cl['grid_stipple_1']['rgb'], 'stroke-opacity' => $cl['grid_stipple_1']['opacity'], 'stroke-width' => '1px', 'stroke-dasharray' => '1,1' ) );
|
173 |
svg_group( array( 'stroke' => $cl['grid_stipple_1']['rgb'], 'stroke-opacity' => $cl['grid_stipple_1']['opacity'], 'stroke-width' => '1px', 'stroke-dasharray' => '1,1' ) );
|
174 |
for ($i = $xlm; $i <= ($iw - $xrm); $i += $x_step)
|
174 |
for ($i = $xlm; $i <= ($iw - $xrm); $i += $x_step)
|
175 |
{
|
175 |
{
|
176 |
svg_line($i, $ytm, $i, $ih-$ybm);
|
176 |
svg_line($i, $ytm, $i, $ih-$ybm);
|
Line 201... |
Line 201... |
201 |
$y_scale = 1;
|
201 |
$y_scale = 1;
|
202 |
$prescale = 1;
|
202 |
$prescale = 1;
|
203 |
$unit = 'K';
|
203 |
$unit = 'K';
|
204 |
$offset = 0;
|
204 |
$offset = 0;
|
205 |
$gr_h = $ih - $ytm - $ybm;
|
205 |
$gr_h = $ih - $ytm - $ybm;
|
206 |
$x_step = ($iw - $xlm - $xrm) / $x_ticks;
|
206 |
$x_step = ($iw - $xlm - $xrm) / ($x_ticks ?: 1);
|
207 |
$y_step = ($ih - $ytm - $ybm) / $y_ticks;
|
207 |
$y_step = ($ih - $ytm - $ybm) / $y_ticks;
|
208 |
$bar_w = ($x_step / 2) ;
|
208 |
$bar_w = ($x_step / 2) ;
|
209 |
|
209 |
|
210 |
//
|
210 |
//
|
211 |
// determine scale
|
211 |
// determine scale
|
Line 245... |
Line 245... |
245 |
//
|
245 |
//
|
246 |
// graph scale factor (per pixel)
|
246 |
// graph scale factor (per pixel)
|
247 |
//
|
247 |
//
|
248 |
$sf = ($prescale * $y_scale * $y_ticks) / $gr_h;
|
248 |
$sf = ($prescale * $y_scale * $y_ticks) / $gr_h;
|
249 |
|
249 |
|
250 |
if ($data[0] == 'nodata')
|
250 |
if (count($data) == 0)
|
251 |
{
|
251 |
{
|
252 |
$text = 'no data available';
|
252 |
$text = 'no data available';
|
253 |
svg_text($iw/2, $ytm + 80, $text, array( 'stroke' => $cl['text']['rgb'], 'fill' => $cl['text']['rgb'], 'stroke-width' => 0, 'font-family' => SVG_FONT, 'font-size' => '16pt', 'text-anchor' => 'middle') );
|
253 |
svg_text($iw/2, $ytm + 80, $text, array( 'stroke' => $cl['text']['rgb'], 'fill' => $cl['text']['rgb'], 'stroke-width' => 0, 'font-family' => SVG_FONT, 'font-size' => '16pt', 'text-anchor' => 'middle') );
|
254 |
}
|
254 |
}
|
255 |
else
|
255 |
else
|
Line 260... |
Line 260... |
260 |
for ($i=0; $i<$x_ticks; $i++)
|
260 |
for ($i=0; $i<$x_ticks; $i++)
|
261 |
{
|
261 |
{
|
262 |
$x = $xlm + ($i * $x_step);
|
262 |
$x = $xlm + ($i * $x_step);
|
263 |
$y = $ytm + ($ih - $ytm - $ybm) - (($data[$i]['rx'] - $offset) / $sf);
|
263 |
$y = $ytm + ($ih - $ytm - $ybm) - (($data[$i]['rx'] - $offset) / $sf);
|
264 |
|
264 |
|
265 |
$depth = ($x_ticks < 20) ? 8 : 6;
|
265 |
$depth = ($x_ticks < 20) ? 8*SVG_DEPTH_SCALING : 6*SVG_DEPTH_SCALING;
|
266 |
$space = 0;
|
266 |
$space = 0;
|
267 |
|
267 |
|
268 |
$x1 = (int)$x;
|
268 |
$x1 = (int)$x;
|
269 |
$y1 = (int)$y;
|
269 |
$y1 = (int)$y;
|
270 |
$w = (int)($bar_w - $space);
|
270 |
$w = (int)($bar_w - $space);
|