google / google-visualization-issues

288 stars 35 forks source link

Bug: Uncaught Error: google-visualization-errors: container is null. message: Container is not defined #1880

Open orwant opened 9 years ago

orwant commented 9 years ago
Steps to reproduce the problem with link to a sample page

1.go to https://iheart.shinyapps.io/ShinyBuilder/
2.move your mouse on the pie and click on the Graph button. the Google Graph Editor
pop up.
3.click on OK 
4.go to the javascript console log
5.you get the error message "Uncaught Error: google-visualization-errors: container
is null. message: Container is not defined"

Everything was working fine until today.  Now I can not validate any change in the
google graph editor, I alway get the error message.

I suppose there has been some change during the night on your side.

(Version 1.0)

What operating system and browser are you using?

*********************************************************
For developers viewing this issue: please click the 'star' icon to be
notified of future changes, and to let us know how many of you are
interested in seeing it resolved.
*********************************************************

Original issue reported on code.google.com by equere21 on 2015-02-19 19:16:47

orwant commented 9 years ago
I worked around this issue by not initializing my chart via "google.visualization.ChartWrapper."
In my case I was using ChartWrapper to create a tree map chart. I swapped that out
for "google.visualization.TreeMap." This initialization method takes some different
parameters but I was able to produce the results I wanted. I hope this helps you.

Original issue reported on code.google.com by Ryan.Marr934 on 2015-02-20 18:49:55

orwant commented 9 years ago
I suspect that people who are getting the 'container is null' message are using jQuery
to provide the element, and it is not a proper element for this purpose, which is especially
important for the ChartWrapper.  I am curious if it works when you get the actual element
(using jQuery .get()).

Original issue reported on code.google.com by dlaliberte@google.com on 2015-02-20 19:10:48

orwant commented 9 years ago
dlalibe, I was using the containerId property. I wasn't passing a jQuery or a DOM element
and it worked fine until a day or two ago.

Original issue reported on code.google.com by Ryan.Marr934 on 2015-02-20 19:17:58

orwant commented 9 years ago
With the ChartWrapper,
I have fixed the problem by removing the parameters of the 'draw' method.

var chart = new google.visualization.ChartWrapper({'dataTable': dataTable, 'options'
: {...}, ...});
chart.draw();

Original issue reported on code.google.com by jolan.teinturier@ipa-consulting.fr on 2015-02-20 19:18:59

orwant commented 9 years ago
jolan

I have fixed the problem with you tip.
That problem was driving me crazy because everything was fine until two days ago.

Thanks a lot
Leo from Brazil

Original issue reported on code.google.com by djleoaz on 2015-02-20 19:46:03

orwant commented 9 years ago
Jolan, and djleoaz, I am curious what parameter were you giving to the draw method?
 It should have been a container element or an id.  Perhaps it ignored non-elements
in the past, but now it causes an error.  We could probably have it ignore the parameter
if it is not a string and not an element.

Original issue reported on code.google.com by dlaliberte@google.com on 2015-02-20 19:52:33

orwant commented 9 years ago
I just gave the datatable.
But, it's useless, we already give it at the creation of the wrapper.

chart.draw(dataTable);

Original issue reported on code.google.com by jolan.teinturier@ipa-consulting.fr on 2015-02-20 20:05:08

orwant commented 9 years ago
I found the same problem just yesterday. Must be some changes in the API library. 

Original issue reported on code.google.com by arbeiv on 2015-02-20 21:56:02

orwant commented 9 years ago
dlalibe

I used to pass the datatable as parameter to the method draw.
chart.draw(dataTable);

Thanks

Original issue reported on code.google.com by djleoaz on 2015-02-21 15:10:38

orwant commented 9 years ago
This happened to me last week too. i believe the chartwrapper .draw() method was redefined.

At some point in the past, it required a Chart object (and, I think, accepted an optional
chart options object). Now the documentation says it accepts an optional container
Id string... Code written against the previous version will result in an error because
the chart object isn't a containerid.

Maybe there was an undocumented update? I know my chart was working for some time after
the last reported update (October)

Original issue reported on code.google.com by bagleworm on 2015-02-22 14:48:17

orwant commented 9 years ago
Correction: Maybe it was a datatable object, not a chart object that the old .draw()
method required. Either way, not a string!

Original issue reported on code.google.com by bagleworm on 2015-02-22 14:50:14

orwant commented 9 years ago
Bagleworm, it seems most people expected the datatable object should be passed to the
draw() method, as it is for regular charts.  But a ChartWrapper is not actually a chart
itself, and I believe the ChartWrapper draw method never allowed a datatable object,
but always expected a container element id.  Now that it also allows a container element,
it gets confused if you give it something else.  

We can make a change that ignores the parameter if it is not a proper element or id,
but since this is more of a user error, I don't think we will make the change at this
time.  The error message should probably be more specific, however.  E.g. 'ChartWrapper
expects a container element or id'

Original issue reported on code.google.com by dlaliberte@google.com on 2015-02-22 17:14:36

orwant commented 9 years ago
Ah, fantastic, thank you for the correction and clarification! I agree that changing
the error message to what you suggested would be very helpful.

Original issue reported on code.google.com by bagleworm on 2015-02-22 22:16:30