2
votes

I'm getting this exception when trying to create an AnnotatedTimeLine object:

com.google.gwt.core.client.JavaScriptException: (TypeError) @com.google.gwt.visualization.client.visualizations.AnnotatedTimeLine::createJso(Lcom/google/gwt/dom/client/Element;)([JavaScript object(1575)]): $wnd.google.visualization.AnnotatedTimeLine is not a constructor

It's being fired right from the "new AnnotatedTimeLine" line. Am I doing something wrong? I know this library hasn't been updated in a while. Does AnnotatedTimeLine still work? I'm successfully using the pie chart already so it's not a problem with my gwt viz setup.

I'm using GWT 2.5.1 and the jar gwt-visualization 1.1.2.

VisualizationUtils.loadVisualizationApi(new Runnable() {
        @Override
        public void run() {
            DataTable tableData = DataTable.create();
            tableData.addColumn(ColumnType.DATE, "Date");
            tableData.addColumn(ColumnType.NUMBER, "I");
            tableData.addRows(5);

            for (int i = 0; i < 5; i++) {
                tableData.setValue(i, 1, ClientDateUtils.addDays(new Date(), i));
                tableData.setValue(i, 0, i * -1);
            }

            AnnotatedTimeLine timeLine = new AnnotatedTimeLine("500px", "300px");
            timeLine.draw(tableData);
            page.add(timeLine);
        }
    }, CoreChart.PACKAGE);

Here's my imports if that helps: import com.google.gwt.visualization.client.AbstractDataTable.ColumnType; import com.google.gwt.visualization.client.DataTable; import com.google.gwt.visualization.client.VisualizationUtils; import com.google.gwt.visualization.client.visualizations.AnnotatedTimeLine; import com.google.gwt.visualization.client.visualizations.corechart.CoreChart;

1

1 Answers

3
votes

The problem is that you're loading CoreChart.PACKAGE, and ATL is in the AnnotatedTimeLine.PACKAGE. Most charts are in CoreChart, but a few aren't. You can find out what package you need by looking at the docs in the "Loading" section:

https://developers.google.com/chart/interactive/docs/gallery/annotatedtimeline?hl=en#Loading

Hope that's helpful.