I’m having a problem with integrating JFreeChart with Vaadin. I imported everything that I need for creating my chart, and I also imported JFreeChartWrapper jar file that I found in the Add-ons for Vaadin, and everything seemed to be going well.
But when I tried to test if things are working correctly, I had an “HTTP 500” type: Exception Format, and description: the server encountered an internal error () that prevented it from fulfilling this request.
Here is the code for the window that should contain the Chart:
public class JFreeTrial extends Window {
public JFreeTrial() {
super("This is a test");
XYSeries series = new XYSeries("Sprint 1");
series.add(0, 165);
series.add(1, 150);
series.add(2, 130);
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series);
// Generate the graph
JFreeChart chart = ChartFactory.createXYLineChart("Burn Down Chart", // Title
"days", // x-axis Label
"Esimated Effort", // y-axis Label
dataset, // Dataset
PlotOrientation.VERTICAL, // Plot Orientation
true, // Show Legend
true, // Use tooltips
false // Configure chart to generate URLs?
);
JFreeChartWrapper wrapper = new JFreeChartWrapper(chart);
/////////////////////////////////////////////
VerticalLayout v = new VerticalLayout();
this.addComponent(v);
v.addComponent(wrapper);
v.setWidth("100%");
}
}
Your code looks just fine to me. Do you have any compile problems? Did you include all batik libraries that JFreeChart uses to render SVG charts? What is the detailed error?
No actually I didn’t, any idea where to get those libraries from ??
Here is the detailed error :
exception
javax.servlet.ServletException: Failed to load application class: com.example.jfreechartwithtoolkit.JfreechartwithtoolkitApplication
com.vaadin.terminal.gwt.server.ApplicationServlet.init(ApplicationServlet.java:71)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
java.lang.Thread.run(Thread.java:637)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.
Thanks for the “patch”. I released 2.1 version that has the suggested change + a compression option in case you don’t have global gzip compression on in your server.
I can get the task of converting batik to freesvg. I’m interested in using this addon.
Note: New versions of JFreeChart uses JFreeSVG, at least in the examples.
Second,
I used the above code, dependencies auto-resolved but I cannot see the chart.
To use JFreeSVG instead of Batik, I think the actual add-on should be modified. If you haven’t done that use use Batik. IF you are using Maven, the dependencies should be automatically resolved.
BTW. If you can make JFreeSVG version working, I’m happy to review your changes and publish a new version. I moved the sources from the dead code.google.com to
github .
MY problem here, all dependencies are OK but code stops when I add the above JFreeChart code. I get your CRUD example, and after the grid, I added chart.
But I cannot see it, and it also prevent me to see list. When I look to developer console, I see this:
GET http://localhost:8080/null 404 (Not Found)
j @ script.js:7
Mj @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:2039
D$c @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5976
Vyb @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5849
Kyb @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5937
Vxb @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5943
Wxb @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5637
Txb @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5747
oyb @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:4661
lxb @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5969
Ti @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5025
Li @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:3955
Xi @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5966
Ri @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:996o
i @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:2337
ri @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:5064
(anonymous function) @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:4602
d @ vwscdnc95eee4621aa10d08d6a6635696b0b07-0.js:441
and the error seem to be on this line on script.js:
Maybe you are hitting the same issue as in
this thread , a nasty backwards incompatibility introduced in 7.3.9 and still not fixed
I’m getting pretty skeptic that our R&D will ever fix that and I have no time for it, so you could maybe introduce the proposed workaround first and only after that look into JFreeSVG upgrade?
The only think that worries me for JFreeSVG is its licence, it’s GPL. So it wont be possible to use this addon for commercial products unless open the source !!
Also, there is another problem. Like i said, i used your crud example. But after i add the chart, components after chart are not rendering. There is no error message etc. If ii put chart as first element, the others are not visible.
Also, even if i put it after the List, i cannot ser the list…
I think the charts kills the rendering loop and all rest components are just not rendered. Fixing the issue will proably take care of this. You can enable client side exceptions by adding “?debug” query parameter to your application during development.
[code]
XYSeries series = new XYSeries(“Sprint 1”);
series.add(0, 165);
series.add(1, 150);
series.add(2, 130);
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series);
// Generate the graph
JFreeChart chart = ChartFactory.createXYLineChart("Burn Down Chart", // Title
"days", // x-axis Label
"Esimated Effort", // y-axis Label
dataset, // Dataset
PlotOrientation.VERTICAL, // Plot Orientation
true, // Show Legend
true, // Use tooltips
false // Configure chart to generate URLs?
);
JFreeChartWrapper wrapper = new JFreeChartWrapper(chart) {
private static final long serialVersionUID = 1L;
@Override
public void attach() {
super.attach();
setResource("src", getSource());
}
};
setContent(
new MVerticalLayout(
new MVerticalLayout(wrapper).withFullWidth(),
new RichText().withMarkDownResource("/welcome.md"),
new MHorizontalLayout(addNew, edit, delete),
list
).expand(list)
);
[/code]This is my code, and this is the debug panel:
03msStarting application ROOT-2521314
114msUsing theme: valo
116msVaadin application servlet version: 7.5.0
125msSetting hearbeat interval to 300sec.
132msJSON parsing took 0ms
134msHandling message from server
135ms* Handling resources from server
136ms* Handling type inheritance map from server
140msHandling type mappings from server
143msHandling resource dependencies
145ms* Handling meta information
146ms* Creating connectors (if needed)
166ms* Updating connector states
181ms* Handling locales
184ms* Updating connector hierarchy
186ms* Sending hierarchy change events
204ms* Running @DelegateToWidget
206ms* Sending state change events
220ms* Passing UIDL to Vaadin 6 style connectors
257ms* Performing server to client RPC calls
260ms* Unregistered 0 connectors
261mshandleUIDLMessage: 115 ms
263msStarting layout phase
269msMeasured 3 non connector elements
279msPass 1 measured 8 elements, fired 7 listeners and did 0 layouts.
283msPass 2 measured 3 elements, fired 1 listeners and did 2 layouts.
284msNo more changes in pass 3
295msTotal layout phase time: 31ms
296ms* Dumping state changes to the console
297msUIDL: undefined
325msProcessing time was 192ms for 6108 characters of JSON
326msReferenced paintables: 10
335msStarting layout phase
341msMeasured 3 non connector elements
344msPass 1 measured 2 elements, fired 0 listeners and did 1 layouts.
344msNo more changes in pass 2
346msTotal layout phase time: 10ms
347msStarting layout phase
349msMeasured 3 non connector elements
352msPass 1 measured 2 elements, fired 0 listeners and did 1 layouts.
352msNo more changes in pass 2
354msTotal layout phase time: 6ms
To me it looks you just have too much staff you try to squeeze into 100% height layout and the rest will be clipped. Removing the .expand(list) part of your code make the layout use the space it needs (and scrollbar will appear).