简体   繁体   English

在JFreeChart上格式化Y轴

[英]Formatting Y-axis on JFreeChart

I have a StackedXYAreaChart similar to the one below: 我有一个StackedXYAreaChart类似于以下内容:

在此处输入图片说明

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. 在Y轴,而不是蜱单位表示( 2.55.07.510.0等),我有以下: 100,000200,000300,000400,000等。这些代表字节,就像上面的一个。 My question is: is there a way I could format these tick units such that they represent Kilobytes, ie 100 , 200 , 300 , 400 , etc. or even Megabytes, ie 0.1 , 0.2 , 0.3 , 0.4 , etc.? 我的问题是:有一个方法,我可以格式化这些蜱单元,使得它们代表千字节,即100200300400等,或甚至兆字节,即0.10.20.30.4 ,等? I don't want to display 10 MB as 10,000,000 on the Y-axis. 我不想在Y轴上将10 MB显示为10,000,000

Thanks! 谢谢!

The static factory createStackedAreaChart() instatiates a NumberAxis for the range. 静态工厂createStackedAreaChart()将范围的NumberAxis实例化。 The NumberAxis method createStandardTickUnits() creates the standard tick units, which may serve as an example for creating your own units. NumberAxis方法createStandardTickUnits()创建标准的刻度单位,可以用作创建自己的单位的示例。 In particular, "If you don't like these defaults, create your own instance of TickUnits and then pass it to the setStandardTickUnits() method." 特别是,“如果您不喜欢这些默认值,请创建自己的TickUnits实例,然后将其传递给setStandardTickUnits()方法。” There's more details here . 还有更多的细节在这里

I would of done a byte conversion, converting from 我会做一个字节转换,从

KB to MB=(KB/1024)
KB to TB=(KB/(1024*2))
KB to GB=(KB/(1024*3))
KB to PB=(KB/(1024*4))

Where the the NumberAxis should auto range depending on the value passed. NumberAxis应根据传递的值自动调整范围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM