JfreeChart on GWT (Google Web Toolkit)

A free public discussion forum for the JFreeChart class library.

Postby wimpie » Wed Nov 21, 2007 11:56 pm

Cool, many thanks !

related to
Code: Select all
java.lang.ClassNotFoundException: org.jfree.chart.servlet.DisplayChart

I put jcommon.jar and jfreechart.jar in WEB-INF/lib
wimpie
 
Posts: 1
Joined: Wed Nov 21, 2007 11:49 pm

Postby marcin » Tue Feb 26, 2008 11:17 pm

Sorry for digging out this old Topic, but i think it is the best place to ask.

I have tried to display a chart exactly like justindsmith describes it. Everything works fine at first. The application makes a call to the server, JChart makes the chart and so on. There are neither Java-Compiling errors nor GWT-Compiling errors.

But in case i run the application there is always a broken image-link. When i try to change the URL in the Image-class the GWT-Compiler says there is no file, so it must be the right URL, but i do not understand why i always get a broken Link instead of the image.

I have searched after the chartName on my computer and i found this file in a windows-temp folder with the right chart-image.

Is there anything not mentioned in justindsmith's tutorial? What could be the reason?

Thank you ...
Marcin :-)
marcin
 
Posts: 4
Joined: Tue Feb 26, 2008 10:59 pm

Postby peter_PL » Tue May 13, 2008 7:34 pm

Hi,

i've followed this tutorial and it's not working properly.

Well.. Maybe first I show you the code and then I describe what's wrong..

Code: Select all
public class ChartUnit extends Image {
   private ChartGeneratorServiceAsync chartGeneratorService;
   public ChartUnit(){
      super();
      
      chartGeneratorService = (ChartGeneratorServiceAsync)GWT.create(ChartGeneratorService.class);
      ServiceDefTarget endpoint = (ServiceDefTarget)chartGeneratorService;
      String url = GWT.getModuleBaseURL() + "ChartGeneratorService";
        endpoint.setServiceEntryPoint(url);
       
        AsyncCallback callback = new AsyncCallback() {
            public void onSuccess(Object s) {
                String chartName = (String)s;
                String imageUrl = "./displayChart?filename=" + chartName;
                setUrl(imageUrl);
            }
           
            public void onFailure(Throwable ex) {ex.printStackTrace();}
        };
        chartGeneratorService.generateChart(callback);
      
   }
}

Above is ChartUnit which is just single Image

Code: Select all
public interface ChartGeneratorService extends RemoteService {
   public String generateChart();
}


Code: Select all
public interface ChartGeneratorServiceAsync {
   public void generateChart(AsyncCallback callback);
}


Code: Select all
public class ChartGeneratorServiceImpl extends RemoteServiceServlet implements ChartGeneratorService {
   public String generateChart() {
        String chartName = "";
        DefaultPieDataset dataset = new DefaultPieDataset();
        dataset.setValue("One", 10.0);
        dataset.setValue("Two", 50.0);
        dataset.setValue("Three", 30.0);
        JFreeChart chart = ChartFactory.createPieChart("New Pie Chart", dataset, false, false, false);
        try {
            HttpSession session = getThreadLocalRequest().getSession();
            chartName = ServletUtilities.saveChartAsJPEG(chart, 300, 250, null, session);
        } catch(Exception e) {
            e.printStackTrace();
        }
        return chartName;
    }
}


Code: Select all
<servlet class="chartgenerator.server.ChartGeneratorServiceImpl" path="/ChartGeneratorService"/>
<servlet path='/displayChart' class='org.jfree.chart.servlet.DisplayChart'/>


And the problem is:

I get the Image object:
Code: Select all
panel = new VerticalPanel();
      
      img =  new ChartUnit();
      panel.add(img);
      
      initWidget(panel);

img url is for example: localhost:8888/chartgenerator.Charts/displayChart?filename=jfreechart-49968.jpeg

And the image is like red x.
no exceptions. No error messages. Could anyone help me please? I'm a bit confused.. :roll:

I'm Using Cypal Studio for gwt. Lastest stable gwt. Latest stable JFreeChart and JCommons
Thanks for help,
Peter
peter_PL
 
Posts: 2
Joined: Tue May 13, 2008 7:04 pm
Location: Warsaw/Poland

Postby peter_PL » Thu May 15, 2008 7:41 pm

Somebody please..
I'm stucked. The image is properly generated and saved into my TEMP directory but that's all. After it's properly generated attaching it into the page not working.

Any ideas.. I've tried everything. could anybody know what's wrong.. I'm desperated to get this work but I cant :(
Thanks for help,
Peter
peter_PL
 
Posts: 2
Joined: Tue May 13, 2008 7:04 pm
Location: Warsaw/Poland

Postby marco_m » Tue Jun 03, 2008 2:15 pm

