I'm trying to incorporate Google Charts into a javascript object oriented web app. After the app is loaded - the idea is that the user clicks a certain button which builds/displays a certain chart.
I suspect that I have a scope problem. Firefox/Firebug throws "InvalidCharacterError: String contains an invalid character" which isn't very helpful.
Below is a snippet of what I'm trying to do. Perhaps someone can point out some obvious problem with my attempt?
Thanks in advance for your help.
<html>
<head>
<script type="text/javascript" src="
https://www.google.com/jsapi"></script>
<script language="JavaScript" type="text/javascript">
google.load('visualization', '1.0', {'packages':['corechart']});
</script>
</head>
<body>
<div id="googlecharttest"></div>
</body>
</html>
BUTTON CLICK EVENT -> OBJchart.build_googlechart();
------------------
Javascript Snippet
------------------
OBJchart = new Fchart();
Fchart = function() { return {
...
build_googlechart : function()
{
this.drawChart();
// also tried this - with the same result.
// google.load('visualization', '1.0', {'packages':['corechart'], 'callback': this.drawChart});
},
drawChart : function()
{
var data = new google.visualization.DataTable();
data.addColumn('string','Topping');
data.addColumn('number','Slices');
data.addRows([['Mushrooms', 3],['Onions', 1],['Olives', 1],['Zucchini', 1],['Pepperoni', 2]]);
var options = {'title':'How Much Pizza I Ate Last Night','width':400,'height':400};
var chart = new google.visualization.LineChart(document.getElementById('googlecharttest'));
chart.draw(data,options);
},
...
};};