带日期的jfreechart直方图 [英] jfreechart histogram with dates
本文介绍了带日期的jfreechart直方图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在直方图的X轴上显示一些日期,但我不知道该怎么做
I want to display some dates in the X axis of a histogram chart, but i don't understand how i can do it
使用此代码,我可以创建带有几个x-y值的简单直方图,但是它们可以是数字,而不是日期:
with this code i can create a simple histogram with couples of x-y values, but they can olny be numbers, not date:
DefaultTableXYDataset dataset = new DefaultTableXYDataset();
XYSeries serie = new XYSeries("Andamento consumi", true, false);
serie.add(30, 8.3);
serie.add(31, 7.1);
serie.add(1, 8.7);
serie.add(2, 6.0);
serie.add(3, 11.9);
dataset.addSeries(serie);
JFreeChart chart = ChartFactory.createHistogram("Grafico di prova", "Giorni", "Consumi", dataset, PlotOrientation.VERTICAL,true,true,true);
ChartFrame frame = new ChartFrame("Titolo finestra", chart);
frame.pack();
frame.setVisible(true);
是否可以插入日期而不是数字?
Is there a way to insert dates instead of numbers?
推荐答案
如果要处理日期,请使用TimeSeriesCollection
或TimePeriodValuesCollection
数据集而不是DefaultTableXYDataset
.
If you are dealing with dates use a TimeSeriesCollection
or TimePeriodValuesCollection
dataset instead of DefaultTableXYDataset
.
这篇关于带日期的jfreechart直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文