Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <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" src="https://www.gstatic.com/charts/loader.js"></script>
- <script type="text/javascript">
- google.charts.load('current', {'packages':['sankey']});
- google.charts.setOnLoadCallback(drawChart);
- function drawChart() {
- var json;
- $.ajax({
- //var req = $get.JSON({
- type: 'POST',
- url: 'http://localhost:9200/<my_index_name>/<type>/<id>/_source?pretty=true',
- data : JSON.stringify(
- {
- "query" : { "match_all" : {} }
- }),
- dataType : "jsonp",
- //cache: true,
- //async: false,
- success: function(data){
- json = data;
- console.log(JSON.parse(data));
- var jdata = {};
- jdata.cols = [
- {
- "id": "",
- "label": "col1",
- "type": "string"
- },
- {
- "id": "",
- "label": "col2",
- "type": "number"
- }
- ];
- //document.write("hello");
- //document.write(data);
- //need loop:
- jdata.rows = [
- {
- "c": [
- {
- "v": json.hits.hits[0]._source.col1
- },
- {
- "v": json.hits.hits[0]._source.col2
- }
- ]
- }
- ];
- 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>
Add Comment
Please, Sign In to add comment