How do I construct the datasource for a line chart using this simple X Y example?
X = 1, 2, 3, 4, 5
Y = 1, 2, 3, 4, 5 ?
Datasource X Y line chart
RE: Datasource X Y line chart
Hi Randy,
You should try, wherever possible, to implement the XYDatasource interface in whatever class you are using to store your data. That way you don't have to copy your data from one structure to another.
Alternatively, you could use the DefaultXYDataSource class which is *supposed* to make it easy to create a chart with some simple data in an array. Unfortunately the current implementation doesn't really make it that easy, because of the multi-dimensional array needed by the constructor not being very intuitive (DefaultXYDataSource will be rewritten for the next release). Here's what you need:
Double[][][] data_array = new Double[][][] { { { new Double(1.0), new Double(5.6) },
{ new Double(2.0), new Double(3.5) },
{ new Double(3.0), new Double(2.4) },
{ new Double(4.0), new Double(4.3) },
{ new Double(5.0), new Double(1.3) } } };
DefaultXYDataSource data = new DefaultXYDataSource(data_array);
Regards,
DG.
You should try, wherever possible, to implement the XYDatasource interface in whatever class you are using to store your data. That way you don't have to copy your data from one structure to another.
Alternatively, you could use the DefaultXYDataSource class which is *supposed* to make it easy to create a chart with some simple data in an array. Unfortunately the current implementation doesn't really make it that easy, because of the multi-dimensional array needed by the constructor not being very intuitive (DefaultXYDataSource will be rewritten for the next release). Here's what you need:
Double[][][] data_array = new Double[][][] { { { new Double(1.0), new Double(5.6) },
{ new Double(2.0), new Double(3.5) },
{ new Double(3.0), new Double(2.4) },
{ new Double(4.0), new Double(4.3) },
{ new Double(5.0), new Double(1.3) } } };
DefaultXYDataSource data = new DefaultXYDataSource(data_array);
Regards,
DG.