I found the solution in another thread...  Conversion of the JSON
string to an object must be done with the following changes:

var JSONObject = eval('(' + JSONstring + ')');

Because the documentation only shows hard coded, object literal
notation, it is also not clear how the JSON string should be
formatted, particularly with respect to "c", "v", and "f" elements.
They must be within double quotes.  The documentation is seriously
lacking with respect to creation of JSON datasets which are then
passed to DataTable upon instantiation.

The manipulation of data using the alternative (creating an empty
DataTable and adding rows via JavaScript) DataTable) methods and array
variables mentioned above could use some documentation, if not bug
fixes...

>
> $(document).ready ( function loadScript(){
>
>         //here's how my string is made available, and I verify it is
> there
>          var JSONstring =  new String($
> ('#treeMapData').children("input[name='treeDataString']").val());
>
>         //converting to object
>          var JSONObject = eval(JSONstring);
>          // also tried this...
>          //  var JSONObject = new Object(JSONstring.toSource());
>
>          // instantiation appears unsuccessful
>          var data = new google.visualization.DataTable(JSONObject);
>
>          //this returns zero "0"
>          alert(data.getNumberOfRows());
>
>        // Create and draw the visualization.  one day, hopefully
>
>          var tree = new
> google.visualization.TreeMap(document.getElementById('visualization'));
>          tree.draw(data, {
>            minColor: '#f00',
>            midColor: '#ddd',
>            maxColor: '#0d0',
>            headerHeight: 15,
>            fontColor: 'black',
>            showScale: true});
>
>     });

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

Reply via email to