29

There was an earlier thread on Java graph or chart library, where JFreeChart was found to be quite good, but, as stated in its FAQ, it's not meant for real-time rendering.

Can anyone recommend a comparable library that supports real-time rendering? Just some basic xy-rendering - for instance, getting a voltage signal from data acquisition system and plotting it as it comes (time on x-axis, voltage on y-axis).

Community
  • 1
  • 1
Joonas Pulakka
  • 36,252
  • 29
  • 106
  • 169
  • do you mean real-time or "amortized" real-time? (the latter being something that is responsive enough to look real-time to a human being, but no guarantees that occasionally it may slow down. If I need a hard real-time guarantee on something, it is usually related to propagation delay limits, and not very often related to human factors.) – Jason S May 13 '09 at 18:30
  • I mean the latter - it's certainly enough that it looks real-time. This probably means something like 10 redraws / second. – Joonas Pulakka May 14 '09 at 06:39

12 Answers12

9

What the FAQ actually says is that JFreeChart doesn't support hard real-time charting, meaning that the chart isn't updated when new data arrives or at deterministic interval after it. However I have found that JFreeChart can be used for the kind of applications you are describing. You can achieve 1 update per second, which is fine. I don't think a human eye can follow something quicker than this.

If you want something more than this, I doubt you will find anything in Java (or even in another language). Operating Systems that we use aren't designed to be real time. You can't have a guaranty that they will respond in a minimum interval after an event. A tight integration with the hardware driver will be needed to show more than 1-10 frames per second.

However, if you design your application correctly, the OS will do respond quickly and your application can easily display a "real-time" graph (meaning a graph that updates once a second). Just don't use your application to shut down a valve in an emergency situation!

kgiannakakis
  • 103,016
  • 27
  • 158
  • 194
  • 3
    Well, we're on a kind of boundary here. 1/s is certainly jerky for the eye if the data is changing much faster. 10/s would be fine, but JFreeChart can't probably do it. – Joonas Pulakka Feb 17 '09 at 08:46
  • Well if you calculate the data, then you could do 10 f/s in Java. I believe however that there is no way to do that if the data come from a data acquisition device. In that case you would need to communicate with the driver directly; this would be a much more difficult problem to solve. – kgiannakakis Feb 17 '09 at 14:16
  • +1 I've used JFreeChart for a real-time graph of stock prices. – Michael Myers Feb 17 '09 at 15:09
  • 1
    @kgiannakakis: ?! do you mean 10f/s as in 10 complete frames, or 10 incremental updates per second? I'm looking for a strip chart recorder, 1 updates/second is way too slow. Besides, there are a lot of data acquisition hardware modules that are pretty speedy, 10Ksamples/second is nothing. (whether any of them will work with Java is another story.... :( argh) – Jason S May 13 '09 at 18:20
  • I mean 10 updates per second. Each update will cover more than one frame. You'll never know if it is tolerable until you do some real tests. – kgiannakakis May 13 '09 at 21:49
  • 12
    Sorry, but I couldn't agree less... If that were true, than how would we get those games with near-realistic graphics? We can create virtual worlds, but can't guarantee a decent update rate for... Chart? – Rekin Jan 15 '11 at 21:16
  • 7
    For anyone still looking at this, I'm currently using JFreeChart to generate a "real-time" graph, with up to 100 updates per second (each adding and removing a single datapoint, basically shifting the complete set). I'm not saying that it's actually doing each frame at exactly 10 ms, but it doesn't lag behind the data, and it looks real-time enough for my purpose. – sonicwave Aug 16 '12 at 08:55
7

http://www.live-graph.org/

Jacek Ławrynowicz
  • 2,670
  • 2
  • 23
  • 23
6

Just stumbled upon a description on how to use the visualvm charting library. Looks very nice!

weberste
  • 1,884
  • 2
  • 17
  • 12
  • 1
    Yes! This is pretty much exactly what I was originally looking for, although I found that JFreeChart was sufficient for my case. – Joonas Pulakka Nov 24 '10 at 07:23
5

You probably have already found a good solution, but if not, I have recently done some work on a framework for producing 2D charts allowing for live updates at a rate of over 50 changes per second.

The original intention was to mimic the appearance of a chart recorder in a scrolling region of a web page, but I believe the approach has wider application.

A demo can be found at Chart Recorder Demo if anyone is interested.

The appearance is defined by a template (www.journeylog.co.uk/chart/templates/chartRecorder.xml). One feature is the ability to specify drawing either on the server or in the browser using ExplorerCanvas.

If anyone is interested I could start an open source project for it.

  • Yes, I found that JFreeChart wass "real time enough" in my case. Anyway, your demo looks quite impressive! Open sourcing it would definitely be appreciated :-) – Joonas Pulakka Dec 09 '09 at 05:46
  • Very nice. I'm looking for a Java graph for Android and your solution may be adaptable... Hmmmm – Brad Hein Jul 01 '10 at 14:43
5

have a look at processing -- it's an open-source, java-based environment designed for all sorts of animated visualizations.

Rahel Lüthy
  • 6,837
  • 3
  • 36
  • 51
  • 1
    Are you sure its not itself a programming language, which perhaps influenced by Java? http://en.wikipedia.org/wiki/Processing_(programming_language) – Adeel Ansari Feb 17 '09 at 08:55
  • you're correct. but: "[...] is written in Java. Programs written in Processing are also translated to Java and then run as Java programs. Programs written in Java and Processing [...]" (from http://www.processing.org/reference/compare/java.html) so it will integrate with existing java models & libs. – Rahel Lüthy Feb 17 '09 at 11:08
  • this tutorial (http://www.processing.org/learning/tutorials/eclipse) explains how to integrate the processing libraries into an existing java project -- it's focused on eclipse, but conceptually this will work with any other java IDE... – Rahel Lüthy Feb 17 '09 at 13:35
  • The conciseness of syntax looks somewhat similar to Groovy. Thanks for clarification. – Adeel Ansari Feb 23 '09 at 03:54
5

Well, if it has to be Java, then you might want to look into these.

Adeel Ansari
  • 39,541
  • 12
  • 93
  • 133
4

Fast enough for real time is swtchart, at least in my experience. Even with lots of data. Don't be scared away by the version number, yes it is a rather new API, but I use it successfully without problems.

As the name implies, it is based on SWT, which uses native OS drawing. Also it does some clever optimizations for drawing fast, like not drawing all points in the dataset (see Large Series Example Snippet).

the.duckman
  • 6,376
  • 3
  • 23
  • 21
2

JCCkit is vary good library who are targetting less memory especially in embedded environment : https://sourceforge.net/projects/jcckit .

Takes less than <100 kb .

CJ_world
  • 45
  • 10
2

this seems like a good candidate.

http://jchart2d.sourceforge.net/

demo:

http://jchart2d.sourceforge.net/applet.shtml

jobobo
  • 389
  • 5
  • 17
1

SWT XYGraph can plot data with your own data provider, so you can create a real time data provider providing live data. With SWTChart and JFreeChart, you have to prepare the whole array for it.

xihui
  • 123
  • 1
  • 7
1

You could dig around the source for NetBeans. The profiler does real time graphing of various things such as memory usage.

TofuBeer
  • 60,850
  • 18
  • 118
  • 163
0

This question has been answered well in: Java Real time graph plotting

As VisualVM includes a Charting API, and this API is included in the JDK, you have a good/fast charting API available.

Community
  • 1
  • 1
java4africa
  • 214
  • 1
  • 3