how to generate a progress bar / capacity bar 
Author Message
 how to generate a progress bar / capacity bar

Hi,
I have some (database) data devices that my script gets info on. I
display the capacity of the devices and how much each is being used
buy %.

I now want to turn this text info into a more pretty picture, so to
speak. A sort of capacity bar along the screen. To represent the %
filled.

But I have no idea how to do this.
Could some one point me in a direction please

thanks

Pete.



Thu, 10 Nov 2005 02:04:55 GMT  
 how to generate a progress bar / capacity bar

Sands contained the following:

Quote:
>I now want to turn this text info into a more pretty picture, so to
>speak. A sort of capacity bar along the screen. To represent the %
>filled.

>But I have no idea how to do this.
>Could some one point me in a direction please

Assuming you can assign each percentage to a variable (or an array) like
$percentage below

Create a css  class like so:

<style type="text/css">
<!--
.bar1 {  font-family: Arial, Helvetica, sans-serif; font-weight: bold;
width: <?php print $percentage ?>%; padding-left: 2px; color: #FFFFFF;
background-color: #FF0000; font-size: x-small; }
-->
</style>

 for each value.  Apply it to what you like, paragraph tag table row etc.

--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/



Thu, 10 Nov 2005 02:34:22 GMT  
 how to generate a progress bar / capacity bar
You could try this using the GD library

Here is some javascript/php I created which uses a percentage value
generated in a piece of javascript to call a php script to generate a
percentage bar:

getpng.htm

function VUgauge(gaugeID)
{
 var n=20;
 var time=new Date();
 var n=time.getSeconds();
 n=Math.floor((n*100)/60);

 document.getElementById(gaugeID).src='makepng.php?percent='+n;
 var temp=setTimeout("VUgauge('gauge1')",1000);

Quote:
}

<body onLoad="VUgauge('gauge1');">
<img id="gauge1" alt="dynamically generated png image">

and in makepng.php

// this reads the percentage parameter from the URL, but it can just as
easily come from a variable on the server.
 $percent=$_GET["percent"];

 $x1=floor(460*($percent/100));

// create image 500 pixels wide by 50 high
 $im = ImageCreate(500, 50);

// allocate colours
 $red = ImageColorAllocate($im, 255, 0, 0);
 $black = ImageColorAllocate($im, 0, 0, 0);

// create hexagonal shape, length determined by percentage parameter
 $points=array(10,25,20,45,($x1+20),45,($x1+30),25,($x1+20),5,20,5);

// fill image - black background
 imagefill($im,0,0,$black);

// fill shape with red
 imagefilledpolygon($im,$points,6,$red);

// write percentage parameter in black
 imagestring($im,5,20,20,$percent.'%',$black);

// send the image to the browser
 header("Content-type: image/png");
 ImagePNG($im)

http://81.86.147.17/test/getpng.htm


Quote:
> Hi,
> I have some (database) data devices that my script gets info on. I
> display the capacity of the devices and how much each is being used
> buy %.

> I now want to turn this text info into a more pretty picture, so to
> speak. A sort of capacity bar along the screen. To represent the %
> filled.

> But I have no idea how to do this.
> Could some one point me in a direction please

> thanks

> Pete.



Thu, 10 Nov 2005 15:55:40 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Progress Bar In Main App Status Bar

2. Progress Bar in Status Bar

3. VWIN32: Smaller title bar and scroll bars? (fwd)

4. VWIN32: Smaller title bar and scroll bars?

5. NetExpress: Icon in title bar / task bar

6. only add a scroll bar when the window is minimized and scroll bar is needed

7. Download a file, displaying progress bar

8. amazingly difficult progress bar

9. Need help with thread and progress bar

10. Progress Bar

11. Progress Bar colours

12. Another Progress Bar

 

 
Powered by phpBB® Forum Software