Adding date/time to JFreeChart graph

孤街醉人 提交于 2019-11-29 08:11:10
trashgod

Without an sscce or the desired format, I'm just guessing.

XYPlot plot = (XYPlot) chart.getPlot();
DateAxis axis = (DateAxis) plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat("dd-MMM-yyyy"));

Addendum: Looking closer, you're using ChartFactory.createXYLineChart(), which creates a NumberAxis for the domain. Instead, use ChartFactory.createTimeSeriesChart(), which creates a DateAxis for the domain.

Addendum: If time represents milliseconds from the same epoch as a Java Date, you can use new Date(time.longValue()) to construct your dataset's RegularTimePeriod. There's a related example here.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!