Different length series?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Jonathan Nash

Different length series?

Post by Jonathan Nash » Thu Jul 19, 2001 5:04 pm

I have several monthly time series, some of which start a few months earlier than others and some of which end a few months later than others.

When I try to graph them on the same graph, the ones with no data for those months graph as zero (with an ugly line connecting the first and last points straight down to zero).

Any ideas for getting round this aside from limiting my graph just to the shared months? I have implemented the graph both with a category data source and an xy data source and am indifferent to a line chart or an XY chart.

If it cannot currently be done, please consider this an enhancement request.

David Gilbert

RE: Different length series?

Post by David Gilbert » Mon Jul 23, 2001 9:54 pm

Hi Jonathan,

The CategoryDataSource requires each series to have a value for *every* category - that made the implementation of the bar charts easier for me.

The XYDataSource is more forgiving - the method getItemCount(int seriesIndex) returns the number of items in a particular series, and each item can return it's X and Y values independently (so each series can cover a different range). So as long as you implement XYDataSource correctly, JFreeChart will allow series of different lengths.

However, the DefaultXYDataSource class (a quick and dirty implementation of the XYDataSource interface) assumes you have the same number of items in every series - I should write a better class, I just put that one together because lots of developers (who should be reading up on interfaces) kept asking me how to create a chart from an array of data.

Hope that helps,

DG.

Locked