In your chart customizer, cast your plot to an XYPlot
(or just call chart.getXYPlot()
) and then call setAxisOffset
on it. This method sets the gap between the axes and the plot.
(javadoc here)
Removing the gap from the y-axis should be as simple as calling:
plot.setAxisOffset(new RectangleInsets(5.0, 0.0, 5.0, 5.0));
Removing all of the gaps can be done with:
plot.setAxisOffset(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
or
plot.setAxisOffset(RectangleInsets.ZERO_INSETS);
Edit:
By default, the plot will begin slightly before the first data point. If you want the data to begin immediately at the edge of the plot, call setMinimumDate
on your date axis, setting it to the same value as the first point in your dataset.