连接拉斐尔和铁轨

发布于 2024-09-24 11:58:03 字数 238 浏览 7 评论 0原文

这是一个关于 Web 框架的高级问题,作为桌面应用程序开发人员,我对此了解不多。

我计划构建一个 Web 应用程序来可视化存储在数据库中的一些数据。我计划使用 Rails 进行用户查询。对于可视化,Raphael JS 库看起来不错。尝试将 Rails 与这个库连接起来是一项艰巨的任务吗?

欢迎提出这两种替代品的任何建议。

This is a high-level question about web frameworks, that as a desktop app developer, I don't have much knowledge of.

I am planning to build a web application which visualizes some data stored in a database. I plan on using Rails for user query. For visualization, the Raphael JS library looks good. Would it be a considerable task trying to connect Rails with this library?

Any recommendations for substitutes for these 2 are welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

海之角 2024-10-01 11:58:04

应该不会有任何问题,特别是因为 Rails 3 已经明确表示与 JS 库无关。

经过快速粗略的搜索,我看到了这个库,可能值得您考虑。似乎没有做饼图,但在其他方面看起来不错: Flot

该特定库是与 jQuery 集成,jQuery 是一个流行且文档齐全的 JS 库,Rails 3 可以很好地使用它。

There should be no issues especially since Rails 3 has made a point of being JS-library agnostic.

Doing a quick cursory search I saw this library that might merit your consideration. Doesn't appear to do pie charts but otherwise it looks good: Flot

That particular library is made to integrate with jQuery, which is a popular and well-documented JS library that Rails 3 plays very nicely with.

梦亿 2024-10-01 11:58:04

如果您感到懒惰,可以使用 gem ,其中将为您提供相关文件。

If you're feeling lazy, you can use a gem which will include the relevant files for you.

楠木可依 2024-10-01 11:58:04

这很容易。 Raphaël 是一个 javascript 库,因此为了使用它,请将 raphael-min.js 文件放入您的 app/assets/javascript 文件夹中。然后添加此行

app/views/layouts/application.html.erb

<!DOCTYPE html>
<html>
<head>
  <title></title>
  <%= stylesheet_link_tag    "application", :media => "all" %>
  <%= javascript_include_tag "raphael-min" %>
  <%= javascript_include_tag "application" %>
  <%= csrf_meta_tags %>
...

然后,将 javascript 代码写入 app/assets/javascript/application.js 文件。这应该有效。

It is very easy. Raphaël is a javascript library so in order to use it, put the raphael-min.js file in your app/assets/javascript folder. Then add this line

app/views/layouts/application.html.erb

<!DOCTYPE html>
<html>
<head>
  <title></title>
  <%= stylesheet_link_tag    "application", :media => "all" %>
  <%= javascript_include_tag "raphael-min" %>
  <%= javascript_include_tag "application" %>
  <%= csrf_meta_tags %>
...

Then, write your javascript code into the app/assets/javascript/application.js file. This should work.

那片花海 2024-10-01 11:58:03

连接 Rails 和 Raphaël 实际上不需要做太多事情。 Raphaël 是一个 Javascript 库,因此完全在客户端上运行,而 Rails 是一个 Web 应用程序框架,在服务器上运行。要集成它们,您真正需要做的就是在您的页面上包含 Raphaël,并以易于从 Javascript 使用的格式向其提供数据;使用以 JSON 形式提供数据的 RESTful 控制器应该可以让您轻松地使用 XMLHttpRequest 从客户端加载数据,然后您可以使用 Raphaël 显示这些数据。

There isn't really much that needs to be done to connect Rails and Raphaël. Raphaël is a Javascript library, and so runs entirely on the client, and Rails is a web application framework, running on the server. All you really need to do to integrate them are include Raphaël on your page, and provide data to it in a format easy to use from Javascript; using RESTful controllers which provide data in JSON should make it easy for you to load data using XMLHttpRequest from the client, which you can then display using Raphaël.

辞旧 2024-10-01 11:58:03

Ryan Bates 在这个 Railscasts 中谈论图表(包括 Raphael),我很确定这是一个很好的开始观点。

Ryan Bates talk about charts (including Raphael) in this Railscasts, Im pretty sure It's a good starting point.

瀟灑尐姊 2024-10-01 11:58:03

Raphael 是一个独立的 JS 库,你选择的服务器端框架/语言并不重要。不过,您不能只是将一个插入另一个,您必须弄清楚如何以 Raphael 期望的格式为其提供所需的数据。在这方面,Rails 不会比任何其他框架更好或更差。

Raphael is a self-contained JS library, the server-side framework/language you pick is really unimportant. You can't just plug one into the other though, you'll have to figure out how to supply Raphael with the data it needs in the format it expects. Rails will be no better or worse than any other framework at this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文