【问题标题】:Embedding Dygraphs in html在 html 中嵌入 Dygraphs
【发布时间】:2013-12-02 16:38:58
【问题描述】:

我正在使用嵌入在我的简单 html 代码中的 java 小程序绘制一些 csv 数据。当我没有任何装饰地绘制数据时,事情运行良好;如果我添加标签和标题,我就看不到图表了。我应该在下面报告的 html 代码中更改什么?

<html>
    <head>
        <script type="text/javascript"
            src="dygraph-combined.js"></script>
    </head>
    <body>
        <div id="graphdiv"
            style="width:1000px; height:600px;"></div><br>
        <script type="text/javascript">
            g2 = new Dygraph(
                             document.getElementById("graphdiv"),
                             "combined_file.csv", // path to CSV file
                             {  title: 'Title',
                                xlabel: 'Time'
                                ylabel: 'Space',
                                legend: 'always',
                                labelsDivStyles: {'textAlign': 'right'},
                             });
            </script>
    </body>
</html>

对于绘图选项,我遵循this 示例。

【问题讨论】:

    标签: java html dygraphs


    【解决方案1】:

    您忘记了 xlabel 属性后面的逗号。应该是这样的:

    {  title: 'Title',
       xlabel: 'Time',
       ylabel: 'Space',
       legend: 'always',
       labelsDivStyles: {'textAlign': 'right'},
    });
    

    因此,停止执行时出现 javascript 错误。要自己调试,请使用浏览器的 Web 开发人员工具并查看控制台。它将报告任何 javascript 错误。

    【讨论】:

    • 感谢您发现这一点并提供提示!
    猜你喜欢
    • 2023-04-11
    • 2011-07-15
    • 2012-04-30
    • 2018-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多