Forum Moderators: coopster
For instance, I'd create an image that is 100 pixels wide. And then the HTML width parameter would be equal to this number. So if the job was 50% complete, then it would show the image 50 pixels wide.
Since the appearance of the graphic only varies from top to bottom (an not from left to right) the graphic can be resized from left to right with no distortion...
...in a late-night brainwave, it occurs to me that you can do this without graphics too...
[b]html:[/b]
<div class="bar-graph">
<div class="red" style="width:150px;" title="150 units">150</div>
<div class="blue" style="width:412px;" title="412 units">412</div>
<div class="green" style="width:35px;" title="35 units">35</div>
</div>
[b]css:[/b]
.bar-graph {
text-align:right;
color:#FFFFFF;
font-weight:bold;
font-size:12px;
line-height:20px;
height:20px;
}
.bar-graph div {
border-style:outset;
border-color:#000033;
border-width:3px;
padding:2px;
margin:5px 0;
}
.green {
background-color:green;
}
.red {
background-color:red;
}
.blue {
background-color:blue;
}
Works great, and dead easy to populate the <div> tags with the appropriate info at runtime.
-B
PS - for the sake of completeness, I should mention there's a neato graph library for php: search for "jpgraph"
[edited by: jatar_k at 2:38 am (utc) on Dec. 10, 2003]
[edit reason] turned of smiles [/edit]
If you have 101 images representing values from 0 to 100 (let's say they're named "image_0.gif", "image_1.gif"...), and a value $x, you can load the appropriate image just like this:
<html>
<img src="image_<?php print($x)?>.gif">
</html>
If you're just making a bar graph, then by all means do what they suggest above. But if you have some kind of funky morphed image and you want to display an image that's 43% horse and 57% penguin, then this will work.
If you have 101 images representing values from 0 to 100 (let's say they're named "image_0.gif", "image_1.gif"...), and a value $x, you can load the appropriate image just like this:
That's all good and well if you want to make 101 different images by hand, but if you don't have the time nor patience, it's NOT fun nor productive.