How to create and use TimeSeriesCollections

I want to show some dates on the x-axis of the chart, but it says here that I should use the TimeSeriesCollections object

It seems that I should add TimeSeries to TimeSeriesCollections and that TimeSeries should be created using a regular loop ... I'm a little confused ...

Could you explain to me what to do? If possible, can you provide sample code? thank

+2
source share
1 answer

TimeSeriesCollectionsconsist of TimeSeriesobjects

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

When creating objects TimeSeries. Fill them with time and values. Here is an 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 , - :

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

Source: https://habr.com/ru/post/1794738/


All Articles