Project

General

Profile

« Previous | Next » 

Revision 9228de6c

Added by Jim Pingle almost 15 years ago

Fix graph staggering, the old method was causing the graphs to diverge in update intervals over time.

View differences:

usr/local/www/graph.php
61 61
else
62 62
	$time_interval = 3;
63 63

  
64
if ($_GET["initdelay"])
65
	$init_delay = $_GET["initdelay"];		//Initial Delay
66
else
67
	$init_delay = 3;
68

  
64 69
//SVG attributes
65 70
$attribs['axis']='fill="black" stroke="black"';
66 71
$attribs['in']='fill="#FF0000" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="7"';
......
229 234
  last_ugmt = ugmt;
230 235
  last_ifin = ifin;
231 236
  last_ifout = ifout;
232
  
237
  var graphTimerId = 0;
233 238
  switch (plot_in.length) {
234 239
  	case 0:
235 240
  		SVGDoc.getElementById("collect_initial").setAttributeNS(null, 'visibility', 'visible');
236 241
		plot_in[0] = diff_ifin / diff_ugmt;
237 242
		plot_out[0] = diff_ifout / diff_ugmt;
238
		setTimeout('fetch_data()',<?=1000*$time_interval?>);
243
		setTimeout('fetch_data()',<?=1000*($time_interval + $init_delay)?>);
239 244
		return;
240 245
	case 1:
241 246
    	SVGDoc.getElementById("collect_initial").setAttributeNS(null, 'visibility', 'hidden');
usr/local/www/widgets/widgets/traffic_graphs.widget.php
80 80
</script>
81 81

  
82 82
<?php
83

  
84 83
	foreach ($ifdescrs as $ifdescr => $ifname) {
85 84
		$ifinfo = get_interface_info($ifdescr);
86 85
		$currentgraph = $showngraphlist[$graphcounter];
......
112 111
			}
113 112
		}
114 113

  
115

  
116 114
	 if ($ifinfo['status'] != "down") {
117 115
	?>
118 116
	<div id="<?=$ifname;?>trafficdiv" style="padding: 5px">
......
128 126
			<div style="clear:both;"></div>
129 127
		</div>
130 128
		<div id="<?=$ifname;?>graphdiv" style="display:<?php echo $graphdisplay;?>">
131
		<?php $refreshInterval = $refreshInterval + 3 ?>
132
			<embed id="graph" src="graph.php?ifnum=<?=$ifdescr;?>&ifname=<?=rawurlencode($ifname);?>&timeint=<?=$refreshInterval;?>" type="image/svg+xml" width="<? echo $width; ?>" height="<? echo $height; ?>" pluginspage="http://www.adobe.com/svg/viewer/install/auto" />
129
			<embed id="graph" src="graph.php?ifnum=<?=$ifdescr;?>&ifname=<?=rawurlencode($ifname);?>&timeint=<?=$refreshInterval;?>&initdelay=<?=($graphcounter+1) * 2;?>" type="image/svg+xml" width="<? echo $width; ?>" height="<? echo $height; ?>" pluginspage="http://www.adobe.com/svg/viewer/install/auto" />
133 130
		</div>
134 131
<? $firstgraphshown = true; $graphcounter++; ?>
135 132
	</div>

Also available in: Unified diff