How can I change the tickLabel on a NumberAxis in JFreeChart?

霸气de小男生 提交于 2019-11-28 02:00:33

The JFreeChart BarChartDemo1 shows how to use the setStandardTickUnits() method. NumberAxis has several handy static factories for this. To override the defaults, you can "create your own instance of TickUnits and then pass it to the setStandardTickUnits() method."

Addendum: The defaults mentioned above simply use a subclass of java.text.Format; you can supply your own for each TickUnit you add(). If this is inadequate, you can override valueToString() in your own concrete subclass of TickUnit and use it to compose the required TickUnits.

chris

I just found this while having the same problem. I solved it by using a SymbolAxis. SymbolAxis can be added to a XYPlot.

SymbolAxis sa = new SymbolAxis("AxisLabel",
    new String[]{"Category1","Category2","Category3","..."});
chart.getPlot().setDomainAxis(sa);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!