Hi,

I want to use the moution chart using JSON like bridge for the data.
In the server side I´m using Java, more specific Seam. I have
@WebRemote annotated method that return String. This method can be
called from javascript directly.

This is the string that returns the method:

{
    "cols":[
             {label: 'Name', type:'string'},
             {label: 'Date', type:'datetime'},
             {label: 'Visit', type:'number'},
             {label: 'Social network', type:'string'}
           ],
     "rows":[
             {c:[{v: 'Test1'}, {v: new Date(2012,02,02)},{v:234},
{v:'Facebook'}]},
             {c:[{v: 'Test2'}, {v: new Date(2012,02,02)},{v:764},
{v:'Twitter'}]},
             {c:[{v: 'Test3'}, {v: new Date(2012,02,02)},{v:111},
{v:'Facebook'}]}
            ]
   }


This is the code that use tho show the chart:
...
  function callServer() {
 
Seam.Component.getInstance('statistic').loadDataMoutionChart(drawChartCallback);
  }

  function drawChartCallback(stringJSON) {

      var JSONObject = stringJSON;
      var data = new google.visualization.DataTable(JSONObject , 0.6);

      var motionchart = new google.visualization.MotionChart(
              document.getElementById('div'));
          motionchart.draw(data, {'width': 800, 'height': 400});
  }
...


I cant display the chart. I think the problem comes beacouse the
"DataTable(JSONObject , 0.6)" constructor need real JSONObject. I
tryed to use the jQuery.parseJSON without success.

If I use directly the returned json string is working well, and the
chart is displayed:
...
var JSONObject = {
    "cols":[
             {label: 'Name', type:'string'},
             {label: 'Date', type:'datetime'},
             {label: 'Visit', type:'number'},
             {label: 'Social network', type:'string'}
           ],
     "rows":[
             {c:[{v: 'Test1'}, {v: new Date(2012,02,02)},{v:234},
{v:'Facebook'}]},
             {c:[{v: 'Test2'}, {v: new Date(2012,02,02)},{v:764},
{v:'Twitter'}]},
             {c:[{v: 'Test3'}, {v: new Date(2012,02,02)},{v:111},
{v:'Facebook'}]}
            ]
   };
    var data = new google.visualization.DataTable( JSONObject, 0.6);

    var table = new
google.visualization.Table(document.getElementById('div'));
    table.draw(data, {showRowNumber: true});
....


How can I properly pass to DataTable the requiered JSONObject?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Chart 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-chart-api?hl=en.

Reply via email to