Tag: timeserieschart

如何仅显示“过去72小时”JFreeChart TimeSeries中的“过去24小时”

我写了这两行代码来使用XYDataset创建图表: final XYDataset dataset = new TimeSeriesCollection(myInfo.getSeries()); JFreeChart timechart = ChartFactory.createTimeSeriesChart(myInfo.getName() + ” CPU (last 72h)”, “”, “CPU %”, dataset, false, false, false); 这些线创建了这个漂亮的“最后72小时”图表: 这是我添加信息以构建此图表的方式(这段代码可以多次运行): SimpleDateFormat simpleDateFormat = new SimpleDateFormat(“yyyy-MM-dd H:mm:ss”); Date date = simpleDateFormat.parse(dateAsStringToParse); Second second = new Second(date); myInfo.getSeries().addOrUpdate(second, maxValue); // maxValue is an Integer 我想要一个(看似简单的)简单的改动 – 仅在过去24小时内“切断”这个。 我的意思是在图中只看到最近的24小时,就像这样(图中是我使用相同技术制作的不同图表,但信息仅存在于过去24小时): 我查看了API并找不到合适的答案,因为我认为这应该有一些聪明但简单的解决方案。

JFreeChart – 如何在TimeSeries图表的X轴上显示实时

我想在TimeSeries图表上显示实时数据, 实时显示在x轴上 (或者至少具有与实时相同的时间速度)。 这是一个问题的SSCCE,随机数作为实时输入。 x轴上显示的时间比实时快得多(假设它以hh:mm:ss格式显示): public class DynamicTimeSeriesChart extends JPanel { private DynamicTimeSeriesCollection dataset; private JFreeChart chart = null; public DynamicTimeSeriesChart(final String title) { dataset = new DynamicTimeSeriesCollection(1, 2000, new Second()); dataset.setTimeBase(new Second(0, 0, 0, 1, 1, 1990)); // date 1st jan 0 mins 0 secs dataset.addSeries(new float[1], 0, title); chart = ChartFactory.createTimeSeriesChart( title, “Time”, […]