Jump to content

Horizontal Bar Graph


treeleaf20

Recommended Posts

This would best be done through CSS. Just create an invisible bar through CSS, put another bar inside it and let the PHP write the height of that bar. I'll wing some code by hand, but it's not tested so you might need to tweak it some.

 

PHP:

<div class="fullbar">
<div class="percbar" style="height:<? echo $percent; ?>;"> </div>
</div>

 

 

CSS:

div.fullbar {
width: 1em;
height: 20em; }

div.fullbar {
border: 1px solid #000;
background-color: #080;
width: 100%; }

 

Just make sure to calculate the height in percentage and save that in the variable "$percent".

Link to comment
https://forums.phpfreaks.com/topic/181759-horizontal-bar-graph/#findComment-958618
Share on other sites

For some reason this won't work. I put in the CSS and actually change the percbar in the CSS so my CSS looks like this:

 

CSS:

div.fullbar {
width: 1em;
height: 20em; }

div.percbar {
border: 1px solid #555555;
background-color: #fff;
width:100%; }

 

And my PHP looks like:

<?
$percent1 = "90%";
$percent2 = "10%";
?>
</form>
<div class="fullbar">
<div class="percbar" style="height:<? echo $percent1; ?>;"> </div>
<div class="percbar" style="height:<? echo $percent2; ?>;"> </div>
</div>

 

So I just hardcoded the values in for now. They both show up for they are the same size. Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/181759-horizontal-bar-graph/#findComment-958633
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.