Plot by hand on scatter plot

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
yannJFreeChart
Posts: 13
Joined: Tue May 15, 2012 2:17 pm
antibot: No, of course not.

Plot by hand on scatter plot

Post by yannJFreeChart » Tue May 22, 2012 7:51 am

Hello,

I'am a french student, so I'm sorry for my English.

I have a serie of point that I plot on a scatter JFreechart.
I would like to draw points by hand when I click on the graph and get back their coordinates.

Is it possible and how to do that ?

Thank you.
Have a good day.

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

Re: Plot by hand on scatter plot

Post by matinh » Tue May 22, 2012 10:43 am

Hi!

Drawing on charts is not directly supported by JFreeChart. However, Searching the forum got me to this post which might help you.
If this is not what you need, try searching for the ChartMouseListener interface.

hth,
- martin

yannJFreeChart
Posts: 13
Joined: Tue May 15, 2012 2:17 pm
antibot: No, of course not.

Re: Plot by hand on scatter plot

Post by yannJFreeChart » Tue May 22, 2012 11:36 am

Thank you for your reply.

In fact, I don't have to draw point when I click on the graph but I want to get back the coordinate of the mouse.

I try with

Code: Select all

frame1.addMouseListener(this);
With this I can have the coordinates all over the frame when I click with the mouse exept when the mouse is on the graph.

So, I try with :

Code: Select all

chart1.addChartMouseListener(this);
but this method is undefinied for JFreeChart.

Do you know how to do ?

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

Re: Plot by hand on scatter plot

Post by matinh » Tue May 22, 2012 12:24 pm

Something like this:

Code: Select all

ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.addChartMouseListener(this);
- martin

yannJFreeChart
Posts: 13
Joined: Tue May 15, 2012 2:17 pm
antibot: No, of course not.

Re: Plot by hand on scatter plot

Post by yannJFreeChart » Tue May 22, 2012 1:04 pm

Thank you, you're right.
That works.

Locked