mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-25 09:49:20 +00:00
SVG: Fixing min/max errors
git-svn-id: https://svn.fhem.de/fhem/trunk@4314 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
59a7d84ae5
commit
ea7b61cd0c
@ -1165,21 +1165,21 @@ SVG_render($$$$$$$$$)
|
||||
#-- Round values, compute a nice step
|
||||
my $dh = $hmax{$a} - $hmin{$a};
|
||||
my ($step, $mi, $ma) = (1, 1, 1);
|
||||
my @limit = (0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, 100,
|
||||
200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000,
|
||||
my @limit = (0.001, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50,
|
||||
100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000,
|
||||
200000, 500000, 1000000, 2000000);
|
||||
|
||||
for my $li (0..$#limit-1) {
|
||||
my $l = $limit[$li];
|
||||
next if($dh > $l);
|
||||
$ma = SVG_doround($hmax{$a}, $l/10, 1);
|
||||
$mi = SVG_doround($hmin{$a}, $l/10, 0);
|
||||
|
||||
if(($ma-$mi)/($l/10) >= 7) { # If more then 7 steps, then choose next
|
||||
next if($dh > $l*10);
|
||||
$ma = SVG_doround($hmax{$a}, $l, 1);
|
||||
$mi = SVG_doround($hmin{$a}, $l, 0);
|
||||
if(($ma-$mi)/$l >= 7) { # If more then 7 steps, then choose next
|
||||
$l = $limit[$li+1];
|
||||
$ma = SVG_doround($hmax{$a}, $l/10, 1);
|
||||
$mi = SVG_doround($hmin{$a}, $l/10, 0);
|
||||
$ma = SVG_doround($hmax{$a}, $l, 1);
|
||||
$mi = SVG_doround($hmin{$a}, $l, 0);
|
||||
}
|
||||
$step = $l/10;
|
||||
$step = $l;
|
||||
last;
|
||||
}
|
||||
if($step==0.001 && $hmax{$a}==$hmin{$a}) { # Don't want 0.001 range for nil
|
||||
@ -1481,10 +1481,15 @@ SVG_doround($$$)
|
||||
{
|
||||
my ($v, $step, $isup) = @_;
|
||||
$step = 1 if(!$step); # Avoid division by zero
|
||||
|
||||
my $d = $v/$step;
|
||||
my $dr = int($d);
|
||||
return $v if($d == $dr);
|
||||
|
||||
if($v >= 0) {
|
||||
return (int($v/$step))*$step+($isup ? $step : 0);
|
||||
return int($v/$step)*$step+($isup ? $step : 0);
|
||||
} else {
|
||||
return (int($v/$step))*$step+($isup ? 0 : -$step);
|
||||
return int($v/$step)*$step+($isup ? 0 : -$step);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user