Setting currency format for labels of vertical axis in jFreeChart

泄露秘密 提交于 2019-12-12 20:22:40

问题


The essential of question is declared at the title.

More details: I have the Time series chart, and vertical axis should has labels in currency format like this

$100, 000, 000
$50, 000
...

Now I have the same labels, but without dollar sign and range delimiter.

For horizontal axis I used this approach:

DateAxis axis = (DateAxis) plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat("yyyy"));

And it works.

When I try to do similar

ValueAxis valueAxis = (ValueAxis) plot.getRangeAxis();

I can't find any method to format labels.

Please, help me.


回答1:


The ChartFactory.createTimeSeriesChart() factory supplies a NumberAxis for the range, so you can use setNumberFormatOverride() for with a localized currency formatter, as shown here.



来源:https://stackoverflow.com/questions/15254385/setting-currency-format-for-labels-of-vertical-axis-in-jfreechart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!