如何构造和使用TimeSeriesCollections [英] How to construct and use TimeSeriesCollections

查看:80
本文介绍了如何构造和使用TimeSeriesCollections的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在图表的X轴上显示一些日期,并在此处据说我必须使用一个TimeSeriesCollections对象

I want to display some dates in the X axis of a chart, and here it is said that i have to use a TimeSeriesCollections object

似乎我必须将TimeSeries添加到TimeSeriesCollections中,并且必须使用RegularTimePeriod构造TimeSeries. 我有点困惑...

It seems that i have to add a TimeSeries to the TimeSeriesCollections, and that the TimeSeries has to be constructed using a RegularTimePeriod... I am a bit confused...

您能解释一下我必须做什么吗? 如果可能,您可以提供一些示例代码吗? 谢谢

Can you please explain me what i have to do? If possible can you provide some example code? Thanks

推荐答案

TimeSeriesCollectionsTimeSeries个对象

使用此方法将系列添加到数据集:addSeries(TimeSeries series)

Use this method to add series to the dataset: addSeries(TimeSeries series)

创建TimeSeries对象时.用时间和值填充它们.这是一个粗略的示例:

When creating TimeSeries objects. Fill them with the time and values. Here is a rough example:

TimeSeries ts= new TimeSeries("Name of Series");
ts.addOrUpdate(new Year(2008), 42);
ts.addOrUpdate(new Year(2009), 51);
ts.addOrUpdate(new Year(2010), 97);
ts.addOrUpdate(new Year(2011), 45);

要使Axis很好地显示日期,您将必须执行以下操作:

For getting the Axis to display the dates nicely, you will have to do something like this:

XYPlot plot = chart.getXYPlot();
DateAxis axis = new DateAxis();
plot.setDomainAxis(axis);
axis.setDateFormatOverride(new SimpleDateFormat("yyyy"));

这篇关于如何构造和使用TimeSeriesCollections的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