Search code examples
javajfreechart

Java JFreeChart - get coordinates of boundary points


How to coordinates of boundary points, which are selected with red arrows?

For example, the lower left boundary point has coordinates (-0.10, 0.00) and the upper right boundary point has coordinates (1.10, 1.15), but how to get it with any functions?

This string below get Window coordinates of this points, but I need their chart coordinates:

Rectangle2D plotArea = chartPanel.getScreenDataArea();

enter image description here


Solution

  • This will give you the ranges you are looking for:

        XYPlot plot = (XYPlot) chart.getPlot();
        Range xRange = plot.getDomainAxis().getRange();
        Range yRange = plot.getRangeAxis().getRange();