A discussion forum for JFreeChart (a 2D chart library for the Java platform).
-
civi
- Posts: 7
- Joined: Sun Feb 17, 2008 6:07 pm
Post
by civi » Sun Feb 17, 2008 7:23 pm
I´m working on line chart graph using jfreechart in applet.
The graph is operationg accordly but I need capture an event using mouseclicked.
I need help to developer the following feature:
When click on line graph to identify the respective line (Object XYSeries) and to start an event.
Code: Select all
chart.addMouseListener(new MouseAdapter() {
public void mouseClicked(final MouseEvent e){
// i need to get XYSerie object if the click is on line exactly
}
}
-
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 » Sun Feb 17, 2008 10:06 pm
Add a ChartMouseListener to the ChartPanel.
-
civi
- Posts: 7
- Joined: Sun Feb 17, 2008 6:07 pm
Post
by civi » Sun Feb 17, 2008 10:51 pm
I already added the MouseLister in ChartPanel.
I already can get the cordanate point (x,y) on mouseclick event.
But, now, I need to check if this point is on some specific line (XYSeries Object) on the chartpanel then get and recognize this line (XYSeries).
Thanks
-
skunk
- Posts: 1087
- Joined: Thu Jun 02, 2005 10:14 pm
- Location: Brisbane, Australia
Post
by skunk » Sun Feb 17, 2008 11:46 pm
Read david's post again slowly. Hint. A MouseListener is not the same as a ChartMouseListener.
-
civi
- Posts: 7
- Joined: Sun Feb 17, 2008 6:07 pm
Post
by civi » Mon Feb 18, 2008 1:58 am
Ok, sorry.
but when i implement this method:
Code: Select all
void chartMouseClicked(ChartMouseEvent event);
of interface ChartMouseListener, is have any method of ChartMouseEvent that can I recognize this specific Object XYSerie in CharPanel ?
I need to get this object when mouse click event, but just if the point (x,y) coordinate is exactly on linechart in ChartPanel.
Best regards
-
civi
- Posts: 7
- Joined: Sun Feb 17, 2008 6:07 pm
Post
by civi » Mon Feb 18, 2008 2:12 am
ChartMouseEvent:
JFreeChart getChart()
Returns the chart that the mouse event relates to.
ChartEntity getEntity()
Returns the chart entity (if any) under the mouse point.
java.awt.event.MouseEvent getTrigger()
Returns the mouse event that triggered this event.
I need to any method for example:
getXYSeries()...
I can check this point (x,y) of mouseclick is on a linechart of charpanel, and what linechart of charpanel is it.
-
anamika21
- Posts: 13
- Joined: Mon Feb 25, 2008 3:20 pm
Post
by anamika21 » Mon Feb 25, 2008 5:11 pm
Hello civi,
could u plz tell me how did u add ChartMouseListener() on Chart Panel()