How to format x axis labels? I have a chart(look at attach1) I need to change x axis labels to the labels in the next attach (but with the same chart)
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
To set the label of the axis (in your example "counts") call
XYPlot plot = (XYPlot) chart.getPlot();
plot.getDomainAxis().setLabel("counts");
To change the number format of the axis call
XYPlot plot = (XYPlot) chart.getPlot();
((NumberAxis)plot.getDomainAxis()).setNumberFormatOverride(new DecimalFormat("0"));
To change the visible range of the plot call
XYPlot plot = (XYPlot) chart.getPlot();
((NumberAxis)plot.getDomainAxis()).setRange(0,20);