How to read the index of a vertical range axis

A free public discussion forum for the JFreeChart class library.

How to read the index of a vertical range axis

Postby amaranath578 » Mon Jul 26, 2010 9:38 pm

Hello,

I have an XYPlot that has one domain axis and 2 vertical range axes. We enabled a functionality that would allow the users to drag range and domain axes.

Issue: Now I have a problem in reading the index of range axis when a plot has multiple range axes configured.

Available Information: I have XYPlot and the point at which the mouse is clicked.

Please let me know how do I know which range axis is selected, index of the selected range axis.

Thanks.
amaranath578
 
Posts: 2
Joined: Mon Jul 26, 2010 4:58 pm

Re: How to read the index of a vertical range axis

Postby paradoxoff » Sat Jul 31, 2010 9:49 am

if you are using a ChartPanel, you can attach a ChartMouseListener to the ChartPanel and listen for chartMouseClicked events.
From the ChartMouseEvent, you can extract the JFreeChart, and from the JfreeChart, you can get a reference to the plot.
Additionally, you can extract the entity from the ChartMouseEvent and check whether it is an instance of AxisEntity.
If the plot is an instance of XYPlot and if the axis if the AxisEntity is an instance of ValueAxis, you can get through the domain and range axes of the XYPlot (XYPlot.getDomainAxisCount() and XYPlot.getRangeAxisCount()) and check whether the returned axis for a given index is the same as the axis of entity. Then you found the index, and then you also know whether the axis of the entity is a range or domain axis.
paradoxoff
 
Posts: 826
Joined: Sat Feb 17, 2007 1:51 pm

Re: How to read the index of a vertical range axis

Postby amaranath578 » Tue Aug 03, 2010 7:39 pm

Thank You.
amaranath578
 
Posts: 2
Joined: Mon Jul 26, 2010 4:58 pm


Return to JFreeChart - General

Who is online

Users browsing this forum: No registered users and 4 guests