gpt4 book ai didi

java - JFreeChart PeriodAxis :29 minutes fractions

转载 作者:搜寻专家 更新时间:2023-11-01 03:25:46 25 4
gpt4 key购买 nike

我正在尝试在图表中使用 PeriodAxis 来绘制一些时间序列数据。第一个数据点出现在 2012-01-08 19:00:00,最后一个数据点出现在 2012-01-09 19:00:00。

绘制图表时,刻度标签从 19:29 开始,到 19:29 结束。我希望它们在 19:00 开始并相应地结束——也就是说,我不想要 :29 分钟的分数。我尝试使用 setStandardTickUnits() 将刻度标签增量设置为 1 小时增量,但这并没有改变任何东西。我似乎无法为此类找到任何其他允许我更改刻度单位的方法。

enter image description here

示例代码:

PeriodAxis domain = new PeriodAxis(null, new Hour(19, new Day(8, SerialDate.JANUARY, 2012)),
new Hour(19, new Day(9, SerialDate.JANUARY, 2012)));
domain.setAutoRangeTimePeriodClass(Hour.class);
PeriodAxisLabelInfo[] periodLabels = new PeriodAxisLabelInfo[2];
periodLabels[0] = new PeriodAxisLabelInfo(Hour.class, new SimpleDateFormat("HH:mm"));
periodLabels[1] = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("MMM dd, yyyy"));
domain.setLabelInfo(periodLabels);

domain.setLowerMargin(0);
domain.setUpperMargin(0);
TickUnits tu = new TickUnits();
tu.add(new DateTickUnit(DateTickUnit.HOUR, 1));

domain.setAutoTickUnitSelection(true);
domain.setStandardTickUnits(tu);

最佳答案

在您的例子中,图表从 19:00 开始,tickUnit 为 1 小时。

这里的问题是 PeriodAxis 将水平轴分成 24 个周期,每个周期由一个 org.jfree.data.time.Hour 对象表示。然后它会在时间段的中间显示一个标签:19:29、20:29...

为了得到你想要的,你可以使用 DateAxis 而不是 PeriodAxis,或者使用 "hh:00" 作为一种日期格式,它将用 00 代替分钟。

关于java - JFreeChart PeriodAxis :29 minutes fractions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14247663/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com