View Full Version : Testing basic chart

6 May 2009, 9:32 AM
I am somewhat familiar with OFCGWT, but the code for basic chart in the 2.0M1 examples is a little different.


public void onModuleLoad() {
String url = !isExplorer() ? "../../" : "";
url += "gxt/chart/open-flash-chart.swf";

final Chart chart = new Chart(url);

ContentPanel panel = new ContentPanel();

I tried copying the whole resources folder with the open-flash-chart.swf from 2.0M1 into my project folder but that didn't work. Here is the exception when the page loads:

[ERROR] Uncaught exception escaped
com.google.gwt.core.client.JavaScriptException: (TypeError): '$wnd.swfobject' is null or not an object
number: -2146823281
description: '$wnd.swfobject' is null or not an object
at com.extjs.gxt.ui.client.widget.flash.SwfObject.embedSWT(Native Method)
at com.extjs.gxt.ui.client.widget.flash.SwfObject.embedSWF(SwfObject.java:113)
at com.extjs.gxt.ui.client.widget.flash.FlashComponent.injectFlash(FlashComponent.java:221)
at com.extjs.gxt.ui.client.widget.flash.FlashComponent.onAttach(FlashComponent.java:185)
at com.extjs.gxt.charts.client.Chart.onAttach(Chart.java:199)
at com.extjs.gxt.ui.client.widget.ComponentHelper.doAttach(ComponentHelper.java:23)
at com.extjs.gxt.ui.client.widget.Container.doLayout(Container.java:377)
at com.extjs.gxt.ui.client.widget.Container.layout(Container.java:294)
at com.extjs.gxt.ui.client.widget.LayoutContainer.layout(LayoutContainer.java:238)
at com.extjs.gxt.ui.client.widget.Container$1.execute(Container.java:448)
at com.google.gwt.user.client.CommandExecutor.doExecuteCommands(CommandExecutor.java:310)
at com.google.gwt.user.client.CommandExecutor$2.run(CommandExecutor.java:205)
at com.google.gwt.user.client.Timer.fireImpl(Timer.java:160)
at com.google.gwt.user.client.Timer.fireAndCatch(Timer.java:146)
at com.google.gwt.user.client.Timer.fire(Timer.java:138)

8 May 2009, 1:01 PM
Found this thread:
[2.0m1] Cannot get charts working (http://extjs.com/forum/showthread.php?t=66637)

I copied googlelybear's example code from the thread, both open-flash-chart.swf and swfobject.js are directly under war folder, but still no go. The error message is still the same one, slightly different than the one googelybear had.

Any idea? Thanks in advance.

10 May 2009, 6:29 AM
You need to include swfobject.js to your host html page. The file is shipped with GXT

11 May 2009, 1:39 PM
Thanks, that was it!

Add open-flash-chart.swf and swfobject.js into war/
Add gxt.jar into war/WEB-INF/lib/

Add these to *.gwt.xml:
<inherits name='com.extjs.gxt.ui.GXT'/>
<inherits name='com.extjs.gxt.charts.Chart'/>

Add this to *.html:
<script type="text/javascript" language="javascript" src="swfobject.js"></script>

12 May 2009, 12:00 AM
For future releases (since "importing" swobject.js is mandatory):

Why don't you include the swfobject.js file in the public folder of the "'com.extjs.gxt.charts.Chart" module?
And then, it could be "imported" in the Chart module xml...

This way we would not need to include it manually in the host html... one less thing to worry about :)