Legend - Tabular Layout

A free public discussion forum for the JFreeChart class library.

Legend - Tabular Layout

Postby jbd007 » Mon May 08, 2006 8:28 pm

I tried searching for a over a day to find a way to do this ... is there anyway to make the items in a Legend be ordered (like a basic HTML table). The legend looks fine when you have 1-6 items but when you get over that and it goes to the next line, you are basically using an (ugly) FlowLayout .....

What I have currently is this:

and I want something like this (yeah it's hand editted so it's not exactly right):

Any help would be greatly appreciated.
Posts: 1
Joined: Mon May 08, 2006 8:18 pm
Location: Phoenix, AZ

Postby david.gilbert » Tue May 09, 2006 10:05 am

There are hooks to enable you to control the layout of the legend items, but as yet no layout manager that can do the table layout for you (it would certainly be a nice addition to JFreeChart). You'll notice that in the LegendTitle constructor, there are two arguments vLayout and hLayout. These are layout managers - one controls the layout of items when the legend is at the left or right of the chart, the other takes control when the legend is at the top or bottom of the chart.

For now, the standard layout is a "flow" layout, and there aren't really any other standard options. I've added a Feature Request for this:

http://sourceforge.net/tracker/index.ph ... tid=365494
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited
JFreeChart Project Leader
Posts: 11337
Joined: Fri Mar 14, 2003 10:29 am

Re: Legend - Tabular Layout

Postby Johannes » Thu Nov 10, 2011 11:48 am

Hi David,

Is this Feature Request still open in the current SVN trunk version (it is in the SF bug tracker at least)? We are a team of students supposed to work on a open source project and have chosen to collaborate on JFreeChart.
If this Feature is not yet implemented, we would like to try to take it up and implement it if it turns out to be of reasonable complexity.
Could you give a hint on where we would hook in for creating such a new LegendRenderer? We sure wouldn't like to break the overall design of JFreeChart by adding it in a unusual way…

What we would think of two ways to offer a tabular layout to the user:
1. offer an integer parameter "columns" and divide available space equally
2. a little more intelligent algorithm trying to find best column widths by looking at the actually widths of the labels contained.

Any comments on that?

Thanks for your time,
Johannes and Ralf
Posts: 2
Joined: Thu Nov 10, 2011 11:31 am

Re: Legend - Tabular Layout

Postby matinh » Mon Nov 14, 2011 9:25 am


Thanks for helping out with this. If the request is still open in the tracker, it's very likely that it still hasn't been implemented.
It would be great, if you could offer a patch for this. However, I currently don't know the code and don't have the time to look at it, so I'm afraid, I can't be of big help for you.
You could also try to jfreechart-developers Mailinglist to get some help.

Implementing the feature via 1. or 2. is up to you. If the user could choose, it would be even better :)

- martin

BTW, two other students also just offered to fix some bug as part of their studies via the dev-mailinglist.
Posts: 467
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: Legend - Tabular Layout

Postby Johannes » Thu Nov 17, 2011 12:06 pm

Thanks for your input, matinh!

We have posted a solution approach on the developers mailing list and hope that this feature will be available soon :).
Posts: 2
Joined: Thu Nov 10, 2011 11:31 am

Return to JFreeChart - General

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 14 guests