--If anybody has still the problem--
Try:
Code: Select all
chartName = ServletUtilities.saveChartAsPNG(chart, 300, 250, session);

instead of
Code: Select all
chartName = ServletUtilities.saveChartAsJPEG(chart, 300, 250, null, session);

in Class ChartGeneratorImpl. That solved it for me.
marco_m
 
Posts: 1
Joined: Tue Jun 03, 2008 2:05 pm

Postby marcin » Sun Jun 15, 2008 12:41 pm

Thank you so much. That works for me too.
marcin
 
Posts: 4
Joined: Tue Feb 26, 2008 10:59 pm

Server round trips

Postby zooxmusic » Thu Jul 17, 2008 9:16 pm

is there a way to do this without making 2 trips to the server?
zooxmusic
 
Posts: 1
Joined: Thu Jul 17, 2008 9:14 pm

Postby irungk » Fri Jul 25, 2008 4:23 am

Guys need your guidance to put MemoryUsageDemo in jfreechart to GWT ... do you have any idea? I tried but failed in dynamic line chart... It didnt move like in MemoryUsageDemo ... need ur help how to do it...


thx
irungk
 
Posts: 1
Joined: Fri Jul 25, 2008 4:19 am

Postby satya » Thu Jul 31, 2008 11:04 am

Hi,
When you couldn't able to see the image even though its generated.
You should configure the DisplayChart servelet in Web.xml. Please advice me if there is any work around :)
satya
 
Posts: 1
Joined: Thu Jul 31, 2008 10:54 am

Re: JfreeChart on GWT (Google Web Toolkit)

Postby nits » Thu Mar 05, 2009 12:03 pm

I am doing same thing whatever is mentioned in tutorial by justindsmith .
yaa it is great tutorial,but I am not able get Image.
I am using GWT-ext-2.0.5

I have imported all three jcommon-1.0.15.jar,jfreechart-1.0.12.jar,servlet.jar jfreeCharts .jar files under "WebContent/WEB-INF/lib"
Here I am going to put the code what I have done:

Added to gwt.xml file
<servlet class="com.gwtext.sample.showcase2.server.ChartingServiceImpl" path="/chartingService"/>
<servlet class="org.jfree.chart.servlet.DisplayChart" path="/displayChart"/>

SERVER CODE
package com.gwtext.sample.showcase2.server;

import javax.servlet.http.HttpSession;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.servlet.ServletUtilities;
import org.jfree.data.general.DefaultPieDataset;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.gwtext.sample.showcase2.client.ChartingService;

public class ChartingServiceImpl extends RemoteServiceServlet implements ChartingService {

/**
*
*/
private static final long serialVersionUID = 1L;

public String getChart() {
/*
* Hold our stored chart name, it will be returned to the GWT caller.
*/
String chartName = "";

/*
* Create the data for this example.
*/
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("One", 10.0);
dataset.setValue("Two", 50.0);
dataset.setValue("Three", 30.0);

/*
* Generate the generic pie chart.
*/
JFreeChart chart = ChartFactory.createPieChart("New Pie Chart", dataset, false, false, false);

/*
* Save the chart as an '300px x 250px' jpeg image.
*/
try {
HttpSession session = getThreadLocalRequest().getSession();
chartName = ServletUtilities.saveChartAsJPEG(chart, 300, 250, null, session);
} catch(Exception e) {
// handle exception
}

/*
* Finally, return the chart name to the caller.
*/
return chartName;
}
}


Service class
package com.gwtext.sample.showcase2.server;

import javax.servlet.http.HttpSession;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.servlet.ServletUtilities;
import org.jfree.data.general.DefaultPieDataset;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.gwtext.sample.showcase2.client.ChartingService;

public class ChartingServiceImpl extends RemoteServiceServlet implements ChartingService {

/**
*
*/
private static final long serialVersionUID = 1L;

public String getChart() {
/*
* Hold our stored chart name, it will be returned to the GWT caller.
*/
String chartName = "";

/*
* Create the data for this example.
*/
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("One", 10.0);
dataset.setValue("Two", 50.0);
dataset.setValue("Three", 30.0);

/*
* Generate the generic pie chart.
*/
JFreeChart chart = ChartFactory.createPieChart("New Pie Chart", dataset, false, false, false);

/*
* Save the chart as an '300px x 250px' jpeg image.
*/
try {
HttpSession session = getThreadLocalRequest().getSession();
chartName = ServletUtilities.saveChartAsJPEG(chart, 300, 250, null, session);
} catch(Exception e) {
// handle exception
}

/*
* Finally, return the chart name to the caller.
*/
return chartName;
}
}


Cleint code----1----
/**
*
*/
package com.gwtext.sample.showcase2.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.Image;
import com.gwtext.client.widgets.MessageBox;

