有向图只显示一天,我想每周看一次

时间:2015-03-22 00:42:11

标签: dygraphs

我对dygraph有问题,它只显示1天,但我希望看到7天或14天。

这是我的剧本:

<html>
<head>
<script type="text/javascript" src="dygraph-combined.js"></script>
</head>
<body>
<div id="graphdiv" style="width:750px; height:400px;"></div>
<script type="text/javascript">

  function addZero(num)
  {
    var s=num+"";
    if (s.length < 2) s="0"+s;
    return s;
  }

  function dateFormat(indate)
  {
    var hh = addZero(indate.getHours());
    var MM = addZero(indate.getMinutes());
    //var ss = addZero(indate.getSeconds());
    var dd = addZero(indate.getDate());
    var mm = addZero(indate.getMonth()+1);
    var yyyy = addZero(indate.getFullYear());
    return dd+'.'+mm+'. '+hh+':'+MM;
  }

  g = new Dygraph(
    document.getElementById("graphdiv"),
    "temp.log",
    {
      xValueParser: function(x) {
        var date = new Date(x.replace(
          /^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/,
          '$1/$2/$3 $4:$5:$6'
        ));
        return date.getTime();
      },
      axes: {
        x: {
          ticker: Dygraph.dateTicker,
          axisLabelFormatter: function(x) {
            return dateFormat(new Date(x));
          },
          valueFormatter: function(x) {
            return dateFormat(new Date(x));
          }
        }
      },
      labelsDivWidth: 510,
      rollPeriod: 1,
      strokeWidth: 2.0,
      colors: ['blue', 'orange', 'red'],
      labels: ['Datum','Lufteuchte (%)','Raum-Temp (C)','Pi-Temp (C)']
    }
  );
</script>
</body>
</html>

我的日志文件如下所示:

20150322011501,36.0,24.0,44.4
20150322012001,36.0,24.0,44.9
20150322012501,36.0,24.0,44.4
20150322013001,36.0,24.0,44.4
20150322013501,35.0,24.0,44.4

我不知道如何设置它来显示每周图表数据。

感谢您的帮助 曼努埃尔

0 个答案:

没有答案