在JFreeChart上格式化Y轴 [英] Formatting Y-axis on JFreeChart

查看:183
本文介绍了在JFreeChart上格式化Y轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似于下面的StackedXYAreaChart:

I have a StackedXYAreaChart similar to the one below:

在Y轴上,而不是显示的刻度单位( 2.5 5.0 7.5 10.0 等),我有以下内容: 100,000 200,000 300,000 400,000 等。这些代表字节,就像上面的那样。我的问题是:有没有办法我可以格式化这些刻度单位,使它们代表千字节,即 100 200 300 400 等,甚至是兆字节,即 0.1 0.2 0.3 0.4 等。 ?我不想在Y轴上显示10 MB作为 10,000,000

On the Y-axis, instead of the tick units shown (2.5, 5.0, 7.5, 10.0, etc.), I have the following: 100,000, 200,000, 300,000, 400,000, etc. These represent Bytes, just like the one above. My question is: is there a way I could format these tick units such that they represent Kilobytes, i.e. 100, 200, 300, 400, etc. or even Megabytes, i.e. 0.1, 0.2, 0.3, 0.4, etc.? I don't want to display 10 MB as 10,000,000 on the Y-axis.

谢谢!

推荐答案

静态工厂 createStackedAreaChart() 实例化 NumberAxis 的范围。 NumberAxis 方法 createStandardTickUnits() 创建标准刻度单位,可以作为创建自己的单位的示例单位。特别是,如果您不喜欢这些默认值,请创建自己的 TickUnits 实例,然后将其传递给 setStandardTickUnits()方法。有更多详细信息此处

The static factory createStackedAreaChart() instatiates a NumberAxis for the range. The NumberAxis method createStandardTickUnits() creates the standard tick units, which may serve as an example for creating your own units. In particular, "If you don't like these defaults, create your own instance of TickUnits and then pass it to the setStandardTickUnits() method." There's more details here.

这篇关于在JFreeChart上格式化Y轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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