【问题标题】:Dygraph AnnotationsDygraph 注释
【发布时间】:2015-01-10 12:45:43
【问题描述】:

我会更新我的注释,我将数据变成 Javascript 字符串。 我从 MYSQL 数据库中读取注释,但我在更新图表期间将新数据作为 javastring 传输。

为什么不运行?

var dat = "[{series: 'AKKU [V]', x: Date.parse('2014/07/06 12:58:12'), shortText: 'A', text: 'Akku geladen'}]";  

graphdiv2.setAnnotations(dat);

这会运行。

graphdiv2.setAnnotations([{series: 'AKKU [V]', x: Date.parse('2014/07/06 12:58:12'), shortText: 'A', text: 'Akku geladen'}]);

可以帮帮我吗?

这运行 althoug,使用 php 字符串,但我不能使用 php 字符串。

graphdiv2.setAnnotations([<?php echo $aaa ?>]);  

【问题讨论】:

    标签: javascript annotations dygraphs


    【解决方案1】:

    我在 mysql 数据库中读取和写入注释。 这是代码。 我的问题在第一个博客中。

    <?php
    

    include("xxx.php"); $aaa = "[ ";

    $annotation_data = mysql_query("SELECT DATE_FORMAT(xval,'%Y/%m/%d %H:%i:%s') AS xval1, xval, series, shortText, text 来自“.$database_anno”。 ORDER BY xval ") or die(mysql_error());

    while($row = mysql_fetch_array($annotation_data)) { $text = str_replace("\r\n", "
    ", $row['text']); // eingebaute Umbrüche ausbessern

    $aaa = " " .$aaa. "{series: '".$row[series]."', x: Date.parse('".$row[xval1]."'), shortText: '".$row[shortText]."', text : '" .$text."'}," ;

    }
    $aaa = "" .$aaa. "]";
    //echo $aaa; 
    

    ?>

    var dataphp = ;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-22
      • 1970-01-01
      • 2011-12-07
      • 1970-01-01
      • 2016-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多