Guest User

Untitled

a guest
Apr 22nd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. google.visualization.events.addListener(chart1, 'ready', function () {
  2. alert("3");
  3. // grab a few details before redirecting
  4. google.visualization.events.addListener(chart.getChart(), 'select', function () {
  5. chartObject = chart.getChart();
  6. alert(data.getValue(chartObject.getSelection()[0].row, 0));
  7. });
  8. });
  9.  
  10. var app = angular.module('myApp', []);
  11. app.controller('myController', ['$scope', '$http', function ($scope, $http) {
  12. //alert("dddd");
  13. // window.alert("hi!");
  14. //here http get method for get data from database
  15. $scope.chartData = [['Name', 'ReportsTo', 'tooltip']];
  16. $http.get('/home/getChartData').then(function (response) {
  17. var newobject = [['Name', 'ReportsTo', 'tooltip']];
  18. angular.forEach(response.data, function (val) {
  19. newobject.push(
  20. [
  21. {
  22. v: val.EmployeeID.toString(),
  23. f: '<div class="customBox"><div>' + (val.FirstName + ' '
  24. + val.LastName) +
  25. '</div><div class="title" id="' + val.EmployeeID + '">'
  26. + val.Title + '</div></div>'
  27. },
  28. (val.ReportsTo.toString() == "0" ? "" : val.ReportsTo.toString()),
  29. (val.FirstName + ' ' + val.LastName)
  30. ]
  31. );
  32. })
  33. $scope.chartData = newobject;
  34. })
  35. }])
  36. app.directive('orgChart', function () {
  37.  
  38. function link($scope, element, attrs) {
  39. var chart = new google.visualization.OrgChart(element[0]);
  40. $scope.$watch('chartData', function (value, oldvalue) {
  41.  
  42. if (!value) {
  43. return;
  44. }
  45. var data = google.visualization.arrayToDataTable(value);
  46. var options = {
  47. 'title': '',
  48. 'allowHtml': true
  49. }
  50. chart.draw(data, options);
  51. })
  52. }
  53. return {
  54. link: link
  55. };
  56. })
  57.  
  58. var chart = new google.visualization.OrgChart(element[0]);
  59.  
  60. google.visualization.events.addListener(chart, 'select', function () {
  61. var selection = chart.getSelection();
  62. if (selection.length > 0) {
  63. alert(data.getValue(selection[0].row, 0));
  64. }
  65. });
Add Comment
Please, Sign In to add comment