将XYPlot的日期轴缩放到固定间隔 [英] Scale date axis of XYPlot to a fixed interval
问题描述
在Java项目中,我使用了JFreeChart 1.0.19版本和XYPlot
在绘图上绘制线条.
我希望将比例尺xAxis
(日期轴)作为日期,例如-10:00:05、10:00:05、10:00:10、10:00:15…-每5秒缩放一次. /p>
但是现在,当用户以10:00:03时间开始时,它看起来像是10:00:03、10:00:08、10:00:13、10:00:18…
我希望始终将5秒缩放为10:00:05、10:00:05、10:00:10、10:00:15,并且与开始时间无关,如何设置?
我将域轴(时间轴)配置如下:
domainAxis.setAutoRange(true);
domainAxis.setAutoTickUnitSelection(true);
domainAxis.setLowerMargin(0.001);
domainAxis.setUpperMargin(0.001);
domainAxis
是ValueAxis
我的情节看起来像 如您所见,时间值是11:21:57、11:22:07、11:22:17等.我希望始终应该是11:21:55、11:22:05、11:22:15等
因为domainAxis
是 DateTickUnit
具有所需的unitType
和multiple
.在此片段中,间隔为五秒,格式包括秒:
domainAxis.setTickUnit(new DateTickUnit(DateTickUnitType.SECOND, 5));
domainAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));
In Java project, I used JFreeChart 1.0.19 version and XYPlot
to draw lines on plot.
I want scale xAxis
(Date axis) as date in example - 10:00:05, 10:00:05, 10:00:10, 10:00:15…—scaling for every 5 seconds.
But now when user start with 10:00:03 time, it looks as 10:00:03, 10:00:08, 10:00:13, 10:00:18…
I want that always be scaled of 5 seconds as 10:00:05, 10:00:05, 10:00:10, 10:00:15 and be independently of start time, how to set it?
I configurated domain axis(time axis) as below:
domainAxis.setAutoRange(true);
domainAxis.setAutoTickUnitSelection(true);
domainAxis.setLowerMargin(0.001);
domainAxis.setUpperMargin(0.001);
domainAxis
is a object of ValueAxis
My plot looks like as You see the time values are 11:21:57, 11:22:07, 11:22:17 etc. I want that always should be 11:21:55, 11:22:05, 11:22:15 etc.
Because domainAxis
is an instance of DateAxis
, you can use setTickUnit()
to specify a DateTickUnit
having the desired unitType
and multiple
. In this fragment, the interval is five seconds, and the format includes seconds:
domainAxis.setTickUnit(new DateTickUnit(DateTickUnitType.SECOND, 5));
domainAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));
这篇关于将XYPlot的日期轴缩放到固定间隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!