On Tue, 26 Mar 2002 13:18:33 +0100, Svenne Krap <usenet@krap.dk>
wrote:
>On Tue, 26 Mar 2002 11:37:52 +0100, "Andre" <andre21@ofir.dk> wrote:
>
>>Jeg forsøger at lave en søjle, der skal vise temperaturen. Jeg kan bare ikke
>>få den til at passe. Jeg har lavet den i en tabel hvor højden er fastlagt og
>>så gange jeg temperaturen så det skulle passe med højen, det gør det bare
>>ikke. Er det nogle som kan hjælpe mig ??
>
>Den nemmeste måde er at lave en søjle-funktion.
>
>Den funktion laver en tabel med tre rækker / kolonner (afhængigt af om
>søljen skal stå eller ligge).
>
>Og du laver tre gif'er .. en top og bund og et midterstykke (hvis
>søljen er liggende er det hhv. højre,venstre og midte).
>Midterstykket kan du så "strække" ved at sætte en anden heigth/width
>på <img>.
>
>Det burde kunne laves på ca. 20 minutter plus tid forbrugt i
>billedprogram (hvilket er væsentligt mere for mig).
Jeg fandt lige lidt gammel kode.
Både en og to barer sammen både liggende og stående:
1 Liggende :
<?php
if (!$DEFINED_SINGLEVBAR) {
$DEFINED_SINGLEVBAR=true;
function singlevbar($amount, $color="yellow") {
?>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img
src="/images/singlevbar-top.gif" width="12" height="1" alt=""
border="0"></td>
</tr>
<tr>
<td><img src="/images/singlevbar-<?php
echo $color; ?>.gif" width="12" height="<?php echo $amount; ?>" alt=""
border="0"></td>
</tr>
<tr>
<td><img
src="/images/singlevbar-bot.gif" width="12" height="1" alt=""
border="0"></td>
</tr>
</table>
<?php
}
}
?>
1 stående :
<?php
if (!$DEFINED_SINGLEHBAR) {
$DEFINED_SINGLEHBAR=true;
function singlehbar($amount, $color="yellow") {
?>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img
src="/images/singlebar_leftend.gif" width="1" height="12" alt=""
border="0"></td>
<td><img src="/images/singlebar_<?php
echo $color; ?>mid.gif" width="<?php echo $amount; ?>" height="12"
alt="" border="0"></td>
<td><img
src="/images/singlebar_rightend.gif" width="1" height="12" alt=""
border="0"></td>
</tr>
</table>
<?php
}
}
?>
2 liggende :
<?php
class doublevbar {
var $scaling_factor=0.1;
var $img_path="/images/";
var $l_label="Antal click trough's";
var $r_label="Antal eksponeringer";
function sethitsprpix($hpp) {
if ($hpp>0) {
$this->scaling_factor=1/$hpp;
return true;
} else {
return false;
}
}
function setscalingfactor($sf) {
if ($sf>0) {
$this->scaling_factor=$sf;
return true;
} else {
return false;
}
}
function draw($lvalue, $rvalue) {
if ($lvalue>$rvalue) $lvalue=$rvalue;
if ($lvalue < 0 ) return false;
if ($rvalue < 0 ) return false;
$lpix=round($this->scaling_factor * $lvalue);
$rpix=round($this->scaling_factor * $rvalue);
?>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td><img src="<?php echo $this->img_path;
?>bar1lt2.gif" width="12" height="1" alt="<?php echo $this->r_label;
?>" border="0"></td>
<td><img src="<?php echo $this->img_path;
?>bar2rt.gif" width="3" height="1" alt="<?php echo $this->r_label; ?>"
border="0"></td>
</tr>
<?php if ($rpix>=1) { ?>
<tr>
<td><img src="<?php echo $this->img_path;
?>bar1lm2.gif" width="12" height="<?php echo $rpix-$lpix; ?>"
alt="<?php echo $this->r_label; ?>" border="0"></td><!-- -->
<td><img src="<?php echo $this->img_path;
?>bar2rm.gif" width="3" height="<?php echo $rpix-$lpix; ?>" alt="<?php
echo $this->r_label; ?>" border="0"></td><!-- -->
</tr>
<?php }
if ($lpix>=1) { ?>
<tr>
<td><img src="<?php echo $this->img_path;
?>bar1lt.gif" width="12" height="1" alt="<?php echo $this->l_label;
?>" border="0"></td>
<td><img src="<?php echo $this->img_path;
?>bar2rm.gif" width="3" height="1" alt="<?php echo $this->r_label; ?>"
border="0"></td>
</tr>
<?php
}
if ($lpix>=2) { ?>
<tr>
<td><img src="<?php echo $this->img_path;
?>bar1lm.gif" width="12" height="<?php echo $lpix-1; ?>" alt="<?php
echo $this->l_label; ?>" border="0"></td>
<td><img src="<?php echo $this->img_path;
?>bar2rm.gif" width="3" height="<?php echo $lpix-1; ?>" alt="<?php
echo $this->r_label; ?>" border="0"></td>
</tr>
<?php } ?>
<tr>
<td><img src="<?php echo $this->img_path;
?>bar1lb.gif" width="12" height="2" alt="<?php echo $this->l_label;
?>" border="0"></td>
<td><img src="<?php echo $this->img_path;
?>bardot.gif" width="3" height="2" alt="<?php echo $this->r_label; ?>"
border="0"></td>
</tr>
</table>
<?php
}
}
?>
og 2 stående :
<?php
class doublehbar {
var $scaling_factor=0.1;
var $img_path="/images/";
var $t_label="Antal click trough's";
var $b_label="Antal eksponeringer";
function sethitsprpix($hpp) {
if ($hpp>0) {
$this->scaling_factor=1/$hpp;
return true;
} else {
return false;
}
}
function setscalingfactor($sf) {
if ($sf>0) {
$this->scaling_factor=$sf;
return true;
} else {
return false;
}
}
function draw($tvalue, $bvalue) {
if ($tvalue>$bvalue) $tvalue=$bvalue;
if ($tvalue < 0 ) return false;
if ($bvalue < 0 ) return false;
$tpix=round($this->scaling_factor * $tvalue);
$bpix=round($this->scaling_factor * $bvalue);
?>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td><img src="<?php echo
$this->img_path; ?>hbar1l.gif" width="2" height="12" alt="<?php echo
$this->t_label; ?>" border="0"></td>
<?php if($tpix>=1) { ?>
<td><img src="<?php echo
$this->img_path; ?>hbar1m.gif" width="<?php echo $tpix-1; ?>"
height="12" alt="<?php echo $this->t_label; ?>" border="0"></td>
<?php } ?>
<?php if($tpix>0) { ?>
<td><img src="<?php echo
$this->img_path; ?>hbar1r.gif" width="1" height="12" alt="<?php echo
$this->t_label; ?>" border="0"></td>
<?php } ?>
<?php if ($bpix>$tpix) { ?>
<td><img src="<?php echo
$this->img_path; ?>hbar1m2.gif" width="<?php echo $bpix-$tpix; ?>"
height="12" alt="<?php echo $this->b_label; ?>" border="0"></td>
<?php } ?>
<td><img src="<?php echo
$this->img_path; ?>hbar1r2.gif" width="1" height="12" alt="<?php echo
$this->b_label; ?>" border="0"></td>
</tr>
<tr>
<td><img src="<?php echo
$this->img_path; ?>hbar2l.gif" width="2" height="3" alt="<?php echo
$this->b_label; ?>" border="0"></td>
<?php if($tpix>=1) { ?>
<td><img src="<?php echo
$this->img_path; ?>hbar2m.gif" width="<?php echo $tpix-1; ?>"
height="3" alt="<?php echo $this->b_label; ?>" border="0"></td>
<?php } ?>
<?php if($tpix>0) { ?>
<td><img src="<?php echo
$this->img_path; ?>hbar2m.gif" width="1" height="3" alt="<?php echo
$this->b_label; ?>" border="0"></td>
<?php } ?>
<?php if ($bpix>$tpix) { ?>
<td><img src="<?php echo
$this->img_path; ?>hbar2m.gif" width="<?php echo $bpix-$tpix; ?>"
height="3" alt="<?php echo $this->b_label; ?>" border="0"></td>
<?php } ?>
<td><img src="<?php echo
$this->img_path; ?>hbar2r.gif" width="1" height="3" alt="<?php echo
$this->b_label; ?>" border="0"></td>
</tr>
</table>
<?php
}
}
?>
--
Job-offerings with more than a googolplex* USD a year are instantly accepted.
* =
http://www.fpx.de/fp/Fun/Googolplex/