No Construcotor Integer[] for BarChart

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

No Construcotor Integer[] for BarChart

Post by Awais Bajwa » Wed Sep 18, 2002 5:23 pm

Hello All ,
I want to display Vertical Bar Chart for 5 integer Values .I am using DefalutCatagoryDataset ,all constructors includes 2 dimenstional array [][] but there is no possibility that i can define dataset wiht single dimentional array say any arry of Integer []=new Integer[]{"2","3","4","6","10"};
I am surprised wiht this as I've Purchased docs for $30 but they cant help me to achieve above. So eventualy i have two options either to implement myo own Datastructures or to convert my Integer[] to Integer[][] .
I hope you all understood well what i wana say .

Regards
Awais Bajwa

David Gilbert

Re: No Construcotor Integer[] for BarChart

Post by David Gilbert » Wed Sep 18, 2002 11:10 pm

Hi Awais,

It's difficult to provide constructors that suit everyone. Two-dimensional arrays of double primitives or Number objects are supported. But by all means write your own dataset implementation to wrap whatever data structure you are using...the DefaultCategoryDataset is just one possible implementation.

Converting a single dimensional array into a two-dimensional array is no problem, the following code works just fine:

double[] data = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0 };
DefaultCategoryDataset dataset = new DefaultCategoryDataset(new double[][] { data });

Regards,

DG

Awais Bajwa

Re: No Construcotor Integer[] for BarChart

Post by Awais Bajwa » Thu Sep 19, 2002 6:59 am

Hello David,
Thank for your reply .
I did the same thing in my case but not such simple as i had to generate Integer [][] array at RunTime .
For the time being i did what you said ,but can you tell me some easy way to implement my own dataset using DataSet Interface that data can be displayed in the BarCart .Kindly name the Interfaces which i have to implenment .

Best Regards.

Andreas Schroeder

Re: No Construcotor Integer[] for BarChart

Post by Andreas Schroeder » Thu Sep 19, 2002 8:54 am

Hi Awais,
i would suggest you use

public class myOwnDataset extends AbstractSeriesDataset implements CategoryDataset

just like the DefaultCategoryDataset does. Works fine!

Regards,
Andreas Schroeder

Locked