I would find a method that get the domaine value (on a TimeSeriesChart) of a mouse click.
I find that code on a former thread but I don't find it in the librairy.
You can add a ChartMouseListner to achieve that. You can capture the anchor point (mouse click) and the distance (mouse move). There are some methods in the Axis classes that let you translate screen coordinates do data coordinates.
Code:Code: Select all
/** * Returns the domain data value given a screen coordinate. * @param x the x-coordinate of the screen * @return the corresponding domain data value */ private double getDomainDataValue(final int x) { // get the current domain value XYPlot plot = chart.getXYPlot(); double xx = plot.getDomainAxis().java2DToValue( x, getScreenDataArea(), plot.getDomainAxisEdge() ); return xx; } /** * Returns the X screen coordinate given a domain data value. * @param xDataValue the domain data value * @return the corresponding x-coordinate of the screen */ private int getXScreenCoordinate(double xDataValue) { // get the current domain value XYPlot plot = chart.getXYPlot(); double xx = plot.getDomainAxis().valueToJava2D( xDataValue, getScreenDataArea(), plot.getDomainAxisEdge() ); // apply scale if any and return (SCALE MESS UP EVERYTHING) //return translateJava2DToScreen(new Point2D.Double(xx,0)).x; return (int) Math.round(xx); }