Guest User

Untitled

a guest
Jul 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. function createDashboard4() {
  2. var json_results = getData('http://localhost:9999/countcarbytype')
  3. data_results = []
  4. var Header = ['car Type', 'count', 'region',{'type': 'string', 'role': 'tooltip', 'p': {'html': true}}];
  5. data_results.push(Header)
  6. for (var i = 0; i < json_results.length; i++) {
  7. var value = json_results[i];
  8. var URL = ""+value["imageURL"][0]
  9.  
  10. data_results.push([value["_id"]["title"], value["countofcars"], value["_id"]["region"]],createCustomHTMLContent(URL,value["_id"]["title"], value["countofcars"], value["_id"]["region"]))
  11. }
  12. console.log(data_results)
  13. var data = google.visualization.arrayToDataTable(data_results);
  14.  
  15.  
  16. // Define a StringFilter control for the 'Name' column
  17. var stringFilter = new google.visualization.ControlWrapper({
  18. 'controlType': 'StringFilter',
  19. 'containerId': 'control4',
  20. 'options': {
  21. 'filterColumnLabel': 'region'
  22. }
  23. });
  24.  
  25. // Define a table visualization
  26. var table = new google.visualization.ChartWrapper({
  27. 'chartType': 'BarChart',
  28. 'containerId': 'chart4',
  29. 'options': { 'height': 400, 'width': 500, 'title': 'Count of cars by Model Type', 'legend': 'none','tooltip': { isHtml: true } },
  30. 'view': { 'columns': [0, 1] }
  31. });
  32.  
  33. // Create the dashboard.
  34. var dashboard = new google.visualization.Dashboard(document.getElementById('dashboard')).
  35. // Configure the string filter to affect the table contents
  36. bind(stringFilter, table).
  37. // Draw the dashboard
  38. draw(data);
  39.  
  40. return stringFilter;
  41. }
  42.  
  43. google.setOnLoadCallback(drawVisualization);
  44.  
  45. function createCustomHTMLContent(imageURL, title, totalCount, region) {
  46. return '<div style="padding:5px 5px 5px 5px;">' +
  47. '<img src="' + imageURL + '" style="width:75px;height:50px"><br/>' +
  48. '<table class="medals_layout">' + '<tr>' +
  49. '<td><img src="https://upload.wikimedia.org/wikipedia/commons/1/15/Gold_medal.svg" style="width:25px;height:25px"/></td>' +
  50. '<td><b>' + title + '</b></td>' + '</tr>' + '<tr>' +
  51. '<td><img src="https://upload.wikimedia.org/wikipedia/commons/1/15/Gold_medal.svg" style="width:25px;height:25px"/></td>' +
  52. '<td><b>' + totalCount + '</b></td>' + '</tr>' + '<tr>' +
  53. '<td><img src="https://upload.wikimedia.org/wikipedia/commons/5/52/Bronze_medal.svg" style="width:25px;height:25px"/></td>' +
  54. '<td><b>' + region + '</b></td>' + '</tr>' + '</table>' + '</div>';
  55. }
Add Comment
Please, Sign In to add comment