Can we create drill downs with JFree Charts

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Sudhir
Posts: 3
Joined: Wed Aug 02, 2006 10:09 pm

Can we create drill downs with JFree Charts

Post by Sudhir » Wed Aug 02, 2006 10:11 pm

I'm looking to create charts which will have the capabity to have drill downs. Does anyone know if JFree Charts have that capability ?

-Sudhir

SeanMcCrohan
Posts: 18
Joined: Thu May 11, 2006 11:22 pm

Post by SeanMcCrohan » Wed Aug 02, 2006 10:28 pm

What sort of drill-down did you have in mind? There's a ChartMouseClick event that you can use to catch clicks on a chart entity, for instance.

Sudhir
Posts: 3
Joined: Wed Aug 02, 2006 10:09 pm

Post by Sudhir » Wed Aug 02, 2006 11:16 pm

I'm planning to have a pie-chart and clicking on any area within the pie-chart should take me to a report page(different parameters to be passed in the URL based on which part of chart the user click's..)

SeanMcCrohan
Posts: 18
Joined: Thu May 11, 2006 11:22 pm

Post by SeanMcCrohan » Thu Aug 03, 2006 2:03 pm

Ah. Then yes, you ought to be able to handle that in JFreeChart. Getting the URL text from a clicked-on chart entity is pretty straightforward.

Sudhir
Posts: 3
Joined: Wed Aug 02, 2006 10:09 pm

Post by Sudhir » Thu Aug 03, 2006 5:19 pm

Can you please give me some tips/hints as to how we could implement that.

SeanMcCrohan
Posts: 18
Joined: Thu May 11, 2006 11:22 pm

Post by SeanMcCrohan » Thu Aug 03, 2006 5:32 pm

Only on the Java side; I haven't done anything with JFreeChart as an applet. Set up a ChartMouseListener, register it with your chart, and then get the URL from the clicked chart entity with something like:

Code: Select all

	public void chartMouseClicked(ChartMouseEvent event) {
		System.out.println(event.getEntity().getURLText());
	}

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

Post by david.gilbert » Thu Aug 03, 2006 5:34 pm

If you are doing this in a client application, you need to add a ChartMouseListener to the ChartPanel, then check the events to see what has been clicked on.

If, on the other hand, you are working on a web application, you need to create an HTML image map for your chart image. There is an ImageMapUtilities class to help with that...explaining how it works will take more time than I have right now. You can customise the URLs in the image map by setting URL generators in the plot or renderer classes.
David Gilbert
JFreeChart Project Leader

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

Locked