How to use objects of arraylist in Jfreechart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
saeid.j
Posts: 1
Joined: Sat Jan 07, 2017 3:41 am
antibot: No, of course not.

How to use objects of arraylist in Jfreechart

Post by saeid.j » Sat Jan 07, 2017 3:45 am

Hello everybody
I am writing a programme to visualize some data which are stored in a few arraylists. I'm using Jfree Line char but the problem is I have to make an arraylist in the chart class and set an array list from use interface to the one in chart class using setter. like

Code: Select all

LineChartDemo linechartdemo1 = new LineChartDemo("All Sensors");
            linechartdemo1.setList(list.getsList());
            linechartdemo1.setTimelist(list.getTime());
            linechartdemo1.create();
            linechartdemo1.pack();
            RefineryUtilities.centerFrameOnScreen(linechartdemo1);
            linechartdemo1.setVisible(true);
So my question is that how can I make an instance of my arraylist class and use it in chart class(The normal way objects work) I tried making a new object and use getters like

Code: Select all

Datalist list = new DataList();
list.getMaxvalue();
But it's not working and this is how I'm using my list in other classes. This time it doesn't work in my chart class and it requires me to make an arraylist in chart class and set an arralist from user interface class. Can Somebody please help? How can I make and instance of my ArrayList class like above and use it in chart class and why is it not working in JfreeChart like we normally use objects in java. it returns null if I create an object of the arraylist in the chart class?
Thanks in advance

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: How to use objects of arraylist in Jfreechart

Post by John Matthews » Sat Jan 07, 2017 11:52 am

Cross-posted here.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: How to use objects of arraylist in Jfreechart

Post by david.gilbert » Mon Jan 09, 2017 7:29 am

I'm not sure I understand the question. JFreeChart doesn't work with ArrayList as a datasource, it works with any implementation of a dataset interface (XYDataset, CategoryDataset, PieDataset etc). That's proven to be a very flexible and effective way of separating the provision of data from the visualisation of data (the latter being the job of JFreeChart).

I'm pretty sure you will be able to create a wrapper object fairly easily for your ArrayList and have it implement the required interface (generally requires just a few mapping methods).
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked