Hi, I think the problem may be in loading packages. In documentation they
use one call of google.load.
Try to use
google.load('visualization', '1', {packages: ['columnchart', 'table']});
I think second call of google.load makes your chart not shown.
7 апреля 2009 г. 16:52 пользователь Ned <[email protected]> написал:
>
> Thanks for the clarifications. This seems to work in IE. FireFox
> shows the table, but no chart at all. Any thoughts on what is going
> on there? No error is being thrown through Firefox, it just shows a
> big empty white space. Here is the code I used (based on original):
>
> <script language="javascript" type="text/javascript">
> google.load('visualization', '1', {packages:
> ['columnchart']});
> google.load('visualization', '1', {packages: ['table']});
>
>
> function drawVisualization(JSONTable)
> {
> var tJSON = {cols: [{id: 'ActivityDate', label:
> 'ActivityDate', type: 'string'},{id: 'Count', label: 'Count', type:
> 'number'}], rows: [{c: [{v: '4/1/2009'},{v: 130}]},{c: [{v:
> '4/2/2009'},{v: 255}]},{c: [{v: '4/3/2009'},{v: 380}]},{c: [{v:
> '4/6/2009'},{v: 614}]}]};
> var data = new google.visualization.DataTable(tJSON);
>
> // Create and draw the visualization.
> new google.visualization.ColumnChart
> (document.getElementById('google_chart')).draw(data, {height: 400,
> width: 800});
>
> visualization = new google.visualization.Table
> (document.getElementById('google_table'));
> visualization.page = "enable";
> visualization.draw(data, {page: 'enable', pageSize:
> 25});
>
> }
> google.setOnLoadCallback(drawVisualization);
>
> </script>
>
>
>
> On Apr 7, 1:33 am, Максим Барбул <[email protected]> wrote:
> > This works well
> >
> > <html>
> > <head>
> > <script type="text/javascript" src="http://www.google.com/jsapi
> "></script>
> > <script type="text/javascript">
> > google.load('visualization', '1', {packages:
> ['table','columnchart']});
> > function drawVisualization() {
> > // Create and populate the data table.
> > var JSONObject = {
> > cols: [
> > {id: 'ActivityDate', label:'ActivityDate', type: 'string'},
> > {id: 'Count', label: 'Count', type:'number'}
> > ],
> > rows: [
> > {c: [{v: 'DateA'},{v:130}]}, // here you should give NUMBER
> but
> > NOT string
> > {c: [{v: 'DateB'},{v:255}]},
> > {c: [{v: 'DateC'},{v:380}]}
> > ]
> > };
> > var data = new google.visualization.DataTable(JSONObject);
> > // Create and draw the visualization.
> > var visualization = new
> > google.visualization.Table(document.getElementById('table'));
> > visualization.draw(data, {}); // empty options == "{}" don't better
> use
> > null.
> > // Create and draw the visualization.
> > new
> >
> google.visualization.ColumnChart(document.getElementById('chart_div')).draw(data,
> > {width: 300, height: 200});
> > }
> > google.setOnLoadCallback(drawVisualization);
> > </script>
> > </head>
> > <body>
> > <div id="table"></div>
> > <div id="chart_div"></div>
> > </body>
> > </html>
> >
> > 2009/4/7 Ned <[email protected]>
> >
> >
> >
> >
> >
> > > I'm trying to output the following data to the screen as both a table
> > > and a chart. When I try this, I get the table fine, but the Chart
> > > appears without any bars (the y-axis goes from 0 to 1 without any bars
> > > in the graph). Is there something I'm doing wrong when trying to
> > > output the chart?
> >
> > > <script type="text/javascript" src="http://www.google.com/jsapi"></
> > > script>
> > > <script type="text/javascript">
> > > google.load('visualization', '1', {packages: ['table']});
> > > google.load('visualization', '1', {packages: ['columnchart']});
> > > </script>
> > > <script type="text/javascript">
> > > function drawVisualization() {
> > > // Create and populate the data table.
> > > var JSONObject = {cols: [{id: 'ActivityDate', label:
> > > 'ActivityDate', type: 'string'},{id: 'Count', label: 'Count', type:
> > > 'number'}], rows: [{c: [{v: 'DateA'},{v: '130'}]},{c: [{v: 'DateB'},
> > > {v: '255'}]},{c: [{v: 'DateC'},{v: '380'}]}]};
> >
> > > var data = new google.visualization.DataTable(JSONObject);
> >
> > > // Create and draw the visualization.
> > > visualization = new google.visualization.Table
> > > (document.getElementById('table'));
> > > visualization.draw(data, null);
> >
> > > // Create and draw the visualization.
> > > new google.visualization.ColumnChart(document.getElementById
> > > ('chart_div')).
> > > draw(data, null);
> >
> > > }
> >
> > > google.setOnLoadCallback(drawVisualization);
> > > </script>
> >
> > > Thanks!
> >
> > --
> > С уважением,
> > Максим Барбул
> >
>
--
С уважением,
Максим Барбул
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en
-~----------~----~----~----~------~----~------~--~---