实时图表 (SVG) + AJAX/Javascript/Jquery +标准输出 +蟒蛇 +我真的不了解自己
我不知道如何准确地描述我的问题,现在我脑子里一团糟,所以请处理它并纠正我,如果我错了,我会确定的。
主要目标:
是构建一个实时折线图,它可以根据来自 stdout 的数据自行更新,无需重新加载网页。所以它基本上必须是Python脚本,它获取每个第二个值,并根据这个值继续在折线图中画线。
1)我现在脑子里的基本标签是:Javascript / AJAX,cgi, python http web 服务器,SVG(矢量图形)。
所以基本上我不明白的最大问题是如何持续将标准输出值传输到网页。我应该编写自己的 python http Web 服务器,以某种方式传递值并使用 javascript 或 ajax + SVG 绘制图表。
或者编写一个 http web 服务器是一个愚蠢的想法,我可以以某种方式让它在没有它的情况下工作?
欢迎任何其他建议,或向我指出一些教程或文章。因为现在我很困惑,尤其是在不断向网页传递值的部分。
提前谢谢。希望你能指出我的地方=)
I am not sure how to accurately describe my problem , and right now i have a total mess in my head , so please deal with it and correct me if i am wrong , and i will be for sure.
MAIN GOAL:
Is to built a real time line chart , which updates itself without web page reloading based on data , which comes from stdout . So it basically must be python script , which gets every second value , and based on this values continues to draw line in a line chart .
1) Well basic tags in my head right now are : Javascript / AJAX , cgi , python http web server , SVG (Vector graphics).
So basically the biggest problem , which i dont understand is how to continuesly transfer stdout values to the webpage . Should i write my own python http web server , somehow pass values and with javascript or ajax + SVG draw the chart .
Or writing a http web server is a stupid idea and i can somehow make it work without it ?
Any other suggestions , or pointing me to some tutorials or arcticles are welcome . Because right now i am very confused , especially on the part of continuesly passing values to webpage.
Thx in advance. Hope you will be able to point me somewhere =)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Highcharts 非常适合静态数据或以最大 1000 毫秒速度更新的数据。尝试将更新速率更改为 100 毫秒 - 看起来很糟糕。
我会推荐Smoothie Charts。非常适合您的场景。
Highcharts are nice for a static data or for data updated at max 1000ms speed. Try changing update rate to 100ms - it looks like crap.
I would recommend Smoothie Charts. Fits perfectly for your scenario.
您想要做的是使用 JavaScript 来呈现图表,例如使用 highcharts 等库。然后,您可以使用 AJAX 向 Web 服务器发出 HTTP 请求以获取数据。
根据您的需要,您可以定期进行这些调用来获取新数据。或者您可以考虑使用更有效的技术,例如 网络套接字、彗星等
What you want to do is use JavaScript to render the chart, for example using a library such as highcharts. Then, you can use AJAX to make an HTTP request back to a web server to get your data.
Depending upon your needs, you could just keep making these calls periodically to get new data. Or you could look into using a more efficient technique such as web sockets, comet, etc.
另请检查 Flot 的实时更新可能性:http://people.iola.dk/olau /flot/examples/
我使用数据库作为缓冲区,因此不需要 Comet 或其他推送技术。
Also check the real-time updates possibilities of Flot: http://people.iola.dk/olau/flot/examples/
I use a database as buffer, so no need for Comet or other push-techniques.
我将使用 JavaScript 创建或操作 SVG 文档,并通过 AJAX 请求轮询服务器并获取数据。
I would use JavaScript to create or manipulate an SVG document, with AJAX requests polling the server and getting data back.