/**
* @author niteshk
*
*/
public class ChartImage extends Image {

private ChartingServiceAsync chartingService;
public ChartImage(){
super();
chartingService = (ChartingServiceAsync)GWT.create(ChartingService.class);
ServiceDefTarget endpoint = (ServiceDefTarget)chartingService;
String url = GWT.getModuleBaseURL() + "chartingService";
endpoint.setServiceEntryPoint(url);
chartingService.getChart(new AsyncCallback<String>(){

public void onFailure(Throwable caught) {
MessageBox.alert("came to failure.. Chart");
}

public void onSuccess(String result) {
System.out.println(" Came to success... Charting...");
String chartName = (String)result;
System.out.println(" Chart name is---"+ chartName);
String imageUrl = "./displayChart?filename=" + chartName;
// String imageUrl = "/showcase/WebContent/WEB-INF/lib//displayChart?filename=" + chartName;
setUrl(imageUrl);
}
});
}
}

Client---2-----
package com.gwtext.sample.showcase2.client.chart
public class Chart extends onLoadmodule(){
Panel pnl = new Panel();
Image img = new ChartImage();
pnl.add(img);
}

But Image is not being displayed..

I am getting following error in Google Web Development Toolkit Shell window
Please help What I have to do for get Chart Image..

Thanks in advance.
nits

[ERROR] Unable to instantiate 'com.gwtext.sample.showcase2.server.DisplayChartImpl'
java.lang.ClassNotFoundException: com.gwtext.sample.showcase2.server.DisplayChartImpl
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.google.gwt.dev.shell.GWTShellServlet.tryGetOrLoadServlet(GWTShellServlet.java:936)
at com.google.gwt.dev.shell.GWTShellServlet.service(GWTShellServlet.java:277)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Unknown Source)
[ERROR] Unable to dispatch request
nits
 
Posts: 3
Joined: Thu Mar 05, 2009 11:26 am

Re: JfreeChart on GWT (Google Web Toolkit)

Postby nits » Thu Mar 05, 2009 12:05 pm

My Service class is
package com.gwtext.sample.showcase2.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import com.google.gwt.user.client.rpc.ServiceDefTarget;

@RemoteServiceRelativePath("chartingService")
public interface ChartingService extends RemoteService {

public static class Util {

public static ChartingServiceAsync getInstance() {

return GWT.create(ChartingService.class);
}
}
public String getChart();
}
nits
 
Posts: 3
Joined: Thu Mar 05, 2009 11:26 am

Re: JfreeChart on GWT (Google Web Toolkit)

Postby nits » Mon Mar 16, 2009 10:41 am

Hi guys

I resolved the problem.

I wasn't having a class with same name DisplayChartIMPL(may be previously I had created and forgot to comment it into .gwt.ext file ) & inheriting that in .gwt.xml file.
I removed all unwanted lines from .gwt.xml file.
So I was getting mentioned error.

I followed justindsmith tutorial.
thanks ,justindsmith :)

nits
nits
 
Posts: 3
Joined: Thu Mar 05, 2009 11:26 am

Re: JfreeChart on GWT (Google Web Toolkit) with drilldown??

Postby jeromej » Tue Jul 14, 2009 4:55 pm

Hi,

Does any body have tried to create a drill down chart using jfreechart with GWT ... i tried few but i couldn't achieve the drill down but creating the 2d, 3d charts are workinig fine .... does any body have any sample code that works for drill down using the HTML image useMap method .... I searched this group there isn't any article or any posts that explains the drill down functionality of Jfreechart integrating with GWT.

If anyone know off something that could help me please let me know.

Thanks for reading this post.


Regards,
Jerome.
jeromej
 
Posts: 1
Joined: Mon Jul 13, 2009 8:54 pm

Re: JfreeChart on GWT (Google Web Toolkit)

Postby asafbent » Fri Dec 18, 2009 12:00 pm

Hi,
I need your help,
I tried to embbed a JfreeChart in GWT as described in the tutorial
however I receive the following error when tring to build any chart in the server side:
"java.lang.NoClassDefFoundError: javax.swing.event.EventListenerList is a restricted class. Please see the Google App Engine developer's guide for more details."
the exception was created as a result of "DefaultPieDataset dataset = new DefaultPieDataset();".

Any idea what am I doing wrong ?
Thanks,
Asaf.
asafbent
 
Posts: 1
Joined: Fri Dec 18, 2009 11:45 am

Re: JfreeChart on GWT (Google Web Toolkit)

Postby Boomi21 » Wed Apr 28, 2010 6:14 am

Thanks for taking time to help...
Boomi21
 
Posts: 1
Joined: Wed Apr 28, 2010 6:09 am

PreviousNext

Return to JFreeChart - General

Who is online

Users browsing this forum: No registered users and 4 guests