Graph:Mouse over interest point

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
schumy
Posts: 5
Joined: Fri Jul 06, 2012 1:29 pm
antibot: No, of course not.

Graph:Mouse over interest point

Post by schumy » Fri Jul 06, 2012 2:03 pm

Hello,
This is my first post. :P
I'm working in a program (java Language) to manage a football championship.
In particular at the relative part of graph (JFreeChart with XYSplineRenderer graph), to calculate the points in a league, match by match

In the image in attachment we have a graph of three teams.
http://img853.imageshack.us/img853/7066/imgfo.png
http://imageshack.us/photo/my-images/853/imgfo.png/

I need to see some information when the mouse is over the intersection points, I don't know an Annotation or a ToolTip,
in short some object to see these information. :cry:
Obviously these information are already stored and ready to be used.

Thank you very much for your support,
Goodbye

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: Graph:Mouse over interest point

Post by matinh » Mon Jul 09, 2012 8:09 am

Try to search this forum for TooltipGenerator and see what you can do.

- martin

schumy
Posts: 5
Joined: Fri Jul 06, 2012 1:29 pm
antibot: No, of course not.

Re: Graph:Mouse over interest point

Post by schumy » Tue Jul 10, 2012 4:05 pm

ah thank you,

I know find me too, without write in the forum.
I want to know if you have some additional informations.

Thanks

schumy
Posts: 5
Joined: Fri Jul 06, 2012 1:29 pm
antibot: No, of course not.

Re: Graph:Mouse over interest point

Post by schumy » Fri Jul 13, 2012 3:59 pm

Finally.............
after a billion of tests I solve my problem.
Post my solution for other users.

First need create XYPlot and XYLineAndShapeRenderer (or XYSplineRenderer)

Code: Select all


    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer();
    .....
    xylineandshaperenderer.setBaseToolTipGenerator((XYToolTipGenerator)new ItemGenerator());
then create ItemGenerator class (or other name), it implements XYToolTipGenerator

Code: Select all

import org.jfree.chart.labels.XYToolTipGenerator;
import org.jfree.data.xy.XYDataset;

public class ItemGenerator implements XYToolTipGenerator {
	public ItemGenerator(){
	}

	@Override
	public String generateToolTip(XYDataset dataset, int series, int category) {
		String giornata_sq = null;	
		String punti_sq = null;	
		
		//Number value = dataset.getValue(series, category);
		Number value = (int)dataset.getXValue(series, category);
		Number value1 = (int)dataset.getYValue(series, category);
		
		if (value != null && value1!=null) {			  
			giornata_sq = value.toString();		  
			punti_sq = value1.toString();		 
		}
		return giornata_sq+"° giornata, " + punti_sq+" punti";
	}
}
Thanks to admin, with a little example I would have solved my problem quickly.

Bye.

Locked