开发者

How to construct and use TimeSeriesCollections

开发者 https://www.devze.com 2023-02-13 05:44 出处:网络
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

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

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


TimeSeriesCollections are made up of TimeSeries objects

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

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);

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"));
0

精彩评论

暂无评论...
验证码 换一张
取 消