Hauptmenü

SVG Wochenstart

Begonnen von Virsacer, 08 Juni 2015, 10:58:54

Vorheriges Thema - Nächstes Thema

Virsacer

Hi,

konnte leider in der Commandref nix finden, was mir hilft:

Wenn man bei nem SVG rauszoom, sodass eine Woche angezeigt wird, so beginnt diese Woche mit dem Sonntag - kann man das irgendwie auf Montag umstellen?

rudolfkoenig

Nicht ohne nennenswerte Programmierung.

Virsacer

Hm, schade - ich finde das schon etwas unschön...

Virsacer

#3
Zitat von: rudolfkoenig am 08 Juni 2015, 11:07:31
Nicht ohne nennenswerte Programmierung.
Hielt sich in Grenzen:

diff -r 30dcfedb4e2c FHEM/98_SVG.pm
--- a/FHEM/98_SVG.pm Wed Sep 16 11:41:19 2015 +0000
+++ b/FHEM/98_SVG.pm Wed Sep 16 18:47:00 2015 +0200
@@ -913,7 +913,7 @@

   } elsif($zoom eq "week") {
     my @l = localtime($now);
-    my $start = (SVG_Attr($FW_wname, $wl, "endPlotToday", undef) ? 6 : $l[6]);
+    my $start = (SVG_Attr($FW_wname, $wl, "endPlotToday", undef) ? 6 : $l[6] - 1);
     my $t = $now - ($start*86400) + ($off*86400)*7;
     @l = localtime($t);
     $SVG_devs{$d}{from} = SVG_tspec(3,0,@l);


EDIT: Hm, ich merke gerade da wird er wohl Sonntags ein Problem haben...

rudolfkoenig

:)

SO meinte ich die Aenderung natuerlich nicht.

Virsacer

Meintest du, dass man das als Option setzen können sollte, oder wie?

Jedenfalls so funktioniert es, wie ich es mir vorgestellt habe:


diff -r 30dcfedb4e2c FHEM/98_SVG.pm
--- a/FHEM/98_SVG.pm Wed Sep 16 11:41:19 2015 +0000
+++ b/FHEM/98_SVG.pm Sun Sep 20 15:11:12 2015 +0000
@@ -913,7 +913,8 @@

   } elsif($zoom eq "week") {
     my @l = localtime($now);
-    my $start = (SVG_Attr($FW_wname, $wl, "endPlotToday", undef) ? 6 : $l[6]);
+    my $start = (SVG_Attr($FW_wname, $wl, "endPlotToday", undef) ? 6 : $l[6] - 1);
+    $start += 7 if($start < 0);
     my $t = $now - ($start*86400) + ($off*86400)*7;
     @l = localtime($t);
     $SVG_devs{$d}{from} = SVG_tspec(3,0,@l);

rudolfkoenig

ZitatMeintest du, dass man das als Option setzen können sollte, oder wie?

Sicher, nicht jeder ist der Ansicht, dass die Woche in der SVG ab sofort mit Montag anfangen muss.
Fuer "Alt"-benutzer sollte sich zunaechst auch nichts aendern.

Virsacer

War jetzt auch nicht wirklich großer Aufwand:


diff -r 79fa915e1988 FHEM/01_FHEMWEB.pm
--- a/FHEM/01_FHEMWEB.pm Mon Sep 28 09:43:01 2015 +0000
+++ b/FHEM/01_FHEMWEB.pm Mon Sep 28 12:01:46 2015 +0200
@@ -159,6 +159,7 @@
     plotmode:gnuplot,gnuplot-scroll,SVG
     plotEmbed:0,1
     plotsize
+    plotStartWeekMondays:0,1
     nrAxis
     redirectCmds:0,1
     refresh
@@ -2884,8 +2885,8 @@
     <a name="endPlotToday"></a>
     <li>endPlotToday<br>
         If this FHEMWEB attribute is set to 1, then week and month plots will
-        end today. Else the current week (starting at Sunday) or the current
-        month will be shown.<br>
+        end today. Else the current week or the current month will be shown.
+        <br>
         </li><br>

     <a name="endPlotNow"></a>
@@ -2925,6 +2926,10 @@
         makes the plotfork attribute meaningless.<br>
     </li><br>

+    <a name="plotStartWeekMondays"></a>
+    <li>plotStartWeekMondays<br>
+        The current week starts on Mondays.<br>
+    </li><br>

     <a name="basicAuth"></a>
     <li>basicAuth, basicAuthMsg<br>
@@ -3612,6 +3617,10 @@
         wirkungslos macht.
     </li><br>

+    <a name="plotStartWeekMondays"></a>
+    <li>plotStartWeekMondays<br>
+        Die aktuelle Woche beginnt Montags.<br>
+    </li><br>

     <a name="basicAuth"></a>
     <li>basicAuth, basicAuthMsg<br>
diff -r 79fa915e1988 FHEM/98_SVG.pm
--- a/FHEM/98_SVG.pm Mon Sep 28 09:43:01 2015 +0000
+++ b/FHEM/98_SVG.pm Mon Sep 28 12:01:46 2015 +0200
@@ -913,7 +913,8 @@

   } elsif($zoom eq "week") {
     my @l = localtime($now);
-    my $start = (SVG_Attr($FW_wname, $wl, "endPlotToday", undef) ? 6 : $l[6]);
+    my $start = (SVG_Attr($FW_wname, $wl, "endPlotToday", undef) ? 6 : $l[6] - AttrVal($FW_wname, "plotStartWeekMondays", 0));
+    $start += 7 if($start < 0);
     my $t = $now - ($start*86400) + ($off*86400)*7;
     @l = localtime($t);
     $SVG_devs{$d}{from} = SVG_tspec(3,0,@l);

rudolfkoenig

ZitatWar jetzt auch nicht wirklich großer Aufwand:

Stimmt, ist ja auch nicht vollstaendig: Im SVG werden solche Attribute per SVG_Attr abgefragt, damit sie sowohl in FHEMWEB wie auch in SVG definiert werden koennen.

Ich habe die Aenderung modifiziert eingecheckt: das Attribut habe ich plotWeekStartDay genannt, 1 ist Montag, erlaubt sind Werte 0-6. Setzbar in FHEMWEB oder SVG.