AnnotatedTimeLine Exception Line Order Weirdness

35 views
Skip to first unread message

Douglas

unread,
Nov 18, 2009, 7:27:49 AM11/18/09
to Google Visualization API
Hi,

Very frustrated here and I am really hoping someone can help me out.
I am using GWT 1.7.1 and GWT-VIZ 1.0.2 on XP. The following code
works fine for me...

1. TabPanel tp = new TabPanel();
2. VerticalPanel vp = new VerticalPanel();
3. vp.add(new MyTimeline());
4. RootPanel.get().add(tp);
5. tp.add(vp, "stuff");
6. tp.selectTab(0);

...but just switching lines (4) and (5) as below...

1. TabPanel tp = new TabPanel();
2. VerticalPanel vp = new VerticalPanel();
3. vp.add(new MyTimeline());
4. tp.add(vp, "stuff");
5. RootPanel.get().add(tp);
6. tp.selectTab(0);

...causes the following exception;

[ERROR] Uncaught exception escaped
com.google.gwt.core.client.JavaScriptException: (Error):
number: 0
description:
at
com.google.gwt.visualization.client.visualizations.Visualization.draw
(Native Method)
at
com.google.gwt.visualization.client.visualizations.Visualization.onLoad
(Visualization.java:116)
at com.google.gwt.user.client.ui.Widget.onAttach(Widget.java:264)
at com.google.gwt.user.client.ui.Panel.doAttachChildren(Panel.java:
165)
at com.google.gwt.user.client.ui.Widget.onAttach(Widget.java:259)
at com.google.gwt.user.client.ui.Panel.doAttachChildren(Panel.java:
165)
at com.google.gwt.user.client.ui.Widget.onAttach(Widget.java:259)
at com.google.gwt.user.client.ui.Panel.doAttachChildren(Panel.java:
165)
at com.google.gwt.user.client.ui.Widget.onAttach(Widget.java:259)
at com.google.gwt.user.client.ui.Composite.onAttach(Composite.java:
102)
at com.google.gwt.user.client.ui.Widget.setParent(Widget.java:393)
at com.google.gwt.user.client.ui.Panel.adopt(Panel.java:119)
at com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:
86)
at com.google.gwt.user.client.ui.AbsolutePanel.add(AbsolutePanel.java:
80)
at uk.co.wibble.client.HistoryGetter.<init>(HistoryGetter.java:19)
at uk.co.wibble.client.TestTimeLine.run(TestTimeLine.java:22)
at com.google.gwt.ajaxloader.client.ExceptionHelper.runProtected
(ExceptionHelper.java:36)

Why should the order of these statements cause this kind of issue?
The above issue replicator models a production defect for me that
suffers from the same kind of line order related wierdness. It's not
related to the data as I can reproduce this with a wide range of
datasets. My host web page is empty (default one generated by GWT).
FYI, here is my AnnotatedTimeLine derivative...

public class MyTimeline extends AnnotatedTimeLine
{
public MyTimeline()
{
super(getData(), getOptions(), "700px", "240px");
}

private static AbstractDataTable getData()
{
DataTable data = DataTable.create();
data.addColumn(ColumnType.DATETIME, "Date");
data.addColumn(ColumnType.NUMBER, "Stuff)");
data.addRows(6);

try
{
data.setValue(0, 0, new Date(2008 - 1900, 1, 1, 1, 1, 1));
data.setValue(1, 0, new Date(2008 - 1900, 1, 2, 2, 2, 2));
data.setValue(2, 0, new Date(2008 - 1900, 1, 3, 3, 3, 3));
data.setValue(3, 0, new Date(2008 - 1900, 1, 4, 4, 4, 4));
data.setValue(4, 0, new Date(2008 - 1900, 1, 5, 5, 5, 5));
data.setValue(5, 0, new Date(2008 - 1900, 1, 6, 6, 6, 6));
}
catch (JavaScriptException ex)
{
GWT.log("Error creating data table - Date bug on mac?", ex);
}
data.setValue(0, 1, 30000);
data.setValue(1, 1, 14045);
data.setValue(2, 1, 0);
data.setValue(3, 1, 75284);
data.setValue(4, 1, 41476);
data.setValue(5, 1, 33322);
return data;
}

private static AnnotatedTimeLine.Options getOptions()
{
AnnotatedTimeLine.Options options = AnnotatedTimeLine.Options.create
();
options.setDisplayAnnotations(true);
options.setOption("displayRangeSelector", false);
options.setScaleType(AnnotatedTimeLine.ScaleType.ALLFIXED);
return options;
}
}


MC Get Vizzy

unread,
Dec 30, 2009, 6:00:48 AM12/30/09
to google-visua...@googlegroups.com
um, sorry it took me forever to get back to you.

the error you're seeing is because the sequence of events is causing the AnnotatedTimeLine to be drawn when the container div has no size.

why do you need to add the timeline to the tab panel before attaching the tab panel to the dom?

can you add the timeline without drawing it (that is, construct it without data and options), and then draw it (that is, call draw()) after the tab panel is added to the dom?  you could also draw the timeline when the tab is selected, like this:

          TabPanel tp = new TabPanel();
          final AnnotatedTimeLine viz = new AnnotatedTimeLine("700px", "240px");
          tp.add(viz, "stuff");
          tp.addSelectionHandler(new SelectionHandler<Integer>(){
            @Override
            public void onSelection(SelectionEvent<Integer> event) {
              if (event.getSelection() == 0) {
                viz.draw(data, options);
              }
            }
          });



--

You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=.



Reply all
Reply to author
Forward
0 new messages