From fba07cd689c87eb98f0b1603fffe2fea5f141ce4 Mon Sep 17 00:00:00 2001 From: Damian <> Date: Sun, 1 Jan 2023 18:13:32 +0000 Subject: [PATCH] 98_DOIF.pm: fixed card plot shift for long time periods git-svn-id: https://svn.fhem.de/fhem/trunk@26938 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/98_DOIF.pm | 51 ++++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/fhem/FHEM/98_DOIF.pm b/fhem/FHEM/98_DOIF.pm index fd5b41241..af0b896a8 100644 --- a/fhem/FHEM/98_DOIF.pm +++ b/fhem/FHEM/98_DOIF.pm @@ -5124,34 +5124,30 @@ sub card my $scale; my $scale_strokes; - my $description; - my $strokes; + my $description=4; + my $strokes=12; my $div = $hours > 168 ? ($hours % 168 == 0 ? 168 : ($hours % 24 == 0 ? 24 : 1)):1; if ($div==168 and $hours/$div/2 == 1) { #2w - $scale=$hours/7; $description=7; $strokes=$description; - $scale_strokes=$scale; } elsif ($hours <= 168*7) { for (my $i=7;$i>=3;$i--) { if ($hours/$div % $i == 0) { - $scale=$hours/$i; - $scale_strokes=$scale; $description=$i; - $strokes=$description; if ($div == 168 and $chart_dim > 130) { $strokes=$description*7; - $scale_strokes=$scale/7; - } + } else { + $strokes=$description; + } last; } } } - - - if (defined $scale) { + $scale=$hours/$description; + $scale_strokes=$hours/$strokes; + if ($hours > 2) { my ($sec,$minutes,$hour,$mday,$month,$year,$wday,$yday,$isdst) = localtime($timebeginn); my $beginhour=int($hour/$scale)*$scale; my $diffsec=($hour-$beginhour)*3600+$minutes*60+$sec; @@ -5162,39 +5158,34 @@ sub card my $x=int((($i)*($chart_dim/$strokes)+$pos_strokes)*10)/10; $out.=sprintf('',$x,0,$x,50) if ($x >= 0 and $x <= $chart_dim); } - for (my $i=0;$i<$description;$i++) { my $h=$beginhour+($i+1)*$scale; $hour=($h >= 24 ? $h % 24:$h); my $x=int((($i*($chart_dim/$description)+$pos))*10)/10; - if ($hour == 0) { - if ($hours <= 168) { - $out.=sprintf('%s',$x,substr(::strftime("%a",localtime($timebeginn+$h*3600)),0,2)); + if ($hours <= 2) { + # $out.=sprintf('%s',$x,::strftime("%H:%M",localtime($time-$hours*3600*(1-$i/3)))); + } elsif ($hours <= 168) { + if ($hour != 0) { + $out.=sprintf('%02d:',$x,$hour); } else { - $out.=sprintf('%s',$x,::strftime("%d.",localtime($timebeginn+$h*3600))); + $out.=sprintf('%s',$x,substr(::strftime("%a",localtime($timebeginn+$h*3600)),0,2)); } + } elsif ($hours <= 168*7) { + $out.=sprintf('%s',$x,::strftime("%d.",localtime($timebeginn+$h*3600))); } else { - $out.=sprintf('%02d:',$x,$hour); - } + $out.=sprintf('%s',$x,::strftime("%d.%m",localtime($timebeginn+$h*3600))); + } } } else { for (my $i=0;$i<=12;$i++) { - my $x=int((($i)*($chart_dim/12)+1)*10)/10; + my $x=int((($i)*($chart_dim/12)+1)*10)/10; $out.=sprintf('',$x,0,$x,50) if ($x >= 0 and $x <= $chart_dim); - } - - for (my $i=0;$i<=3;$i++) { - my $x=int(($i*($chart_dim/3)-1)*10)/10; - if ($hours <=168) { + for (my $i=0;$i<=3;$i++) { + my $x=int(($i*($chart_dim/3)-1)*10)/10; $out.=sprintf('%s',$x+2,::strftime("%H:%M",localtime($time-$hours*3600*(1-$i/3)))); - } elsif ($hours <=168*7 and $hours % 24 == 0) { - $out.=sprintf('%s',$x,::strftime("%d.%H:",localtime($time-$hours*3600*(1-$i/3)))); - } else { - $out.=sprintf('%s',$x+2,::strftime("%d.%m",localtime($time-$hours*3600*(1-$i/3)))); } } } - my ($outplot,$outfooter); my @outfooter;