admin管理员组文章数量:1414949
I am trying to use dygraph for javascript.
<html>
<head>
<script type="text/javascript"
src="dygraph-bined.js"></script>
</head>
<body>
<div id="graphdiv2"
style="width:500px; height:300px;"></div>
<script type="text/javascript">
g2 = new Dygraph(
document.getElementById("graphdiv2"),
"C:/temperatures.csv", // path to CSV file ***This file is local file in my C: drive***
{} // options
);
</script>
</body>
temperatures.csv is a local file on my machine. I read couple of posts that state .csv file has to be on a remote machine. I wonder is there a way to read local .csv file. Can you suggest some solution to this please. Thanks.
I am trying to use dygraph for javascript.
<html>
<head>
<script type="text/javascript"
src="dygraph-bined.js"></script>
</head>
<body>
<div id="graphdiv2"
style="width:500px; height:300px;"></div>
<script type="text/javascript">
g2 = new Dygraph(
document.getElementById("graphdiv2"),
"C:/temperatures.csv", // path to CSV file ***This file is local file in my C: drive***
{} // options
);
</script>
</body>
temperatures.csv is a local file on my machine. I read couple of posts that state .csv file has to be on a remote machine. I wonder is there a way to read local .csv file. Can you suggest some solution to this please. Thanks.
Share Improve this question edited Dec 19, 2011 at 0:32 user1079655 asked Dec 18, 2011 at 22:59 user1079655user1079655 1071 gold badge2 silver badges7 bronze badges2 Answers
Reset to default 4In general, you cannot load local files via JavaScript. This would be a huge security hole.
If you want to enable this for local development, you can run Chrome with the --allow-file-access-from-files
mand-line flag. I assume other browsers have similar options. You may also need to add a "file://" before the "c:\" in your path.
Alternatively, consider spinning up a lightweight HTTP server for local development. Common choices are Python's http.server
(run python -m http.server
) or the http-server node module.
This works fine for me on Firefox with the CSV file in the same directory as the HTML file. Then just open the HTML file locally as a file://whatever and pass "input.csv" to dygraphs.
No turning off of security options needed - but I don't know about Chrome.
本文标签: javascriptlocal csv file using dygraph libraryStack Overflow
版权声明:本文标题:javascript - local .csv file using dygraph library - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745156532a2645206.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论