mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
98_SVG.pm: add endPotNow/endPlotToday as SVG attribute, some endPlotNow fixes (Forum #35352)
git-svn-id: https://svn.fhem.de/fhem/trunk@8292 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
03df8c5a28
commit
28c9cdff60
@ -57,6 +57,7 @@ SVG_Initialize($)
|
|||||||
|
|
||||||
$hash->{DefFn} = "SVG_Define";
|
$hash->{DefFn} = "SVG_Define";
|
||||||
$hash->{AttrList} = "fixedoffset fixedrange startDate plotsize nrAxis ".
|
$hash->{AttrList} = "fixedoffset fixedrange startDate plotsize nrAxis ".
|
||||||
|
"endPlotNow endPlotToday ".
|
||||||
"label title plotfunction captionLeft:1,0";
|
"label title plotfunction captionLeft:1,0";
|
||||||
$hash->{SetFn} = "SVG_Set";
|
$hash->{SetFn} = "SVG_Set";
|
||||||
$hash->{FW_summaryFn} = "SVG_FwFn";
|
$hash->{FW_summaryFn} = "SVG_FwFn";
|
||||||
@ -114,6 +115,15 @@ SVG_Set($@)
|
|||||||
return $err;
|
return $err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
SVG_Attr($$$$)
|
||||||
|
{
|
||||||
|
my ($parent, $dev, $attr, $default) = @_;
|
||||||
|
my $val = AttrVal($dev, $attr, undef);
|
||||||
|
return $val if(defined($val));
|
||||||
|
return AttrVal($parent, $attr, $default);
|
||||||
|
}
|
||||||
|
|
||||||
##################
|
##################
|
||||||
sub
|
sub
|
||||||
SVG_FwDetail($@)
|
SVG_FwDetail($@)
|
||||||
@ -170,7 +180,8 @@ SVG_FwFn($$$$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# plots navigation buttons
|
# plots navigation buttons
|
||||||
if (AttrVal($d,"plotmode",$FW_plotmode) ne "gnuplot") {
|
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:-]*$/) {
|
||||||
|
|
||||||
@ -184,7 +195,7 @@ SVG_FwFn($$$$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(AttrVal($FW_wname, "plotmode", "SVG") eq "jsSVG") {
|
if($pm eq "jsSVG") {
|
||||||
my @d=split(":",$defs{$d}{DEF});
|
my @d=split(":",$defs{$d}{DEF});
|
||||||
my ($err, @svgplotfile) = FileRead("$FW_gplotdir/$d[1].gplot");
|
my ($err, @svgplotfile) = FileRead("$FW_gplotdir/$d[1].gplot");
|
||||||
($err, @svgplotfile) = FileRead("$FW_gplotdir/template.gplot") if($err);
|
($err, @svgplotfile) = FileRead("$FW_gplotdir/template.gplot") if($err);
|
||||||
@ -218,7 +229,7 @@ SVG_FwFn($$$$)
|
|||||||
"&logfile=$hash->{LOGFILE}".
|
"&logfile=$hash->{LOGFILE}".
|
||||||
"&pos=" . join(";", map {"$_=$FW_pos{$_}"} keys %FW_pos);
|
"&pos=" . join(";", map {"$_=$FW_pos{$_}"} keys %FW_pos);
|
||||||
|
|
||||||
if(AttrVal($d,"plotmode",$FW_plotmode) eq "SVG") {
|
if($pm eq "SVG") {
|
||||||
$ret .= "<div class=\"SVGplot SVG_$d\">";
|
$ret .= "<div class=\"SVGplot SVG_$d\">";
|
||||||
|
|
||||||
if(SVG_isEmbed($FW_wname)) {
|
if(SVG_isEmbed($FW_wname)) {
|
||||||
@ -849,7 +860,7 @@ SVG_calcOffsets($$)
|
|||||||
my @zrange = split(" ", $zoom); #fixedrange with offset
|
my @zrange = split(" ", $zoom); #fixedrange with offset
|
||||||
if(defined($zrange[1])) { $off += $zrange[1]; $zoom=$zrange[0]; } #fixedrange with offset
|
if(defined($zrange[1])) { $off += $zrange[1]; $zoom=$zrange[0]; } #fixedrange with offset
|
||||||
|
|
||||||
my $endPlotNow = (AttrVal($FW_wname, "endPlotNow", undef) && !$st);
|
my $endPlotNow = (SVG_Attr($FW_wname, $d, "endPlotNow", undef) && !$st);
|
||||||
if($zoom eq "hour") {
|
if($zoom eq "hour") {
|
||||||
if($endPlotNow) {
|
if($endPlotNow) {
|
||||||
my $t = int(($now + $off*3600 - 3600)/300.0)*300 + 300;
|
my $t = int(($now + $off*3600 - 3600)/300.0)*300 + 300;
|
||||||
@ -900,7 +911,7 @@ SVG_calcOffsets($$)
|
|||||||
|
|
||||||
} elsif($zoom eq "week") {
|
} elsif($zoom eq "week") {
|
||||||
my @l = localtime($now);
|
my @l = localtime($now);
|
||||||
my $start = (AttrVal($FW_wname, "endPlotToday", undef) ? 6 : $l[6]);
|
my $start = (SVG_Attr($FW_wname, $d, "endPlotToday", undef) ? 6 : $l[6]);
|
||||||
my $t = $now - ($start*86400) + ($off*86400)*7;
|
my $t = $now - ($start*86400) + ($off*86400)*7;
|
||||||
@l = localtime($t);
|
@l = localtime($t);
|
||||||
$SVG_devs{$d}{from} = SVG_tspec(3,0,@l);
|
$SVG_devs{$d}{from} = SVG_tspec(3,0,@l);
|
||||||
@ -909,7 +920,7 @@ SVG_calcOffsets($$)
|
|||||||
|
|
||||||
} elsif($zoom eq "month") {
|
} elsif($zoom eq "month") {
|
||||||
my ($endDay, @l);
|
my ($endDay, @l);
|
||||||
if(AttrVal($FW_wname, "endPlotToday", undef)) {
|
if(SVG_Attr($FW_wname, $d, "endPlotToday", undef)) {
|
||||||
@l = localtime($now+86400);
|
@l = localtime($now+86400);
|
||||||
$endDay = $l[3];
|
$endDay = $l[3];
|
||||||
$off--;
|
$off--;
|
||||||
@ -1249,9 +1260,8 @@ SVG_render($$$$$$$$$$)
|
|||||||
$SVG_RET="";
|
$SVG_RET="";
|
||||||
my $SVG_ss = AttrVal($parent_name, "smallscreen", 0);
|
my $SVG_ss = AttrVal($parent_name, "smallscreen", 0);
|
||||||
|
|
||||||
my $nr_axis = AttrVal($parent_name,"nrAxis","1,1");
|
|
||||||
my ($nr_left_axis,$nr_right_axis,$use_left_axis,$use_right_axis) =
|
my ($nr_left_axis,$nr_right_axis,$use_left_axis,$use_right_axis) =
|
||||||
split(",", AttrVal($name,"nrAxis",$nr_axis));
|
split(",", SVG_Attr($parent_name, $name,"nrAxis","1,1"));
|
||||||
|
|
||||||
$use_left_axis = $nr_left_axis if( !defined($use_left_axis) );
|
$use_left_axis = $nr_left_axis if( !defined($use_left_axis) );
|
||||||
$use_right_axis = $nr_right_axis if( !defined($use_right_axis) );
|
$use_right_axis = $nr_right_axis if( !defined($use_right_axis) );
|
||||||
@ -1520,7 +1530,7 @@ SVG_render($$$$$$$$$$)
|
|||||||
if(!$conf{xrange});
|
if(!$conf{xrange});
|
||||||
$initoffset = $step;
|
$initoffset = $step;
|
||||||
|
|
||||||
if(AttrVal($FW_wname, "endPlotNow", undef) && $ddur>1.1 && $ddur<7.1) {
|
if(SVG_Attr($parent_name,$name,"endPlotNow",undef) && $ddur>1.1 && $ddur<6.9){
|
||||||
my $now = time();
|
my $now = time();
|
||||||
$initoffset -= ($now+fhemTzOffset($now))%86400; # Forum #25768
|
$initoffset -= ($now+fhemTzOffset($now))%86400; # Forum #25768
|
||||||
}
|
}
|
||||||
@ -2503,6 +2513,8 @@ plotAsPng(@)
|
|||||||
<li><a href="#plotsize">plotsize</a></li><br>
|
<li><a href="#plotsize">plotsize</a></li><br>
|
||||||
|
|
||||||
<li><a href="#plotmode">plotmode</a></li><br>
|
<li><a href="#plotmode">plotmode</a></li><br>
|
||||||
|
<li><a href="#endPlotNow">endPlotNow</a></li><br>
|
||||||
|
<li><a href="#endPlotToday">endPlotToday</a></li><br>
|
||||||
|
|
||||||
<a name="label"></a>
|
<a name="label"></a>
|
||||||
<li>label<br>
|
<li>label<br>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user