mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
SVG.pm: delete plotmode gnuplot, add gnuplot-scroll-SVG (Forum #35129)
git-svn-id: https://svn.fhem.de/fhem/trunk@9577 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
61ad1ce5d4
commit
864879b703
@ -157,7 +157,7 @@ FHEMWEB_Initialize($)
|
|||||||
nameDisplay
|
nameDisplay
|
||||||
ploteditor:always,onClick,never
|
ploteditor:always,onClick,never
|
||||||
plotfork:1,0
|
plotfork:1,0
|
||||||
plotmode:gnuplot,gnuplot-scroll,SVG
|
plotmode:gnuplot-scroll,gnuplot-scroll-svg,SVG
|
||||||
plotEmbed:0,1
|
plotEmbed:0,1
|
||||||
plotsize
|
plotsize
|
||||||
plotWeekStartDay:0,1,2,3,4,5,6
|
plotWeekStartDay:0,1,2,3,4,5,6
|
||||||
@ -3206,14 +3206,12 @@ FW_widgetOverride($$)
|
|||||||
<li>SVG<br>
|
<li>SVG<br>
|
||||||
The plots are created with the <a href="#SVG">SVG</a> module.
|
The plots are created with the <a href="#SVG">SVG</a> module.
|
||||||
This is the default.</li>
|
This is the default.</li>
|
||||||
|
|
||||||
<li>gnuplot<br>
|
|
||||||
The plots are created with the gnuplot program. Note: this mode
|
|
||||||
ist only available due to historic reasons.</li>
|
|
||||||
|
|
||||||
<li>gnuplot-scroll<br>
|
<li>gnuplot-scroll<br>
|
||||||
Like the gnuplot-mode, but scrolling to historical values is alos
|
The plots are created with the gnuplot program. The gnuplot
|
||||||
possible, just like with SVG.</li>
|
output terminal PNG is assumed. Scrolling to historical values
|
||||||
|
is also possible, just like with SVG.</li>
|
||||||
|
<li>gnuplot-scroll-svg<br>
|
||||||
|
Like gnuplot-scroll, but the output terminal SVG is assumed.</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li><br>
|
</li><br>
|
||||||
|
|
||||||
@ -3923,15 +3921,15 @@ FW_widgetOverride($$)
|
|||||||
Die Plots werden mit Hilfe des <a href="#SVG">SVG</a> Moduls als SVG
|
Die Plots werden mit Hilfe des <a href="#SVG">SVG</a> Moduls als SVG
|
||||||
Grafik gerendert. Das ist die Standardeinstellung.</li>
|
Grafik gerendert. Das ist die Standardeinstellung.</li>
|
||||||
|
|
||||||
<li>gnuplot<br>
|
<li>gnuplot-scroll<br>
|
||||||
Die Plots werden mit Hilfe des gnuplot Programmes erzeugt. Diese
|
Die plots werden mit dem Programm gnuplot erstellt. Das output
|
||||||
Option ist aus historischen Gründen vorhanden.
|
terminal ist PNG. Der einfache Zugriff auf historische Daten
|
||||||
|
ist möglich (analog SVG).
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>gnuplot-scroll<br>
|
<li>gnuplot-scroll-svg<br>
|
||||||
Wie gnuplot, der einfache Zugriff auf historische Daten ist aber
|
Wie gnuplot-scroll, aber als output terminal wird SVG angenommen.
|
||||||
genauso möglich wie mit dem SVG Modul.</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</li><br>
|
</li><br>
|
||||||
|
|
||||||
|
@ -202,17 +202,15 @@ SVG_FwFn($$$$)
|
|||||||
|
|
||||||
# plots navigation buttons
|
# plots navigation buttons
|
||||||
my $pm = AttrVal($d,"plotmode",$FW_plotmode);
|
my $pm = AttrVal($d,"plotmode",$FW_plotmode);
|
||||||
if($pm ne "gnuplot") {
|
if((!$pageHash || !$pageHash->{buttons}) &&
|
||||||
if((!$pageHash || !$pageHash->{buttons}) &&
|
AttrVal($d, "fixedrange", "x") !~ m/^[ 0-9:-]*$/) {
|
||||||
AttrVal($d, "fixedrange", "x") !~ m/^[ 0-9:-]*$/) {
|
|
||||||
|
|
||||||
$ret .= SVG_zoomLink("zoom=-1", "Zoom-in", "zoom in");
|
$ret .= SVG_zoomLink("zoom=-1", "Zoom-in", "zoom in");
|
||||||
$ret .= SVG_zoomLink("zoom=1", "Zoom-out","zoom out");
|
$ret .= SVG_zoomLink("zoom=1", "Zoom-out","zoom out");
|
||||||
$ret .= SVG_zoomLink("off=-1", "Prev", "prev");
|
$ret .= SVG_zoomLink("off=-1", "Prev", "prev");
|
||||||
$ret .= SVG_zoomLink("off=1", "Next", "next");
|
$ret .= SVG_zoomLink("off=1", "Next", "next");
|
||||||
$pageHash->{buttons} = 1 if($pageHash);
|
$pageHash->{buttons} = 1 if($pageHash);
|
||||||
$ret .= "<br>";
|
$ret .= "<br>";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -268,10 +266,14 @@ SVG_FwFn($$$$)
|
|||||||
}
|
}
|
||||||
$ret .= "</div>";
|
$ret .= "</div>";
|
||||||
|
|
||||||
} else {
|
} elsif($pm eq "gnuplot-scroll") {
|
||||||
$ret .= "<img src=\"$arg\"/>";
|
$ret .= "<img src=\"$arg\"/>";
|
||||||
|
} elsif($pm eq "gnuplot-scroll-svg") {
|
||||||
|
$ret .= "<object type=\"image/svg+xml\" ".
|
||||||
|
"data=\"$arg\">Your browser does not support SVG.</object>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!$pageHash) {
|
if(!$pageHash) {
|
||||||
if($FW_plotmode eq "SVG") {
|
if($FW_plotmode eq "SVG") {
|
||||||
$ret .= SVG_PEdit($FW_wname,$d,$room,$pageHash) . "<br>";
|
$ret .= SVG_PEdit($FW_wname,$d,$room,$pageHash) . "<br>";
|
||||||
@ -849,7 +851,6 @@ SVG_calcOffsets($$)
|
|||||||
my ($d,$wl) = @_;
|
my ($d,$wl) = @_;
|
||||||
|
|
||||||
my $pm = AttrVal($wl,"plotmode",$FW_plotmode);
|
my $pm = AttrVal($wl,"plotmode",$FW_plotmode);
|
||||||
return if($pm eq "gnuplot");
|
|
||||||
|
|
||||||
my ($fr, $fo);
|
my ($fr, $fo);
|
||||||
my $frx; #fixedrange with offset
|
my $frx; #fixedrange with offset
|
||||||
@ -1024,73 +1025,72 @@ SVG_doShowLog($$$$;$)
|
|||||||
|
|
||||||
my $tmpfile = "/tmp/file.$$";
|
my $tmpfile = "/tmp/file.$$";
|
||||||
my $errfile = "/tmp/gnuplot.err";
|
my $errfile = "/tmp/gnuplot.err";
|
||||||
|
|
||||||
|
my $f;
|
||||||
|
my $t;
|
||||||
|
my $xrange;
|
||||||
|
|
||||||
if($pm eq "gnuplot" || !$SVG_devs{$d}{from}) {
|
if(!$SVG_devs{$d}{from}) {
|
||||||
# Fix range, as we are without scroll
|
# Fix range, as we are without scroll
|
||||||
my $f = 0; # From the beginning of time...
|
$f = 0; # From the beginning of time...
|
||||||
my $t = 9; # till the end
|
$t = 9; # till the end
|
||||||
|
$xrange = "\n"; #We don't have a range, but need the new line
|
||||||
|
} else {
|
||||||
# Read the data from the filelog
|
# Read the data from the filelog
|
||||||
my $oll = $attr{global}{verbose};
|
($f,$t)=($SVG_devs{$d}{from}, $SVG_devs{$d}{to});
|
||||||
$attr{global}{verbose} = 0; # Else the filenames will be Log'ged
|
$xrange = "set xrange [\"$f\":\"$t\"]\n";
|
||||||
my @path = split(" ",
|
|
||||||
FW_fC("get $d $file $tmpfile $f $t $srcDesc->{all}", 1));
|
|
||||||
$attr{global}{verbose} = $oll;
|
|
||||||
|
|
||||||
# replace the path with the temporary filenames of the filelog output
|
|
||||||
my $i = 0;
|
|
||||||
$plot =~ s/\".*?using 1:[^ ]+ /"\"$path[$i++]\" using 1:2 "/gse;
|
|
||||||
my $xrange = "\n"; #We don't have a range, but need the new line
|
|
||||||
foreach my $p (@path) { # If the file is empty, write a 0 line
|
|
||||||
next if(!-z $p);
|
|
||||||
open(FH, ">$p");
|
|
||||||
print FH "$f 0\n";
|
|
||||||
close(FH);
|
|
||||||
}
|
|
||||||
|
|
||||||
my $gplot_script = SVG_substcfg(0, $wl, $cfg, $plot, $file, $tmpfile);
|
|
||||||
|
|
||||||
$plot =~ s/ls \w+//g;
|
|
||||||
open(FH, "|gnuplot >> $errfile 2>&1");# feed it to gnuplot
|
|
||||||
print FH $gplot_script, $xrange, $plot;
|
|
||||||
close(FH);
|
|
||||||
|
|
||||||
} elsif($pm eq "gnuplot-scroll") {
|
|
||||||
# Read the data from the filelog
|
|
||||||
my ($f,$t)=($SVG_devs{$d}{from}, $SVG_devs{$d}{to});
|
|
||||||
my $oll = $attr{global}{verbose};
|
|
||||||
$attr{global}{verbose} = 0; # Else the filenames will be Log'ged
|
|
||||||
my @path = split(" ",
|
|
||||||
FW_fC("get $d $file $tmpfile $f $t $srcDesc->{all}", 1));
|
|
||||||
$attr{global}{verbose} = $oll;
|
|
||||||
|
|
||||||
# replace the path with the temporary filenames of the filelog output
|
|
||||||
my $i = 0;
|
|
||||||
$plot =~ s/\".*?using 1:[^ ]+ /"\"$path[$i++]\" using 1:2 "/gse;
|
|
||||||
my $xrange = "set xrange [\"$f\":\"$t\"]\n";
|
|
||||||
foreach my $p (@path) { # If the file is empty, write a 0 line
|
|
||||||
next if(!-z $p);
|
|
||||||
open(FH, ">$p");
|
|
||||||
print FH "$f 0\n";
|
|
||||||
close(FH);
|
|
||||||
}
|
|
||||||
|
|
||||||
my $gplot_script = SVG_substcfg(0, $wl, $cfg, $plot, $file, $tmpfile);
|
|
||||||
|
|
||||||
$plot =~ s/ls \w+//g;
|
|
||||||
open(FH, "|gnuplot >> $errfile 2>&1");# feed it to gnuplot
|
|
||||||
print FH $gplot_script, $xrange, $plot;
|
|
||||||
close(FH);
|
|
||||||
foreach my $p (@path) {
|
|
||||||
unlink($p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$FW_RETTYPE = "image/png";
|
|
||||||
open(FH, "$tmpfile.png"); # read in the result and send it
|
my $oll = $attr{global}{verbose};
|
||||||
binmode (FH); # necessary for Windows
|
$attr{global}{verbose} = 0; # Else the filenames will be Log'ged
|
||||||
FW_pO join("", <FH>);
|
my @path;
|
||||||
|
my $tmp = 0;
|
||||||
|
foreach my $src (@{$srcDesc->{order}}) {
|
||||||
|
my $s = $srcDesc->{src}{$src};
|
||||||
|
my $fname = ($src eq $defs{$d}{LOGDEVICE} ? $defs{$d}{LOGFILE}:"CURRENT");
|
||||||
|
my $cmd = "get $src $fname $tmpfile$tmp $f $t ".$s->{arg};
|
||||||
|
my @files = split(" ", FW_fC($cmd, 1));
|
||||||
|
push(@path, @files);
|
||||||
|
$tmp++;
|
||||||
|
}
|
||||||
|
$attr{global}{verbose} = $oll;
|
||||||
|
|
||||||
|
# replace the path with the temporary filenames of the filelog output
|
||||||
|
my $i = 0;
|
||||||
|
$plot =~ s/\".*?using 1:[^ ]+ /"\"$path[$i++]\" using 1:2 "/gse;
|
||||||
|
foreach my $p (@path) { # If the file is empty, write a 0 line
|
||||||
|
next if(!-z $p);
|
||||||
|
open(FH, ">$p");
|
||||||
|
print FH "$f 0\n";
|
||||||
|
close(FH);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $gplot_script = SVG_substcfg(0, $wl, $cfg, $plot, $file, $tmpfile);
|
||||||
|
|
||||||
|
$plot =~ s/ls \w+//g;
|
||||||
|
open(FH, "|gnuplot >> $errfile 2>&1");# feed it to gnuplot
|
||||||
|
print FH $gplot_script, $xrange, $plot;
|
||||||
close(FH);
|
close(FH);
|
||||||
unlink("$tmpfile.png");
|
foreach my $p (@path) {
|
||||||
|
unlink($p);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($pm eq "gnuplot-scroll") {
|
||||||
|
$FW_RETTYPE = "image/png";
|
||||||
|
open(FH, "$tmpfile.png"); # read in the result and send it
|
||||||
|
binmode (FH); # necessary for Windows
|
||||||
|
FW_pO join("", <FH>);
|
||||||
|
close(FH);
|
||||||
|
unlink("$tmpfile.png");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$FW_RETTYPE = "image/svg+xml";
|
||||||
|
open(FH, "$tmpfile.svg"); # read in the result and send it
|
||||||
|
binmode (FH); # necessary for Windows
|
||||||
|
FW_pO join("", <FH>);
|
||||||
|
close(FH);
|
||||||
|
unlink("$tmpfile.svg");
|
||||||
|
}
|
||||||
|
|
||||||
} elsif($pm eq "SVG") {
|
} elsif($pm eq "SVG") {
|
||||||
my ($f,$t)=($SVG_devs{$d}{from}, $SVG_devs{$d}{to});
|
my ($f,$t)=($SVG_devs{$d}{from}, $SVG_devs{$d}{to});
|
||||||
@ -2328,14 +2328,14 @@ plotAsPng(@)
|
|||||||
<a name="fixedrange"></a>
|
<a name="fixedrange"></a>
|
||||||
<li>fixedrange [offset]<br>
|
<li>fixedrange [offset]<br>
|
||||||
Contains two time specs in the form YYYY-MM-DD separated by a space.
|
Contains two time specs in the form YYYY-MM-DD separated by a space.
|
||||||
In plotmode gnuplot-scroll or SVG the given time-range will be used,
|
In plotmode gnuplot-scroll(-svg) or SVG the given time-range will be
|
||||||
and no scrolling for this SVG will be possible. Needed e.g. for
|
used, and no scrolling for this SVG will be possible. Needed e.g. for
|
||||||
looking at last-years data without scrolling.<br><br>
|
looking at last-years data without scrolling.<br><br> If the value is
|
||||||
If the value is one of hour, day, <N>days, week, month, year than
|
one of hour, day, <N>days, week, month, year than set the zoom
|
||||||
set the zoom level for this SVG independently of the user specified
|
level for this SVG independently of the user specified zoom-level. This
|
||||||
zoom-level. This is useful for pages with multiple plots: one of the
|
is useful for pages with multiple plots: one of the plots is best
|
||||||
plots is best viewed in with the default (day) zoom, the other one with
|
viewed in with the default (day) zoom, the other one with a week
|
||||||
a week zoom.<br>
|
zoom.<br>
|
||||||
|
|
||||||
If given, the optional integer parameter offset refers to a different
|
If given, the optional integer parameter offset refers to a different
|
||||||
period (e.g. last year: fixedrange year -1, 2 days ago: fixedrange day
|
period (e.g. last year: fixedrange year -1, 2 days ago: fixedrange day
|
||||||
@ -2367,13 +2367,11 @@ plotAsPng(@)
|
|||||||
(<L1>, <L2>, etc.). Each value will be evaluated as a perl
|
(<L1>, <L2>, etc.). Each value will be evaluated as a perl
|
||||||
expression, so you have access e.g. to the Value functions.<br><br>
|
expression, so you have access e.g. to the Value functions.<br><br>
|
||||||
|
|
||||||
If the plotmode is gnuplot-scroll or SVG, you can also use the min, max,
|
If the plotmode is gnuplot-scroll(-svg) or SVG, you can also use the min,
|
||||||
mindate, maxdate, avg, cnt, sum, firstval, firstdate, currval (last
|
max, mindate, maxdate, avg, cnt, sum, firstval, firstdate, currval (last
|
||||||
value) and currdate (last date) values of the individual curves, by
|
value) and currdate (last date) values of the individual curves, by
|
||||||
accessing the corresponding
|
accessing the corresponding values from the data hash, see the example
|
||||||
|
below:<br>
|
||||||
values from the data hash, see the example below:<br>
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Fixed text for the right and left axis:<br>
|
<li>Fixed text for the right and left axis:<br>
|
||||||
<ul>
|
<ul>
|
||||||
@ -2525,10 +2523,10 @@ plotAsPng(@)
|
|||||||
<li>fixedrange [offset]<br>
|
<li>fixedrange [offset]<br>
|
||||||
Version 1<br>
|
Version 1<br>
|
||||||
Enthält zwei Zeit-Spezifikationen in der Schreibweise YYYY-MM-DD,
|
Enthält zwei Zeit-Spezifikationen in der Schreibweise YYYY-MM-DD,
|
||||||
getrennt durch ein Leerzeichen. Im Plotmodus gnuplot-Scroll oder SVG wird
|
getrennt durch ein Leerzeichen. Im Plotmodus gnuplot-scroll(-svg) oder
|
||||||
das vorgegebene Intervall verwendet und ein Scrolling der Zeitachse ist
|
SVG wird das vorgegebene Intervall verwendet und ein Scrolling der
|
||||||
nicht möglich. Dies wird z.B. verwendet, um sich die Daten des
|
Zeitachse ist nicht möglich. Dies wird z.B. verwendet, um sich die
|
||||||
vergangenen Jahres ohne Scrollen anzusehen.<br><br>
|
Daten des vergangenen Jahres ohne Scrollen anzusehen.<br><br>
|
||||||
|
|
||||||
Version 2<br>
|
Version 2<br>
|
||||||
Wenn der Wert entweder Tag, <N>Tage, Woche, Monat oder Jahr lautet,
|
Wenn der Wert entweder Tag, <N>Tage, Woche, Monat oder Jahr lautet,
|
||||||
@ -2568,11 +2566,12 @@ plotAsPng(@)
|
|||||||
Jeder Wert wird als Perl-Ausdruck bewertet, deshalb hat man Zugriff z.B.
|
Jeder Wert wird als Perl-Ausdruck bewertet, deshalb hat man Zugriff z.B.
|
||||||
auf die hinterlegten Funktionen. <br><br>
|
auf die hinterlegten Funktionen. <br><br>
|
||||||
|
|
||||||
Egal, ob es sich bei der Plotart um gnuplot-scroll oder SVG handelt, es
|
Egal, ob es sich bei der Plotart um gnuplot-scroll(-svg) oder SVG
|
||||||
können ebenfalls die Werte der individuellen Kurve für min,
|
handelt, es können ebenfalls die Werte der individuellen Kurve
|
||||||
max, mindate, maxdate, avg, cnt, sum, currval (letzter Wert) und currdate
|
für min, max, mindate, maxdate, avg, cnt, sum, currval (letzter
|
||||||
(letztes Datum) durch Zugriff der entsprechenden Werte über das
|
Wert) und currdate (letztes Datum) durch Zugriff der entsprechenden Werte
|
||||||
data Hash verwendet werden. Siehe untenstehendes Beispiel:<br>
|
über das data Hash verwendet werden. Siehe untenstehendes
|
||||||
|
Beispiel:<br>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Beschriftunng der rechten und linken y-Achse:<br>
|
<li>Beschriftunng der rechten und linken y-Achse:<br>
|
||||||
<ul>
|
<ul>
|
||||||
|
Loading…
Reference in New Issue
Block a user