aspose file tools*
The moose likes Other Open Source Projects and the fly likes Anybody used JFreeCharts? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Anybody used JFreeCharts? " Watch "Anybody used JFreeCharts? " New topic
Author

Anybody used JFreeCharts?

Tanmoy Palodhi
Greenhorn

Joined: May 21, 2007
Posts: 13
Anybody used JFreeCharts?
I have been trying to use the JFreeCharts for rendering a bar chart in my JSR-168 portlet and deploy in Sun ONE portal. But I havent got success yet. Its not throwing any kind of specific error but the graph is not been getting displayed !!

Can anybody help?

- Tanmoy
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
How are you generating the chart? Is the chart image being stored correctly in a place where it can be served from? Does the resulting web page have the proper URL in the "src" attribute of an "img" tag?


Ping & DNS - my free Android networking tools app
Tanmoy Palodhi
Greenhorn

Joined: May 21, 2007
Posts: 13
Thanks Ulf for replying.

On the more easier note, I have been trying to render this 3D barchart in channel using JSP Provider.
I have put the code below that I have written in the JSP. The code contains the hard coded values only.
This code works good when run in the local tomcat server but doesnt in the portal server. When run in portal as a channel it gives an error: "Content not available".

I tried to debug and found that the method createBarChart3D() is not getting called but it doesnt throw any exceptions.

Would it been an issue with the img src, it would have created the jpg file atleast which is not happening.

Ulf, hope you are able to understand the problem. Please help.


<%
out.println("Creating the 3D bar chart...");

DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.setValue(7, "Science", "Mike");
dataset.setValue(18, "Science", "Craig");
dataset.setValue(9, "Science", "Casey");
dataset.setValue(6, "Science", "Tanmoy");
dataset.setValue(16, "Science", "Kathy");
dataset.setValue(6, "Science", "Ben");

JFreeChart chart1 = ChartFactory.createBarChart3D("Comparison between Students","Students", "Marks",
dataset, PlotOrientation.VERTICAL, true,true,false);

chart1.setBackgroundPaint(Color.yellow);
chart1.getTitle().setPaint(Color.blue);
CategoryPlot p = chart1.getCategoryPlot();
p.setRangeGridlinePaint(Color.red);

ChartUtilities.saveChartAsJPEG(new File("chart_03March09.jpg"), chart1, 300, 300);

%>
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
"Tanmoy Pjava ",
you seem to have missed that we have a policy on screen names here at JavaRanch. It must consist of a first name and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do using the "My Profile" link at the top of the page.

I tried to debug and found that the method createBarChart3D() is not getting called but it doesnt throw any exceptions.

How do you know the method is not being called?

ChartUtilities.saveChartAsJPEG(new File("chart_03March09.jpg"), chart1, 300, 300);

There is no default directory for web apps. You need to use an absolute file path.
Tanmoy Palodhi
Greenhorn

Joined: May 21, 2007
Posts: 13
Thanks Ulf for reminding me of the policies.

On the JFreeCharts side...I have commented most of the code to identify the problem zone. The code I writing now is:

&lt;%
out.println("Creating the 3D bar chart...");

DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.setValue(7, "Science", "Mike");
dataset.setValue(18, "Science", "Craig");
dataset.setValue(9, "Science", "Casey");

out.println("Debug 1");

JFreeChart chart1 = ChartFactory.createBarChart3D("Comparison between Students","Students", "Marks",
dataset, PlotOrientation.VERTICAL, true,true,false);

out.println("Debug 2");

chart1.setBackgroundPaint(Color.yellow);
chart1.getTitle().setPaint(Color.blue);
CategoryPlot p = chart1.getCategoryPlot();
p.setRangeGridlinePaint(Color.red);

out.println("Debug 3");

ChartUtilities.saveChartAsJPEG(new File("chart_03March09.jpg"), chart1, 300, 300);

%&gt;

The code above works till midway... I am getting the value printed "Debug 1" but not the "Debug 2" and neither the "Debug 3"!!

Any guesses whats causing the problem?

Thanks
Tanmoy


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
Check the server logs for exceptions. Also, as I said, you must use an absolute path that points to a publicly accessible directory.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Anybody used JFreeCharts?