diff --git a/FHEM/01_FHEMWEB.pm b/FHEM/01_FHEMWEB.pm index 148787d73..177fce39e 100755 --- a/FHEM/01_FHEMWEB.pm +++ b/FHEM/01_FHEMWEB.pm @@ -134,6 +134,7 @@ FHEMWEB_Initialize($) plotfork:1,0 plotmode:gnuplot,gnuplot-scroll,SVG plotsize + nrAxis redirectCmds:0,1 refresh reverseLogs:0,1 @@ -2442,6 +2443,14 @@ FW_ActivateInform() smallscreen.
+ +
  • nrAxis
    + the number of axis for which space should be reserved on the left and right sides of a plot + and optionaly how many axes should realy be used on each side, separated by comma: + left,right[,useLeft,useRight]. You can set individual numbers by setting the nrAxis of + the SVG. Default is 1,1. +

  • +
  • SVGcache
    if set, cache plots which won't change any more (the end-date is prior diff --git a/FHEM/98_SVG.pm b/FHEM/98_SVG.pm index f85674015..73acfb2e9 100755 --- a/FHEM/98_SVG.pm +++ b/FHEM/98_SVG.pm @@ -49,7 +49,7 @@ SVG_Initialize($) my ($hash) = @_; $hash->{DefFn} = "SVG_Define"; - $hash->{AttrList} = "fixedoffset fixedrange startDate plotsize label title plotfunction"; + $hash->{AttrList} = "fixedoffset fixedrange startDate plotsize nrAxis label title plotfunction"; $hash->{SetFn} = "SVG_Set"; $hash->{FW_summaryFn} = "SVG_FwFn"; $hash->{FW_detailFn} = "SVG_FwFn"; @@ -914,8 +914,15 @@ SVG_render($$$$$$$$$) my $SVG_ss = AttrVal($parent_name, "smallscreen", 0); return $SVG_RET if(!defined($dp)); + + my $nr_axis = AttrVal($parent_name,"nrAxis","1,1"); + my ($nr_left_axis,$nr_right_axis,$use_left_axis,$use_right_axis) = split(",", AttrVal($name,"nrAxis",$nr_axis)); + $use_left_axis = $nr_left_axis if( !defined($use_left_axis) ); + $use_right_axis = $nr_right_axis if( !defined($use_right_axis) ); + my $th = 16; # "Font" height - my ($x, $y) = (($SVG_ss ? 2 : 3)*$th, 1.2*$th); # Rect offset + my $axis_width = ($SVG_ss ? 2 : 3)*$th; + my ($x, $y) = ($axis_width*$nr_left_axis, 1.2*$th); # Rect offset ###################### # Convert the configuration to a "readable" form -> array to hash @@ -924,7 +931,7 @@ SVG_render($$$$$$$$$) my $ps = "800,400"; $ps = $1 if($conf{terminal} =~ m/.*size[ ]*([^ ]*)/); my ($ow,$oh) = split(",", $ps); # Original width - my ($w, $h) = ($ow-2*$x, $oh-2*$y); # Rect size + my ($w, $h) = ($ow-$nr_left_axis*$axis_width-$nr_right_axis*$axis_width, $oh-2*$y); # Rect size # Keep only the Filter part of the #FileLog $flog = join(" ", map { my @a=split(":",$_); @@ -964,7 +971,7 @@ SVG_render($$$$$$$$$) SVG_pO ""; - my ($off1,$off2) = ($ow/2, 3*$y/4); + my ($off1,$off2) = ($x+$w/2, 3*$y/4); my $title = ($conf{title} ? $conf{title} : " "); $title =~ s//>/g; @@ -973,31 +980,39 @@ SVG_render($$$$$$$$$) ###################### # Copy and Paste labels, hidden by default - SVG_pO " "; - SVG_pO " "; ###################### # Left label = ylabel and right label = y2label - my $t = ($conf{ylabel} ? $conf{ylabel} : ""); - $t =~ s/"//g; if(!$SVG_ss) { - ($off1,$off2) = (3*$th/4, $oh/2); - SVG_pO "$t"; + for my $idx (1..$use_left_axis) { + my $name = "y".($idx)."label"; + $name = "ylabel" if( $idx == 1 ); + my $t = ($conf{$name} ? $conf{$name} : ""); + $t =~ s/"//g; + ($off1,$off2) = ($x-($idx)*$axis_width+3*$th/4, $oh/2); + SVG_pO "$t"; + } - $t = ($conf{y2label} ? $conf{y2label} : ""); - $t =~ s/"//g; - ($off1,$off2) = ($ow-$th/4, $oh/2); - SVG_pO "$t"; + for my $idx ($use_left_axis+1..$use_left_axis+$use_right_axis) { + my $name = "y".($idx)."label"; + $name = "ylabel" if( $idx == 1 ); + my $t = ($conf{$name} ? $conf{$name} : ""); + $t =~ s/"//g; + ($off1,$off2) = ($x+$w+($idx-$use_left_axis)*$axis_width-$th/4, $oh/2); + SVG_pO "$t"; + } } ###################### - ($off1,$off2) = ($ow-$x-$th, $y+$th); + ($off1,$off2) = ($ow-$nr_right_axis*$axis_width-$th, $y+$th); ###################### @@ -1125,7 +1140,7 @@ SVG_render($$$$$$$$$) # then the text and the grid $off1 = $x; $off2 = $y+$h+$th; - $t = SVG_fmtTime($first_tag, $fromsec); + my $t = SVG_fmtTime($first_tag, $fromsec); SVG_pO "$t"; $initoffset = $step; $initoffset = int(($step/2)/86400)*86400 if($aligntext); @@ -1214,30 +1229,30 @@ SVG_render($$$$$$$$$) # offsets my ($align,$display,$cll); - if( $a eq "x1y1" ){ - # first axis = left - $off1 = $x-4-$th*0.3; - $off3 = $x-4; - $off4 = $off3+5; - $align = " text-anchor=\"end\""; - $display = ""; - $cll = ""; - } elsif ( $a eq "x1y2" ){ - # second axis = right - $off1 = $x+4+$w+$th*0.3; - $off3 = $x+4+$w-5; - $off4 = $off3+5; - $align = ""; - $display = ""; - $cll = ""; - } else { - # other axes in between - $off1 = $x-$th*0.3+30; - $off3 = $x+30; - $off4 = $off3+5; - $align = " text-anchor=\"end\""; - $display = " display=\"none\" id=\"hline_$idx\""; - $cll = " class=\"l$idx\""; + if( $a =~ m/x1y(\d)/ ) { + my $idx = $1; + if( $idx <= $use_left_axis ) { + $off1 = $x - ($idx-1)*$axis_width-4-$th*0.3; + $off3 = $x - ($idx-1)*$axis_width-4; + $off4 = $off3+5; + $align = " text-anchor=\"end\""; + $display = ""; + $cll = ""; + } elsif( $idx <= $use_left_axis+$use_right_axis ) { + $off1 = $x+4+$w+($idx-1-$use_left_axis)*$axis_width+$th*0.3; + $off3 = $x+4+$w+($idx-1-$use_left_axis)*$axis_width-5; + $off4 = $off3+5; + $align = ""; + $display = ""; + $cll = ""; + } else { + $off1 = $x-$th*0.3+30; + $off3 = $x+30; + $off4 = $off3+5; + $align = " text-anchor=\"end\""; + $display = " display=\"none\" id=\"hline_$idx\""; + $cll = " class=\"l$idx\""; + } }; #-- grouping