questions about what jfreechart can do

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
dandante

questions about what jfreechart can do

Post by dandante » Sat Dec 06, 2003 11:31 am

After struggling with other plotting packages, I am wondering if this is the one for me. It's hard to tell at a glance whether it has the features I want, since I will not buy the developer's guide unless I'm sure I'm going to be using it, and the demo, PDF, and javadoc don't fully answer my questions.

I will be working entirely with XY plot data. Here are the features I want:

-I don't want a scatter plot. Nor do I want a line plot as shown in the demo--I want a line plot with a circle or square at each data point. (I guess that's a combo of line and scatter).

-I don't want zooming. I want to be able to click on individual data points (marked with circle or square as above) and get back an object telling me all the information about what I just clicked on (the original double x,y coordinates, the name of the dataset, etc.). Also, at this point I want to fire a custom event to some client code. (For example, say there is a table showing the data that is plotted. You click on a line in the plot and it selects the corresponding row in the table).

-the tooltip stuff looks cool but I want more than that, I want to to get back an object, as described above, whenever I mouse over a data point (as well as when I click on it).

-can I create a custom legend? I may be plotting many rows of data at once which will cause the default legend to get cluttered. all i need is the list of names for each dataset and their associated colors and i can do this.

In other plotting packages doing these things were so problematic that I thought it would be easier to write my own plotting package. Since I'd rather not do that, I am looking at other packages. Please help and let me know if JFreeChart can help me. Thanks.

kingguppy
Posts: 37
Joined: Mon Apr 07, 2003 9:52 pm
Location: Wuppertal, Germany

Post by kingguppy » Mon Dec 08, 2003 11:08 am

I don't know about the legend (I've never needed to use a legend in my charts), but everything else you've mentioned is possible.

You can set the Shape and Paint for individual data points, which covers your "circle or square" requirement.

There's a "ChartEntity" concept, which maps shapes that have been plotted to the underlying data - that's what you get back with mouse clicks.

I've done some additional work on the ChartEntity stuff which makes it a bit faster and more flexible, and I'll eventually submit a patch for this to David. But what's already there should do what you want.

dandante

thanks

Post by dandante » Mon Dec 08, 2003 12:06 pm

Thanks, I've found what you are saying to be correct.
I've been able to implement almost everything I want, though the big stumbling block is the problem with plotting XY data with non-sequential X values (see my other post).

As for setting the shape for the data points, I can do this, but i find it puts the shapes away from the center of the plot point. Say you have a straight line in your plot, the default plot shapes will be right on top of the line. But say you want the data point shape to be a
new Rectangle(8,8).
In this case the rectangle hangs off the bottom of the line. It does not look nearly is cool. Is there a fix for this?
As for the chart entity stuff, I have it working. But I'm curious, is there any way to pass meta data about a plot point other than in the tooltip text?

Thanks

kingguppy
Posts: 37
Joined: Mon Apr 07, 2003 9:52 pm
Location: Wuppertal, Germany

Post by kingguppy » Mon Dec 08, 2003 12:57 pm

The add() method in the XYSeries class sorts by x position, so you might want to subclass it to override that behaviour.

"XYChartEntity"s give you the dataset, series and item which was selected. So you could store any metadata in your dataset (or in a separate list). Or you could subclass the renderer you're using, and return your own XYChartEntity subclass which contains additional fields.

I don't know anything about the alignment issues with Shapes, since I've never used anything but dots, sorry.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: thanks

Post by david.gilbert » Mon Dec 08, 2003 2:12 pm

dandante wrote:As for setting the shape for the data points, I can do this, but i find it puts the shapes away from the center of the plot point. Say you have a straight line in your plot, the default plot shapes will be right on top of the line. But say you want the data point shape to be a
new Rectangle(8,8 ).
In this case the rectangle hangs off the bottom of the line. It does not look nearly is cool. Is there a fix for this?
JFreeChart assumes that (0, 0) is at the center of your shape, so you should create your rectangle using:

Code: Select all

Rectangle2D r = new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0);
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

dandante

thanks

Post by dandante » Sun Dec 14, 2003 12:24 pm

That works beautifully.

Locked