Unfortunately, I'm unfamiliar with UIBinder, but I can help interpret the error message.
"Container width is zero" is generally thrown when you attempt to draw the ATL before associating it with an Element on the page. (This error is unique to GWT, since this binding takes place as part of the ctor in javascript.) Take a look at this sample code<https://code.google.com/p/gwt-google-apis/wiki/VisualizationGettingStarted>to see how a GCT chart is normally associated with a panel (or similar) before being drawn. I suspect something similar is happening here, since you create the ATL and then immediately draw it in all of your code samples. Perhaps you need to call initWidget before trying to draw the ATL? -g On Monday, July 15, 2013 11:36:43 PM UTC-4, [email protected] wrote: > > Hi , > > I am sure this topic has been posted before but, I just can't find the > right topic > > I am trying to use AnnotatedTimeLine.PACKAGE with UiBinder > > My UiBinder XML File is > <g:VerticalPanel width="450px" height="222px"> > > ... > <g:HTMLPanel width="100px" height="160px"> > <gct:AnnotatedTimeLine > ui:field="timelineplot" width="90px" height="150px"/> > </g:HTMLPanel> > <g:Label > ui:field="lastUpdatedLabel"></g:Label> > </g:VerticalPanel> > > My "timelineplot" field is declared with provided=true as > @UiField (provided = true) > AnnotatedTimeLine timelineplot; > > > As I understand for Visualization API I need to call > VisualizationUtils.loadVisualizationApi(timelineplotCallback, > AnnotatedTimeLine.PACKAGE); > > where timelineplotCallBack is the call back function which initializes the > chart > > Relevant code > > Runnable timelineplotCallback = new Runnable() > { > @Override > public void run() > { > AnnotatedTimeLine timelineplot = new > AnnotatedTimeLine("90px", "150px"); > DataTable talbe = createHistoryTable(); > timelineplot.draw(talbe); > > initWidget(uiBinder.createAndBindUi(handletoParent)); > //timer to refresh data > CreateTimer(); > } > }; > > VisualizationUtils.loadVisualizationApi(timelineplotCallback, > AnnotatedTimeLine.PACKAGE); > > AnnotatedTimeLine.Options options = > AnnotatedTimeLine.Options.create(); > options.setDisplayAnnotations(true); > options.setDisplayZoomButtons(true); > options.setScaleType(AnnotatedTimeLine.ScaleType.ALLFIXED); > > options.setLegendPosition(AnnotatedTimeLine.AnnotatedLegendPosition.SAME_ROW); > // Additional data initialization > PrepareStockTable(); > } > > However, the run code is never executed ( no stop on breakpoints) and the > RootPanel.get("application").add(c); // where c is a composite object > consisting of the widgets including timeplot > > It crashes at this line with > > java.lang.AssertionError: This UIObject's element is not set; you may be > missing a call to either Composite.initWidget() or UIObject.setElement() > > This is understandable since initWidget located in the callback is still > not called. > > If I however call > " initWidget(uiBinder.createAndBindUi(handletoParent));" > just before the "PrepareStockTable();" > > it crashes at the "(uiBinder.createAndBindUi(handletoParent));" line with > > java.lang.AssertionError: UiField timelineplot with 'provided = true' was > null > > > On the other hand if my code is as follows : > > Runnable timelineplotCallback = new Runnable() > { > @Override > public void run() > { > //DataTable talbe = createHistoryTable(); > //timelineplot.draw(talbe); > CreateTimer(); > > } > }; > > VisualizationUtils.loadVisualizationApi(timelineplotCallback, > AnnotatedTimeLine.PACKAGE); > > AnnotatedTimeLine.Options options = > AnnotatedTimeLine.Options.create(); > options.setDisplayAnnotations(true); > options.setDisplayZoomButtons(true); > options.setScaleType(AnnotatedTimeLine.ScaleType.ALLFIXED); > > options.setLegendPosition(AnnotatedTimeLine.AnnotatedLegendPosition.SAME_ROW); > > //DataTable data = createHistoryTable(); > //PrepareGWTChart(); > > AnnotatedTimeLine timelineplot = new AnnotatedTimeLine("90px", > "150px"); > DataTable talbe = createHistoryTable(); > timelineplot.draw(talbe); > > > initWidget(uiBinder.createAndBindUi(handletoParent)); > then it crashes at " timelineplot.draw(talbe);" with > > com.google.gwt.core.client.JavaScriptException: (Error) > @com.google.gwt.visualization.client.visualizations.Visualization::draw(Lcom/google/gwt/visualization/client/AbstractDataTable;)([JavaScript > > object(15)]): Container width is zero. Expecting a valid width. > > So what is the right way of using AnnotatedTimeLine.PACKAGE with UiBinder > ?? > > Thanks for reading so far :) > > Regards > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-visualization-api. For more options, visit https://groups.google.com/groups/opt_out.
