Chart implementation

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

Chart implementation

Post by Sudha Rajamani » Wed Jan 29, 2003 11:32 pm

Hi David
I installed jfreechart and cewolf and I am beginning to develop some charts. I also purchased jfreechart documentation. I need some help from you to proceed...

This is where I am. I need to construct some line charts. My seriesnames, categories and values change depending on time. I am using java classes and jsp pages to accomplish this.
I am attaching my code from the jsp page. Here I determine the seriesnames, categories and values. Now How do I go about getting a line chart. (Actually I would have to generate many line charts. But at this moment if I could do one that would be cool!!.)

<%@ page import = "java.lang.String.*, java.sql.*, java.util.*, java.text.*, java.io.*" %>
<%@page import="com.jrefinery.data.*"%>
<%@page import="de.laures.cewolf.*"%>
<%@taglib uri='/WEB-INF/cewolf-1.1.tld' prefix='cewolf' %>
<%@page contentType="text/html"%>

<jsp:useBean id="labforce" scope="session" class="almisLabor.almisLaborBean" />

<%

// get period
String period = request.getParameter("timePeriod");
session.setAttribute("period", period);

//get fields
String[] fields;
fields = (String[])session.getAttribute("fields");
session.setAttribute("fields", fields);

//get areaname
//String areaname = request.getParameter("areaname");
String areaname = (String)session.getAttribute("areaname");
session.setAttribute("areaname", areaname);

//get year
String[] year = (String[])session.getAttribute("year");
session.setAttribute("year", year);

labforce.makeConnection();
String[] seriesNames = labforce.getSeriesNames(year, fields, period);
String[] categories = labforce.getCategories(year, period);
Integer[] [] values = new Integer[seriesNames.length] [categories.length];
values = labforce.getValues(seriesNames, categories, areaname, year, fields, period);
labforce.goDown();
String title = "My Sample Chart";
%>

Thanks
Sudha

David Gilbert

Re: Chart implementation

Post by David Gilbert » Thu Jan 30, 2003 12:30 am

Hi Sudha,

I haven't used Cewolf, so I don't know the answer...but hopefully someone else will be able to help.

Regards,

Dave Gilbert

Sudha Rajamani

Re: Chart implementation

Post by Sudha Rajamani » Thu Jan 30, 2003 5:47 pm

Hi
I know I am using jsp pages in a funny way - I have a database and I have java classes which have methods to query the database and returns the data. From jsp page I am calling these methods to get the data series needed for graphs.

Now I am able to get the seriesnames, categories and values which are needed to develop a categorydataset but I am not sure how I can feed this information to the categorydataset class to produce a dataset which can be displayed in the browser. Even if you could brainstorm a bit with me on this - may be something will light up.

Anybody has any ideas??
Sudha

David Gilbert

Re: Chart implementation

Post by David Gilbert » Thu Jan 30, 2003 9:03 pm

Hi Sudha,

Your data is in a reasonable format to pass to the DefaultCategoryDataset constructor:

CategoryDataset = new DefaultCategoryDataset(seriesNames, categories, values);

Then you can pass that dataset to the createLineChart(...) method in the ChartFactory class.

Regards,

Dave Gilbert

P.S. The DefaultCategoryDataset class in 0.9.4 is not that great. It has been overhauled for 0.9.5, and should be much easier to use.

Locked