2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

98_SVG.pm: new label alignments by (95248)

git-svn-id: https://svn.fhem.de/fhem/trunk@24084 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2021-03-25 16:10:28 +00:00
parent 2465b0ce69
commit a40f3a891d

View File

@ -1651,7 +1651,7 @@ SVG_render($$$$$$$$$$)
}
$tstep = $step;
$first_tag=""; $tag=". 6";
$aligntext = 2; $aligntics = 2;
$aligntext = 3; $aligntics = 3;
}
my $barwidth = $tstep;
@ -1674,12 +1674,13 @@ SVG_render($$$$$$$$$$)
}
} else { # times
$initoffset = int(($tstep/2)/86400)*86400 if($aligntics == 1);
for(my $i = $fromsec+$initoffset; $i < $tosec; $i += $tstep) {
for(my $i = $fromsec; $i < $tosec; $i += $tstep) {
$i = SVG_time_align($i,$aligntics);
$off1 = int($x+($i-$fromsec)*$tmul);
SVG_pO "<polyline class='SVGplot' points='$off1,$y $off1,$off2'/>";
SVG_pO "<polyline class='SVGplot' points='$off1,$off3 $off1,$off4'/>";
if($off1 > $x+8 && $off1 < $x+$w-8) {
SVG_pO "<polyline class='SVGplot' points='$off1,$y $off1,$off2'/>";
SVG_pO "<polyline class='SVGplot' points='$off1,$off3 $off1,$off4'/>";
}
}
}
@ -1731,14 +1732,25 @@ SVG_render($$$$$$$$$$)
}
} else { # times
$initoffset = 86400 if($aligntext == 1);
for(my $i = $fromsec+$initoffset; $i < $tosec; $i += $step) {
for(my $i = $fromsec; $i < $tosec; $i += $step) {
$i = SVG_time_align($i,$aligntext);
$off1 = int($x+($i-$fromsec)*$tmul);
if($aligntext >= 2) { # center month and year
$off1 = int($x+($i-$fromsec+$step/2)*$tmul);
} else {
$off1 = int($x+($i-$fromsec)*$tmul);
}
$t = SVG_fmtTime($tag, $i);
SVG_pO "<text x=\"$off1\" y=\"$off2\" class=\"ylabel\" " .
"text-anchor=\"middle\">$t</text>";
SVG_pO " <polyline points=\"$off1,$y $off1,$off4\" class=\"hgrid\"/>";
if($off1 == $x) {
SVG_pO "<text x=\"$off1\" y=\"$off2\" class=\"ylabel\" " .
"text-anchor=\"left\">$t</text>";
} elsif ($off1 < $x+$w-8) {
SVG_pO "<text x=\"$off1\" y=\"$off2\" class=\"ylabel\" " .
"text-anchor=\"middle\">$t</text>";
}
$off1 = int($x+($i-$fromsec)*$tmul);
if($off1 > $x+8 && $off1 < $x+$w-8) {
SVG_pO " <polyline points=\"$off1,$y $off1,$off4\" class=\"hgrid\"/>";
}
}
}
@ -2374,11 +2386,12 @@ sub
SVG_time_align($$)
{
my ($v,$align) = @_;
my $wl = $FW_webArgs{detail};
return $v if(!$align);
if($align == 1) { # Look for the beginning of the week
for(;;) {
my @a = localtime($v);
return $v if($a[6] == 0);
return $v if($a[6] == SVG_Attr($FW_wname, $wl, "plotWeekStartDay", 0));
$v += 86400;
}
}
@ -2389,6 +2402,13 @@ SVG_time_align($$)
$v += 86400;
}
}
if($align == 3) { # Look for the beginning of the year
for(;;) {
my @a = localtime($v);
return $v if($a[7] == 0);
$v += 86400;
}
}
}
sub