Embedding Dygraphs in html

送分小仙女□ 提交于 2019-12-13 04:22:48

问题


I am plotting some csv data using a java applet embedded in my simple html code. Things run fine when I plot the data without any frill; if I add labels and title I don't see the graphs anymore. What should I change in the html code, reported below?

<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>

For the plotting options, I followed this example.


回答1:


You forgot a comma after the xlabel property. It should be this:

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

As a result, there was a javascript error stopping execution. To debug this yourself, use your browser's web developer tools and look at the console. It will report any javascript errors.



来源:https://stackoverflow.com/questions/20333264/embedding-dygraphs-in-html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!