I have problem with getting the correct Y values when having mouseover a point on my chart.. This is what i have in my listener:
public void chartMouseMoved(ChartMouseEvent move) {
MouseEvent e = move.getTrigger();
int x = e.getX();
int y = e.getY();
Point2D p =frame.getChartPanel().translateScreenToJava2D(e.getPoint());
XYPlot xyplot = frame.getChartPanel().getChart().getXYPlot();
Rectangle2D dataArea = frame.getChartPanel().getChartRenderingInfo().getPlotInfo().getDataArea();
double xValue = xyplot.getDomainAxis().java2DToValue(p.getX(), dataArea, xyplot.getDomainAxisEdge());
double yValue = xyplot.getDomainAxis().java2DToValue(p.getY(), dataArea, xyplot.getRangeAxisEdge());
System.out.println( "X: " + xValue + " Y: " + yValue);
}
If I use the dataArea.getHeight() / dataArea.getWidth() i can observe that one of them is bigger than the other is this where my problem lies? Do i have to redraw the graph?
It returns the right x value since this is always the biggest of the two.
Im guessing it has something to do with scaling of the axis...? Could someone help me out here?
Axis / Scaling problem?
-
- Posts: 844
- Joined: Fri Oct 13, 2006 9:29 pm
- Location: Sunnyvale, CA
Re: Axis / Scaling problem?
You seem to be using the domain axis to compute yValue which could explain a lot of the scaling issues.samoht wrote:Could someone help me out here?
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA