如何在JFreeChart中更改NumberAxis上的tickLabel? [英] How can I change the tickLabel on a NumberAxis in JFreeChart?

查看:108
本文介绍了如何在JFreeChart中更改NumberAxis上的tickLabel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JFreeChart,并希望能够将范围轴上的标签从数字更改为对我所在域更有意义的内容。我只看到用于自定义标签外观的选项,无法覆盖基于刻度线位置的标签内容。

I am using JFreeChart and want to be able to change the label on the range axis from a number to something more meaningful for the domain I am in. I only see options for customizing the look of the label and no way to override the content of the label based on the position of the tick.

有谁知道如何覆盖tickLabel的文本?

Does anyone know how to override the text of the tickLabel?

推荐答案

JFreeChart BarChartDemo1 显示如何使用 setStandardTickUnits() 方法。 NumberAxis 有几个方便的静态工厂。要覆盖默认值,您可以创建自己的 TickUnits 然后将其传递给 setStandardTickUnits() 方法。

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."

附录:上面提到的默认值只使用 java.text.Format 的子类;你可以为每个 TickUnit 提供你自己的 add()。如果这不合适,你可以覆盖 TickUnit 并用它来组成所需的 TickUnits

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.

这篇关于如何在JFreeChart中更改NumberAxis上的tickLabel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