图表平台

发布于 2024-07-23 09:48:37 字数 1539 浏览 3 评论 0原文

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

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

发布评论

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

评论(4

奶气 2024-07-30 09:48:38

JFreeChart 是一个免费且可扩展的解决方案。

http://www.jfree.org/jfreechart/

JFreeChart is a free and scalable solution.

http://www.jfree.org/jfreechart/

鸵鸟症 2024-07-30 09:48:38
  1. 使用 JSON 将数据提供给浏览器(您可能需要这样做)以更新客户端的信息;
  2. 使用 Raphaël 绘制数据

这应该会给您带来更高的吞吐量,因为图形是在客户端和平台内重新生成的为绘画而生。

以下是您可以实现的几个示例:

图表 http://img140.imageshack .us/img140/5143/rapahelchart.png
图表 http://img269.imageshack.us/img269/6679/raphaelgraph.png

  1. Feed the data to the browser using JSON - as you probably need to - for updating the information on the client-side;
  2. Draw the data using Raphaël

This should give you much higher throughput, since graphs are regenerated client-side, and within a platform made for drawing.

Here are a couple of samples of what you can achieve:

chart http://img140.imageshack.us/img140/5143/rapahelchart.png
graph http://img269.imageshack.us/img269/6679/raphaelgraph.png

何处潇湘 2024-07-30 09:48:38

由于图表可以在浏览器上查看,因此您可以使用 gnuplot 之类的工具来生成数据的图像文件并显示这些文件。 Gnuplot 非常灵活,您几乎可以创建任何东西,而且速度相当快。 但是您必须自己读取数据并将其输入到 gnuplot 中。 如果您想坚持使用 Java,gnuplot 有一些 Java 接口。 将刷新标头设置为合理的数量并观察数据更新。

有关 gnuplot 的信息,请参见此处:http://www.gnuplot.info

请参见此处,了解 java 接口:http://www.gnuplot.info/links.html

Since the charts are going to be viewable on a browser, you could use something like gnuplot to generate image files of your data and display those. Gnuplot is really flexible, you can create pretty much anything, and it is quite fast. But you're going to have to read the data and feed it into gnuplot yourself. There are some Java interfaces to gnuplot in case you want to stick to Java. The set the refresh header to come reasonable amount and watch your data update.

See here about gnuplot: http://www.gnuplot.info

See here about the java interfaces: http://www.gnuplot.info/links.html

樱花落人离去 2024-07-30 09:48:38

我曾经必须显示 150 台机器和 100.000 个任务的甘特图。 我编写了一个带有自定义渲染的自定义 Java 小程序,数据传输由 http + java 序列化 api 处理。 我发现任何其他解决方案(SVG、VML、Flash、图像标签)都太慢且难以操作。

更新这里是它的外观图像。 对于社区来说不幸的是,这是一个工业项目,因此源代码不公开。 我只能分享一些关于它的概念。

图表区域由几个不同的组件组成:水平和垂直滚动条、图表区域、时间标签以及两侧的两个表格。 这些组件通过事件处理程序链接在一起。 如果其中一个正在滚动/更改,则会影响其他人。 甘特图由填充的矩形组成,其中颜色用于指示任务的状态。 渲染是在 Paint() 方法中通过循环遍历每个可见行以及可显示的开始结束日期之间来完成的。 渲染使用积极的裁剪,而不是依赖 Graphics2D 的裁剪功能。 用户能够平移和缩放视图。

数据存储在可序列化的数据结构中。 服务器端Java代码包含整个数据结构的缓存。 该结构每 30 秒刷新一次,但仅从支持数据库检索差异。 然后数据由小程序查询,组成甘特图模型,序列化并返回到客户端。 客户端/小程序端的数据刷新不是自动的:用户需要单击刷新按钮 - 这允许他们评估图片而不会发生意外的更改。

渲染甘特图不需要那么多花哨的东西 - fillRect、AlphaComposite、drawLine。 如果您需要更复杂的图像,您将需要使用我的方法进行更多编码。

I once had to display a gantt diagram of 150 machines and 100.000 tasks. I wrote a custom Java applet with custom rendering and the data transfer was handled by http + java serialization api. I found that any other solution (SVG, VML, Flash, image tags) was simply too slow and hard to operate.

Update: Here is an image how it looks like. Unfortunately for the community, this was an industrial project, therefore, the source code is not public. I can only share some concepts about it.

The diagram area consists several distinct components: horizontal and vertical scrollbars, the diagram area, the time label and the two tables on each side. These components are linked together via event handlers. If one is scrolling/changing it affects the others. The gantt diagram consists of filled rectangles where the color is used to indicate status of the task. The rendering is done in the paint() method by looping through each visible line and between the displayable start-end dates. The rendering uses aggressive clipping instead of relying the Graphics2D's clipping feature. The users have the ability to pan and zoom the view.

The data is stored in a serializable data structure. The server side Java code contains a cache for the entire data structure. This structure gets refreshed on every 30 seconds but only the differences are retrieved from the backing database. The data then gets queried by the applet, composed into the gantt model, serialized and returned to the client side. The data refresh on the client/applet side is not automatic: users need to click on the refresh button - this allows them to evaluate the picture without unexpected changes.

Rendering a Gantt diagram does not need that many fancyness - fillRect, AlphaComposite, drawLine. If you need more complex images you will need to do more coding with my approach.

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