Author: zecas
Date: Sun Dec 13 09:24:35 2015
New Revision: 127

URL: http://svn.gna.org/viewcvs/zzzt?rev=127&view=rev
Log:
daily stats for a year long link from yearly stats

Modified:
    trunk/stats/daily.php
    trunk/stats/yearly.php

Modified: trunk/stats/daily.php
URL: 
http://svn.gna.org/viewcvs/zzzt/trunk/stats/daily.php?rev=127&r1=126&r2=127&view=diff
==============================================================================
--- trunk/stats/daily.php       (original)
+++ trunk/stats/daily.php       Sun Dec 13 09:24:35 2015
@@ -62,9 +62,17 @@
     document.write("<div id=\"holder\"></div>");
      
     <?php
-      $sql="SELECT date,production FROM zzzt_daily
-           WHERE TO_DAYS( NOW( ) ) - TO_DAYS( date ) < 60      
-           ORDER BY date ASC";
+      $select="SELECT date,production FROM zzzt_daily ";
+      $order=" ORDER BY date ASC";
+      
+      if( isset($_GET['year']) )
+        $where="WHERE YEAR(date)=".substr($_GET['year'],0,4);
+      else
+        $where="WHERE TO_DAYS( NOW( ) ) - TO_DAYS( date ) < 60";
+
+      
+      $sql=$select.$where.$order;
+      
       $db->query($sql);
       while ($row = $db->fetch()) {
        $jour[]=$row['date'];

Modified: trunk/stats/yearly.php
URL: 
http://svn.gna.org/viewcvs/zzzt/trunk/stats/yearly.php?rev=127&r1=126&r2=127&view=diff
==============================================================================
--- trunk/stats/yearly.php      (original)
+++ trunk/stats/yearly.php      Sun Dec 13 09:24:35 2015
@@ -61,18 +61,32 @@
 
   <script type="text/javascript" charset="utf-8">
     document.write("<div id=\"holder\"></div>");
-     
-    new Morris.Area({element: 'holder', lineColors: ['#<?php echo 
$db->rnd_color(); ?>', '#<?php echo $db->rnd_color(); ?>'], 
-      continuousLine: false, fillOpacity: 0.5, postUnits: 'kWh', 
behaveLikeLine: true, parseTime: false, hideHover: 'auto',  data: [
-      <?php
-         $tableau='';
-         foreach($values as $k => $v) {
-           $partiel = str_replace(',','.',$v['partiel'] + 0);//pour la 
première année, on n'a pas tous les jours, et on veut des points en JS
-           $tableau .= "{ a: '$k', 'y': {$v['production']}, 'z': $partiel },";
-         }
-         echo substr($tableau,0,-1);
-      ?>
-      ], xkey: 'a', ykeys: ['y','z'], labels: [ '<?php echo KYR;?>', '<?php 
echo DDY.' '.date('z');?>'] });
+
+    new Morris.Area({element: 'holder',
+                 lineColors: ['#<?php echo $db->rnd_color(); ?>',
+                              '#<?php echo $db->rnd_color(); ?>'], 
+                  hoverCallback: function (index, options, content) {
+                                      var row = options.data[index];
+                                      var urld = '<a href=daily.php?year=' + 
row.a + ">" + row.a + "</a>";
+                                      var label = content.replace(row.a,urld);
+                                      return label ;
+                                    },
+                  continuousLine: false,
+                  fillOpacity: 0.5,
+                  postUnits: 'kWh',
+                  behaveLikeLine: true,
+                  parseTime: false,
+                  hideHover: 'auto',
+                  data: [
+                    <?php
+                        $tableau='';
+                        foreach($values as $k => $v) {
+                          $partiel = str_replace(',','.',$v['partiel'] + 
0);//pour la première année, on n'a pas tous les jours, et on veut des points 
en JS
+                          $tableau .= "{ a: '$k', 'y': {$v['production']}, 
'z': $partiel },";
+                        }
+                        echo substr($tableau,0,-1);
+                    ?>
+                    ], xkey: 'a', ykeys: ['y', 'z'], labels: [ '<?php echo 
KYR;?>', '<?php echo DDY.' '.date('z');?>'] });
 
   </script>
   <noscript><img src='image_by_year.php?width=1000&amp;height=600' alt='<?php 
echo KYR;?>'></noscript>


_______________________________________________
Zzzt-commits mailing list
Zzzt-commits@gna.org
https://mail.gna.org/listinfo/zzzt-commits

Reply via email to