我能够使用以下代码完成此操作(感谢dinjas):
<html> <head> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript"> google.load('visualization', '1', {'packages':['corechart']}); google.setonLoadCallback(drawChart); function drawChart() { var json; $.ajax({ url: 'http://localhost:9200/wcs/routes/_search', type: 'POST', data: JSON.stringify( { "query" : { "match_all" : {} } }), dataType : 'json', async: false, success: function(data){ json = data; } })var jdata = {};jdata.cols = [ { "id": "", "label": "Lane", "type": "string" }, { "id": "", "label": "Routes", "type":"number" }];//need loop:jdata.rows = [ { "c": [ { "v": json.hits.hits[0]._source.lane }, { "v": json.hits.hits[0]._source.routes } ] }]; var data = new google.visualization.DataTable(jdata); var chart = new google.visualization.PieChart(document.getElementById('piechart_div')); chart.draw(data, {is3D: true, title: 'Multi Routes per Lane', width: 600, height: 440}); } </script></head><body> <div id="piechart_div"> </div> </body></html>


