The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Decent charting software for Java

I'm looking for some decent free or non-free charting tools for Java desktop apps. It doesn't have to be massive (I just need line charts right now).

I've looked into jfreechart but it mystifyingly doesn't show x values in proportion. Thus, if you have Dec 1, Dec 2, Dec 3, and Dec 25th on the x axis, they are shown equidistantly. Dumb. And a lot of tools seem to do the same thing.

Any thoughts?
thanks, but anon
Thursday, August 21, 2008
Off-hand, this sounds like something that might need to be handled by the application. What does your data look like?

Since this is a line chart, what do you want to happen for the columns that are missing values? IE: Dec. 4 ?

Why not just supply a list of values that includes all values between the x min and x max (IE: all dates between Dec 1 and Dec 25) ?
Joe Lynds Send private email
Thursday, August 21, 2008
In my experience there is a total lack of good (open-source) charting libraries for Java, even more so if you want real-time rendering (JFreeChart fails miserably on this point).

I would love to see a new player enter this field.
Gili Send private email
Thursday, August 21, 2008
Use a time series dataset in JFreeChart and you'll achieve what you describe.

JFreeChart is powerful and has good demos with source code.  However getting the hang of using is takes a while. Finding a demo that does what you want, then poring over its source code is usually the easiest way to progress.

TimeSeries series = ...
TimeSeriesCollection dataset = new TimeSeriesCollection(series);
JFreeChart chart = ChartFactory.createTimeSeriesChart(
Steve McLeod Send private email
Thursday, August 21, 2008
I've heard that JFreeChart and Google Chart are both pretty good, but I haven't used either.
Benjamin Manes Send private email
Thursday, August 21, 2008
I'm looking for the same thing.  flot (uses jQuery I guess) looks promising:

Let us know if you find something better
Friday, August 22, 2008
If there's a JFreeChart, maybe there's a JChart?


Ahh, what do you know:

The samples look pretty as well....

John Send private email
Friday, August 22, 2008
>>I've looked into jfreechart but it mystifyingly doesn't show x values in proportion.

Sounds like your trying to do it with a CategoryDataset and a CategoryAxis and CategoryPlot. Those are intended for data that is classed into discrete categories.

What you have is more like observations from a continuous domain for which a ValueAxis is more appropriate. These are used with an XYPlot with values coming from an XYDataset.

The XYDataset interface exposes X and Y values as doubles however there is a DateAxis class that subclasses ValueAxis and formats them as dates (internally casting the double to a long and treating that as a milliseconds past epoch value).

Here is your example using an XYPlot:

    double data[][] = new double[][] {
      { parse("2008-12-01"), parse("2008-12-02"), parse("2008-12-03"), parse("2008-12-25") },
      { 169, 172, 174, 201 },    };
    DefaultXYDataset dataset = new DefaultXYDataset();
    dataset.addSeries("WTI", data);
    DateAxis xAxis = new DateAxis("Posted Date");
    xAxis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd"));
    xAxis.setRange( new Range( parse("2008-11-20"), parse("2008-12-31") ) );
    NumberAxis yAxis = new NumberAxis("USD");
    yAxis.setRange( new Range(110,210) );
    XYPlot plot = new XYPlot( dataset, xAxis, yAxis, new XYLineAndShapeRenderer() );
    JFreeChart chart = new JFreeChart("Prices",plot);

Saturday, August 23, 2008

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz