Reputation: 1
I am trying to hide the y axis line in my stacked bar chart in JFreeChart, and I have already tried below methods:
Setoutlinepaint(null)
Setbackgroundpaint(color.white)
Setoutlinevisible(false)
Categoryaxis.setaxislinevisible(false)
Categoryaxis.setvisible(false)
Many thanks in advance for your help.
Upvotes: 0
Views: 243
Reputation: 205875
Invoking the parent method setAxisLineVisible()
appears to produce the expected result for either a CategoryAxis
or a ValueAxis
. Starting from this example, the following changes in createChart()
produce the result shown. I've changed the plot orientation to make the domain axis vertical, and I've invoked setAxisLineVisible(false)
on both axes.
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setOrientation(PlotOrientation.HORIZONTAL);
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setAxisLineVisible(false);
plot.setDomainAxis(domainAxis);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setAxisLineVisible(false);
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
Axis lines not visible:
Axis lines visible:
Note that the factory methods for both bar chart stacked bar chart use the same axes.
Upvotes: 1