signal Posted April 23, 2007 Share Posted April 23, 2007 I'm trying to figure out the best way to generate a signal strength graphic much like wifi tools or mobile phones have. These are usually a scaled segmented graphic that go from small to large segments. How many segments are "on" is based on a single value. Using a bar graph tool seems overkill and doesn't present the scaleable/segmented effect. A "progress" bar doesn't seem to be the right direction either. Any ideas on how to go about this? Or does a class/extension exist for it? Thanks. Link to comment https://forums.phpfreaks.com/topic/48353-generating-a-segmented-signal-strength-graph/ Share on other sites More sharing options...
Wildbug Posted April 23, 2007 Share Posted April 23, 2007 You could use the image functions to create a subroutine that would render a simple image based on one or more parameters passed to it. Link to comment https://forums.phpfreaks.com/topic/48353-generating-a-segmented-signal-strength-graph/#findComment-236411 Share on other sites More sharing options...
signal Posted April 23, 2007 Author Share Posted April 23, 2007 Using the image function to draw multiple bars (solid or not) per "meter" seems it would be a bit intensive. Here's is an example from the Intel PROSet/Wireless software. The green signal strength bar graph on the left side is what I'm after. Note the bars are always there but being solid or not is based on a single value. I suppose the easiest thing would be to generate 6 static images (or more if more segments are used). Link to comment https://forums.phpfreaks.com/topic/48353-generating-a-segmented-signal-strength-graph/#findComment-236434 Share on other sites More sharing options...
fert Posted April 23, 2007 Share Posted April 23, 2007 GD is pretty much the only thing that could do this Link to comment https://forums.phpfreaks.com/topic/48353-generating-a-segmented-signal-strength-graph/#findComment-236437 Share on other sites More sharing options...
Wildbug Posted April 24, 2007 Share Posted April 24, 2007 Oh, that's all you need? Yep, six static images would be the most efficient -- you wouldn't want to redraw that every time. Link to comment https://forums.phpfreaks.com/topic/48353-generating-a-segmented-signal-strength-graph/#findComment-236523 Share on other sites More sharing options...
Barand Posted April 28, 2007 Share Posted April 28, 2007 Dynamic GD version :: ssm.php :: <?php $im = imagecreate(42,32); $white = imagecolorallocate($im, 0xFF,0xFF,0xFF); $sig = imagecolorallocate($im, 0xFF,0x00,0x00); $nosig = imagecolorallocate($im, 0x00,0xFF,0x00); $black = imagecolorallocate($im, 0x00,0x00,0x00); $ss = $_GET['ss']; // 0 to 5 $barheight = array (10, 15, 20, 25, 30); $barwidth = 5; $gap = 4; for ($b=0; $b<5; $b++) { $ht = $barheight[$b]; $x1 = $b * ($barwidth+$gap); // determine bar position $x2 = $x1+$barwidth; $y2 = 31; $y1 = $y2 - $ht; $col = $ss > $b ? $sig : $nosig; // determine color of this bar imagefilledrectangle($im, $x1, $y1, $x2, $y2, $col); imagerectangle($im, $x1, $y1, $x2, $y2, $black); } header("content-type: image/png"); imagepng($im); imagedestroy($im); ?> To view the images :: ssm.html :: <html> <head> <meta name="generator" content="PhpED Version 4.5 (Build 4513)"> <title>Signal strength</title> <meta name="author" content="Barand"> </head> <body> <img src="ssm.php?ss=0"/> Signal strength 0<br /> <img src="ssm.php?ss=2"/> Signal strength 2<br /> <img src="ssm.php?ss=4"/> Signal strength 4<br /> </body> </html> Link to comment https://forums.phpfreaks.com/topic/48353-generating-a-segmented-signal-strength-graph/#findComment-240373 Share on other sites More sharing options...
heckenschutze Posted April 28, 2007 Share Posted April 28, 2007 GD is pretty much the only thing that could do this Um, no? How bout parsing / editing a bitmap yourself... or using static images Link to comment https://forums.phpfreaks.com/topic/48353-generating-a-segmented-signal-strength-graph/#findComment-240375 Share on other sites More sharing options...
signal Posted April 30, 2007 Author Share Posted April 30, 2007 Thank you Barand. That worked out very well indeed. Link to comment https://forums.phpfreaks.com/topic/48353-generating-a-segmented-signal-strength-graph/#findComment-241954 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.