mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
98_SVG.pm: fix bars (Forum #35028)
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@8214 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
ca39d62513
commit
c6ece03bde
@ -129,15 +129,16 @@ SVG_FwDetail($@)
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub
|
sub
|
||||||
jsSVG_getAttrs($)
|
jsSVG_getAttrs($;$)
|
||||||
{
|
{
|
||||||
my ($d) = @_;
|
my ($d , $flt) = @_;
|
||||||
return join("", map { #00 arrives as 65533 in JS
|
return join("", map { #00 arrives as 65533 in JS
|
||||||
my $v=$attr{$d}{$_};
|
my $v=$attr{$d}{$_};
|
||||||
$v =~ s/'/'/g;
|
$v =~ s/'/'/g;
|
||||||
"$_=$v";
|
"$_=$v";
|
||||||
} keys %{$attr{$d}});
|
} grep { $flt ? $flt->{$_} : 1 } keys %{$attr{$d}});
|
||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
@ -168,26 +169,6 @@ SVG_FwFn($$$$)
|
|||||||
$pageHash->{jsLoaded} = 1 if($pageHash);
|
$pageHash->{jsLoaded} = 1 if($pageHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(AttrVal($FW_wname, "plotmode", "SVG") eq "jsSVG") {
|
|
||||||
|
|
||||||
my @d=split(":",$defs{$d}{DEF});
|
|
||||||
my $gplot;
|
|
||||||
if(open(FH, "$FW_gplotdir/$d[1].gplot")) {
|
|
||||||
$gplot = join("",<FH>);
|
|
||||||
$gplot =~ s/'/'/g;
|
|
||||||
$gplot =~ s/\n//g;
|
|
||||||
}
|
|
||||||
close(FH);
|
|
||||||
|
|
||||||
$ret .= "<div id='jsSVG_$d' class='jsSVG' ".
|
|
||||||
"attr='".jsSVG_getAttrs($d)."' ".
|
|
||||||
"parentAttr='".jsSVG_getAttrs($FW_wname)."' ".
|
|
||||||
"gplotFile='$gplot' source='$d[0]'>".
|
|
||||||
"</div>";
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# plots navigation buttons
|
# plots navigation buttons
|
||||||
if (AttrVal($d,"plotmode",$FW_plotmode) ne "gnuplot") {
|
if (AttrVal($d,"plotmode",$FW_plotmode) ne "gnuplot") {
|
||||||
if((!$pageHash || !$pageHash->{buttons}) &&
|
if((!$pageHash || !$pageHash->{buttons}) &&
|
||||||
@ -202,6 +183,32 @@ SVG_FwFn($$$$)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(AttrVal($FW_wname, "plotmode", "SVG") eq "jsSVG") {
|
||||||
|
my @d=split(":",$defs{$d}{DEF});
|
||||||
|
my ($err, @svgplotfile) = FileRead("$FW_gplotdir/$d[1].gplot");
|
||||||
|
($err, @svgplotfile) = FileRead("$FW_gplotdir/template.gplot") if($err);
|
||||||
|
my $gplot = join("", @svgplotfile);
|
||||||
|
$gplot =~ s/'/'/g;
|
||||||
|
my %webattrflt = ( endPlotNow=>1, endPlotToday=>1, plotmode=>1,
|
||||||
|
plotsize=>1, nrAxis=>1, stylesheetPrefix=>1 );
|
||||||
|
if(!$pageHash || !$pageHash->{jssvgLoaded}) {
|
||||||
|
$ret .=
|
||||||
|
"<script type='text/javascript' src='$FW_ME/pgm2/jsSVG.js'></script>";
|
||||||
|
$pageHash->{jssvgLoaded} = 1 if($pageHash);
|
||||||
|
}
|
||||||
|
|
||||||
|
SVG_calcOffsets($d[0], $d);
|
||||||
|
$ret .= "<div id='jsSVG_$d' class='jsSVG' ".
|
||||||
|
"data-webAttr='".jsSVG_getAttrs($FW_wname, \%webattrflt)."' ".
|
||||||
|
"data-svgAttr='".jsSVG_getAttrs($d)."' ".
|
||||||
|
"data-from='".$SVG_devs{$d[0]}{from}."' ".
|
||||||
|
"data-to='" .$SVG_devs{$d[0]}{to} ."' ".
|
||||||
|
"data-gplotFile='$gplot' source='$d[0]'>".
|
||||||
|
"</div>";
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
my $arg="$FW_ME/SVG_showLog?dev=$d".
|
my $arg="$FW_ME/SVG_showLog?dev=$d".
|
||||||
"&logdev=$hash->{LOGDEVICE}".
|
"&logdev=$hash->{LOGDEVICE}".
|
||||||
"&gplotfile=$hash->{GPLOTFILE}".
|
"&gplotfile=$hash->{GPLOTFILE}".
|
||||||
@ -1800,13 +1807,13 @@ SVG_render($$$$$$$$$$)
|
|||||||
$ret .= sprintf(" %d,%d %d,%d %d,%d %d,%d",
|
$ret .= sprintf(" %d,%d %d,%d %d,%d %d,%d",
|
||||||
$x,$y+$h, $x,$y1, $x+$w,$y1, $x+$w,$y+$h);
|
$x,$y+$h, $x,$y1, $x+$w,$y1, $x+$w,$y+$h);
|
||||||
} else {
|
} else {
|
||||||
$barwidth = $barwidth*$tmul;
|
my $bw = $barwidth*$tmul;
|
||||||
# bars are all of equal width (see far above !),
|
# bars are all of equal width (see far above !),
|
||||||
# position rounded to integer multiples of bar width
|
# position rounded to integer multiples of bar width
|
||||||
foreach my $i (0..int(@{$dxp})-1) {
|
foreach my $i (0..int(@{$dxp})-1) {
|
||||||
my ($x1, $y1) = ( $x +4 + $dxp->[$i] - $barwidth,
|
my ($x1, $y1) = ( $x +4 + $dxp->[$i] - $bw,
|
||||||
$y +$h-($dyp->[$i]-$min)*$hmul);
|
$y +$h-($dyp->[$i]-$min)*$hmul);
|
||||||
my ($x2, $y2) = ($barwidth, ($dyp->[$i]-$min)*$hmul);
|
my ($x2, $y2) = ($bw, ($dyp->[$i]-$min)*$hmul);
|
||||||
SVG_pO "<rect $attributes $lStyle x=\"$x1\" y=\"$y1\" ".
|
SVG_pO "<rect $attributes $lStyle x=\"$x1\" y=\"$y1\" ".
|
||||||
"width=\"$x2\" height=\"$y2\"/>";
|
"width=\"$x2\" height=\"$y2\"/>";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user