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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.