1. #1
    Ext User babyblue's Avatar
    Join Date
    May 2009
    Posts
    47
    Vote Rating
    0
    babyblue is on a distinguished road

      0  

    Question Testing basic chart

    Testing basic chart


    I am somewhat familiar with OFCGWT, but the code for basic chart in the 2.0M1 examples is a little different.

    http://extjs.com/examples-dev/explorer.html#basicchart
    Code:
        public void onModuleLoad() {
            String url = !isExplorer() ? "../../" : "";  
            url += "gxt/chart/open-flash-chart.swf";
          
            final Chart chart = new Chart(url);
            chart.setBorders(true);
            chart.setChartModel(getPieChartData());
          
            ContentPanel panel = new ContentPanel();
            panel.add(chart);
            RootPanel.get().add(panel);
        }
    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)

  2. #2
    Ext User babyblue's Avatar
    Join Date
    May 2009
    Posts
    47
    Vote Rating
    0
    babyblue is on a distinguished road

      0  

    Default


    Found this thread:
    [2.0m1] Cannot get charts working

    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.

  3. #3
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    You need to include swfobject.js to your host html page. The file is shipped with GXT

  4. #4
    Ext User babyblue's Avatar
    Join Date
    May 2009
    Posts
    47
    Vote Rating
    0
    babyblue is on a distinguished road

      0  

    Talking


    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>

  5. #5
    Sencha User
    Join Date
    Nov 2008
    Location
    Vienna - Austria
    Posts
    870
    Vote Rating
    1
    micgala is on a distinguished road

      0  

    Default


    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

    Regards,
    Michel.

Thread Participants: 2