在 Ruby on Rails 中显示可视化数据 [英] Showing visual Data in Ruby on Rails

查看:102
本文介绍了在 Ruby on Rails 中显示可视化数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的屏幕截图,从某个数据库读取数据 - 我想我可以通过我正在关注的一些 RubyOnRails 教程从数据库中读取数据 - 但是我应该如何能够以它们的漂亮形状表示该数据想要下面这张图吗?

Screen shot below, reads data from some database - I think I can get my head around reading data from DB with some RubyOnRails tutorial I am following - but then how should I be able to represent that data in a pretty shape that they want like this picture below?

我应该很快熟悉哪些工具、框架等,以便能够像这样表示数据?

What tools, frameworks, etc. should I get myself familiar with very quick to be able to represent the data like this?

因为我应该专注于 Rails,如果您的建议也能与 Rails 很好地集成,那就太好了...

Since I am should focus on Rails, it would be great if what you suggest is in something that integrate well with Rails too...

屏幕截图2:对于这个,我认为"不知何故我可以使用谷歌图表",但还是很高兴能得到你的建议.

Screen shot2: for this one I "think" somehow I can use "Google Charts" but still good to have your suggestions too.

推荐答案

要制作图表,您可以使用 javascript.那里有很多图书馆.

To make charts you use javascript. There is a lot of libraries out there.

第一张图片中的那些小图表称为闪光线.它们可以用这个 jquery 插件制作

Those small charts in the first picture are called sparklelines. They can be made with this jquery plugin

jQuery 迷你图

还有这个纯 javascript 工具

And this pure javascript tool

sparklines.js

对于其他图表,我认为最好的免费图表是 d3 库,特别是 nvd3 库女巫建立在 d3 库之上.

For other charts I think the best free one is the d3 library and spesially the nvd3 library witch is built on top of the d3 library.

Raphaël—JavaScript 库 也有一些解决方案.一种是 gRaphaël.我个人不喜欢这个,但可以看看.

There are also some solutions with the Raphaël—JavaScript Library. One is gRaphaël. I personally do not like this one, but have a look.

图表库通常使用 SVG(可缩放矢量图形.转到这里a> 了解 SVG 和 CSS )以显示图表.然后您通过 JSON 从 Rails 中获取数据.

Charting libraries often use SVG's (Scalable Vector Graphics. Go here to learn about SVG and CSS ) to display the charts. And you feed the data from Rails trough JSON.

Rails 可以从控制器渲染 JSON,你可以使用 jbuilder "Jbuilder 给你一个用于声明 JSON 结构的简单 DSL,它胜过按摩巨型哈希结构."

Rails can render JSON from the controllers and you can use jbuilder "Jbuilder gives you a simple DSL for declaring JSON structures that beats massaging giant hash structures."

我通常会在 lib 目录中生成一个自定义类,因为制图通常需要大量复杂的查询和处理数据库中的数据,然后才能将其发送到图表.

I usually end up with a custom class in the lib directory, because charting usually requires a lot of complex queries and handling of data from the database before you can send it to the chart.

您应该会看到这些轨道广播.railscasts#223 railscasts#223revised

You should see these railscasts. railscasts#223 railscasts#223revised

第一个使用 highcharts(非免费),最后一个使用 morris.js.莫里斯相当简单,但在某些追逐中就足够了.最后一个是最好的,但我想你必须订阅才能看到它.

The first uses highcharts (Not free) and the last use morris.js. Morris is rather simple, but in some chases sufficient. The last one is the best, but I guess you have to get a subscription to see it.

这里有很多东西要学,很有趣!

There is a lot to learn here, and that is fun!

这篇关于在 Ruby on Rails 中显示可视化数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