Possible bug? "a is null"

729 views
Skip to first unread message

Ümit

unread,
Oct 14, 2010, 8:29:31 AM10/14/10
to Google Visualization API
I have a weird problem with the Google Visualization API and GWT.
I am using a MVP Package (gwtp) to create an application. Basically I
have two presenters and views respectively.

One view/presenter displays as static text and the other one displays
as PieChart (google-vis-api).
As soon as the presenter with the Piechart is revealed a DataTable
with some test data is created and passed to the draw method of the
Piechart.
This works without any problems. The piechart is displayed just fine.
However as soon as I navigate away from the pie chart presenter to the
static text presenter and then back to the Piechart presenter
(thus creating again a DataTable and calling the draw method) I get an
visualization error ("a is null").

if I do a hard refresh (F5) the Piechart works again.
The same applies if I recreate the Piechart instance as soon as I
display the Piechart page.


I suspect that there is a problem when detaching and re-attaching the
DOM-container of the visualization widget so that calling draw on the
datatable I somewhere get the error "a is null".

I have attached a sample GWT application (which should contain all
necessary libs) which let's you reproduce the problem.

I have tried to debug it but because the visualization code is
obfuscated i didn't get far. As far as I could there seems to be a
problem somewhere in the setSelection function.

Maybe someone has an idea what might be the problem

Cheers

Thanks in advance

Uemit

P.S.: http://rapidshare.com/files/423663096/gwtpvisualizationsample.zip

ChartMan

unread,
Oct 17, 2010, 4:21:30 AM10/17/10
to google-visua...@googlegroups.com
can you please send a code snippet example.


--
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=en.


Ümit

unread,
Oct 18, 2010, 6:31:14 AM10/18/10
to Google Visualization API
Ok I have removed the MVP part and with this code you can reproduce
the problem in GWT.


private FlowPanel container;
private PieChart piechart;

public void onModuleLoad() {
// display initial Piechart with Testdata
container = new FlowPanel();
piechart = new PieChart();
container.add(piechart);
RootPanel.get().add(container);
piechart.draw(createTable(),createOptions());

// add Button which clears the container Panel and redraws the
piechart
Button button = new Button("reload");
container.add(button);
button.addClickHandler(new ClickHandler() {

@Override
public void onClick(ClickEvent event) {
container.clear();
container.add(piechart1);
piechart.draw(createTable(),createOptions());
}
});
}


createTable and creatOptions are just functions which create some
sample DataTable and Visualization Options (taken from another sample)

Apparantly when I clear the container FlowPanel and then re-add
(reattach) the piechart some reference is lost because as soon as I
call draw on the reattached piechart I get following exception:


Caused by: com.google.gwt.core.client.JavaScriptException:
(TypeError): a is null
fileName: http://www.google.com/uds/api/visualization/1.0/defe3df15750b02ac04b4018cb88c896/default,browserchart,piechart.I.js
lineNumber: 504
stack: ()@http://www.google.com/uds/api/visualization/1.0/
defe3df15750b02ac04b4018cb88c896/default,browserchart,piechart.I.js:
504
([object Object],[object Object])@http://www.google.com/uds/api/
visualization/1.0/defe3df15750b02ac04b4018cb88c896/
default,browserchart,piechart.I.js:528
()@http://www.google.com/uds/api/visualization/1.0/
defe3df15750b02ac04b4018cb88c896/default,browserchart,piechart.I.js:
590
([object Object])@http://www.google.com/uds/api/visualization/1.0/
defe3df15750b02ac04b4018cb88c896/default,browserchart,piechart.I.js:
590
([object Object],[object Object])@http://www.google.com/uds/api/
visualization/1.0/defe3df15750b02ac04b4018cb88c896/
default,browserchart,piechart.I.js:600
([object Object],[object Object])@http://127.0.0.1:8888:8


