javascript 使用 csv 中的数据在 html 中创建图形

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11753791/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 14:13:13  来源:igfitidea点击:

create a graph in html using data in csv

javajavascripthtmlgraph

提问by Praveen

I need to show a graph(piegraph and XYgraph) in HTML file. I have used some free tool created an image and I am trying to show this on HTML.

我需要在 HTML 文件中显示图形(饼图和 XYgraph)。我使用了一些免费工具创建了一个图像,我试图在 HTML 上显示它。

But, we need to place this image in shared folder or in a server to get accessed by HTML.Our client is not satisfied with both approaches.

但是,我们需要将此图像放在共享文件夹或服务器中才能被 HTML 访问。我们的客户对这两种方法都不满意。

Can some please let me know whether there is any way where I can pass data directly to html file. The data will be in csv file and it may contain some thousands of rows.

可以请让我知道是否有任何方法可以将数据直接传递给 html 文件。数据将在 csv 文件中,它可能包含数千行。

Thanks,

谢谢,

回答by Wouter Lievens

There is a Javascript framework that renders really pretty charts: http://www.highcharts.com/

有一个 Javascript 框架可以呈现非常漂亮的图表:http: //www.highcharts.com/

You can use one of many CSV Javascript parsers: Javascript code to parse CSV data

您可以使用许多 CSV Javascript 解析器之一:Javascript code to parse CSV data

If you then write some javascript code to extract your CSV data, and pass it to highcharts, you've got a very nice interactive chart.

如果您然后编写一些 javascript 代码来提取您的 CSV 数据,并将其传递给 highcharts,您就会得到一个非常好的交互式图表。

The alternative, if you want to use your existing images, is to encode the images as base64 directly in the html file: http://webcodertools.com/imagetobase64converter/

如果您想使用现有图像,另一种方法是直接在 html 文件中将图像编码为 base64:http: //webcodertools.com/imagetobase64converter/

回答by Rainer.R

As an alternative you can also look at the Dojo Toolkit (http://dojotoolkit.org/), its a Javascript toolkit with some really nice features including charting.

作为替代方案,您还可以查看 Dojo Toolkit (http://dojotoolkit.org/),它是一个 Javascript 工具包,具有一些非常好的功能,包括图表。