Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Jsni

    I am trying to link in Dygraphs (javascript native graphing library) into smartGWT 2.2. I have successfully compiled and linked my project to the javascript library. I am getting the following error:

    Code:
     
    
    23:36:32.818:WARN:Log:(TypeError): $wnd.google is undefined
     stack: ...

    I am not sure what the error means or what I need to do to resolve. Here is my .java code as well:

    Code:
    public class Dygraphs implements EntryPoint {
    
    	@Override
    	public void onModuleLoad() {
    		final VLayout main = new VLayout();
    		
    		
    		main.setWidth100();
    		main.setHeight100();
    		
    		
    		ToolStrip topBar = new ToolStrip();
    		
    		topBar.setHeight(33);
    	    topBar.setWidth100();
            topBar.addSpacer(6);
    		
    		
            
            ToolStripButton devConsoleButton = new ToolStripButton();
    	        devConsoleButton.setTitle("Developer Console");
    	        devConsoleButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
    	            public void onClick(ClickEvent event) {
    	                SC.showConsole();
    	                
    	                
    	                
    	            }
    	        });
    
    	        topBar.addButton(devConsoleButton);
    
    	        HLayout hLayout = new HLayout();
    		    hLayout.setLayoutMargin(5);
    		    hLayout.setWidth100();
    		    hLayout.setHeight100();
    		    hLayout.setShowEdges(true);
    		
    	        
    	        
    	    main.addMember(topBar);
    		main.addMember(hLayout);
    		
    	    try {
    			drawDygraph(hLayout.getElement(),createData());
    		} catch (Exception e) {
    			SC.logWarn(e.getMessage());
    		}
    
    
    		
    		main.draw();
    		
    		
    		
    	}
    
    	
    	// Protected because the GWT compiler has to generate a subclass.
    	  protected interface Resources extends ClientBundle {
    	    @Source("com/test/client/dygraph-combined.js")
    	    TextResource dygraphs();
    	  }
    
    	  private static final Resources RESOURCES = GWT.create(Resources.class);
    	  private static boolean installed = false;
    
    	  /**
    	   * Install the Dygraphs JavaScript source into the current document.  This
    	   * method is idempotent.
    	   */
    	  public static synchronized void install() {
    	    if (!installed) {
    	      ScriptElement e = Document.get().createScriptElement();
    	      e.setText(RESOURCES.dygraphs().getText());
    	      Document.get().getBody().appendChild(e);
    	      installed = true;
    	    }
    	  }
    
    	  // Prevent construction
    	  private Dygraphs() { }
    
    	
    	
    	public static native JavaScriptObject drawDygraph(Element element, DataTable dataTable) /*-{
        var chart = new $wnd.Dygraph.GVizChart(element);
        chart.draw(dataTable,
          {
            valueRange: [0,50]
          });
        return chart;
      }-*/;
    
    	private DataTable createData() {
    		
    		
    		DataTable data =  DataTable.create();
    		
    		data.setValue(0,0,2);
    		data.setValue(0,1,6);
    		data.setValue(1,0,12);
    		data.setValue(2,0,30);
    		
    		
    		return data;
    	}
    }
Working...
X