I have uploaded a test sample application which allows you to
reproduce the problem (uses two piechart -> one works the other
doesn't). It's actually pure GWT and Google Visualization (no MVP or
other library used).

http://rapidshare.com/files/425754405/gwtvisualizationsample.zip
> > google-visualizati...@googlegroups.com<google-visualization- api%2Bunsu...@googlegroups.com>
> > .

Ümit

unread,
Nov 18, 2010, 3:19:52 AM11/18/10
to Google Visualization API
Any update on this issue?

thanks in advance
>  fileName:http://www.google.com/uds/api/visualization/1.0/defe3df15750b02ac04b4...
>  lineNumber: 504
>  stack: ()@http://www.google.com/uds/api/visualization/1.0/
> defe3df15750b02ac04b4018cb88c896/default,browserchart,piechart.I.js:
> 504
> ([object Object],[object Object])@http://www.google.com/uds/api/
> visualization/1.0/defe3df15750b02ac04b4018cb88c896/
> default,browserchart,piechart.I.js:528
> ()@http://www.google.com/uds/api/visualization/1.0/
> defe3df15750b02ac04b4018cb88c896/default,browserchart,piechart.I.js:
> 590
> ([object Object])@http://www.google.com/uds/api/visualization/1.0/
> defe3df15750b02ac04b4018cb88c896/default,browserchart,piechart.I.js:
> 590
> ([object Object],[object Object])@http://www.google.com/uds/api/
> visualization/1.0/defe3df15750b02ac04b4018cb88c896/
> default,browserchart,piechart.I.js:600
> ([object Object],[object Object])@http://127.0.0.1:8888:8
>
> I have uploaded a test sample application which allows you to
> reproduce the problem (uses two piechart -> one works the other
> doesn't). It's actually pure GWT and Google Visualization (no MVP or
> other library used).
>
> http://rapidshare.com/files/425754405/gwtvisualizationsample.zip
>
> On Oct 17, 10:21 am, ChartMan <chart...@google.com> wrote:
>
>
>
>
>
>
>
> > can you please send a code snippet example.
>

sandro.b

unread,
Dec 1, 2010, 11:45:54 AM12/1/10
to Google Visualization API
I'm experiencing the same issue. Does anybody know of a workaround?

Eric Ayers

unread,
Dec 1, 2010, 11:55:05 AM12/1/10
to google-visua...@googlegroups.com
Are you sure the API is loaded? I didn't see a call to the
VisualizationUtils.loadVisualzationApi() and wait for the callback in
the onModuleLoad of the original post. Unless you include a <script>
include line for the API in the host HTML file, you haven't loaded the
JavaScript API (see the getting started page for Chart Tools on the
gwt-google-apis google code project.)

http://code.google.com/p/gwt-google-apis/wiki/VisualizationFAQ#Why_do_I_get_an_exception_saying_that_$wnd.google.visualization

> 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=en.
>
>

--
Eric Z. Ayers
Google Web Toolkit, Atlanta, GA USA

Eric Ayers

unread,
Dec 1, 2010, 12:01:16 PM12/1/10
to google-visua...@googlegroups.com
Sorry, I misfired on that one - your code is successfully loading, obviously.

Instead of adding and removing the widget from the container, I was
wondering if you could try a workaround - create an intervening
container and add and remove it from the outer container instead of
the visualization widget directly.

Another thing to try is to run in hosted mode -

?mit

unread,
Dec 10, 2010, 4:30:59 AM12/10/10
to google-visua...@googlegroups.com
Hi Eric, 
sorry for my late response. 
I actually get the "a is null" in both production and hosted mode. 

I will try to do your workaround but I think it will also cause an error. This problem/error occurred when I was using a MVP framework (GWTP) when going from one view to another and back. The MVP framework internally probably calls clear on the root container and then re-adds the container (which contains my piechart) as soon as the view is displayed again. 

Anyways I will test with an intermediate container and report back with my findings.

cheers
Ümit

Reply all
Reply to author
Forward
0 new messages