Wednesday, September 01, 2010

Simple Java strip charts

I've been looking for a very simple Java strip chart for a while, and haven't found one. So in the end I decided to put together something myself, the end result being JStripChart.

(There's already something else out there called jstripchart. Just to confuse you, it's a python implementation.)

Using JKstat to knock something together I came up with this:

Of course, you partly miss the point which is that this thing is merrily scrolling away.

I expect to be able to use this fairly extensively in both JKstat and SolView, but it's certainly not tied to those in any way - it's designed to be trivially simple to use in any context.

The API really is very simple. Just create a chart:

JStripChart jsc = new JStripChart();

which you can add to your application in the normal way as it's just a JPanel, and then

jsc.add(some_data);

will add the value some_data to the right of the chart and move everything else along. That's it. (To get it to continuously update, create a Timer loop.)

No comments: