You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.1 KiB

  1. function collectEventSeries(data) {
  2. var events = data.events;
  3. var series = {
  4. "application_launched_with_location": {
  5. name: "Launched with Location",
  6. color: '#42C093',
  7. y: 90,
  8. data: []
  9. },
  10. "visit": {
  11. name: "Visit",
  12. type: 'scatter',
  13. color: '#8f799e',
  14. y: 80,
  15. data: []
  16. },
  17. "paused_location_updates": {
  18. name: "Paused Location Updates",
  19. color: '#a0876e',
  20. y: 70,
  21. data: []
  22. },
  23. "resumed_location_updates": {
  24. name: "Resumed Location Updates",
  25. color: '#819e73',
  26. y: 60,
  27. data: []
  28. },
  29. "exited_pause_region": {
  30. name: "Exited Pause Region",
  31. color: '#819e73',
  32. y: 50,
  33. data: []
  34. },
  35. "did_finish_deferred_updates": {
  36. name: "Finished Deferred Updates",
  37. color: '#9ea06e',
  38. y: 40,
  39. data: []
  40. },
  41. "did_enter_background": {
  42. name: "Entered Background",
  43. color: '#799b9e',
  44. y: 30,
  45. data: []
  46. },
  47. "will_resign_active": {
  48. name: "Will Resign Active",
  49. color: '#737f9e',
  50. y: 20,
  51. data: []
  52. },
  53. "will_terminate": {
  54. name: "Will Terminate",
  55. color: '#9e7773',
  56. y: 10,
  57. data: []
  58. }
  59. };
  60. for(var i=0; i<events.length; i++) {
  61. if(series[events[i].properties.action]) {
  62. series[events[i].properties.action].data.push({
  63. x: new Date(events[i].properties.unixtime*1000),
  64. y: series[events[i].properties.action].y,
  65. location: (events[i].geometry ? events[i].geometry.coordinates : null)
  66. });
  67. }
  68. }
  69. var response = [];
  70. series = Object.values(series);
  71. for(var i=0; i<series.length; i++) {
  72. if(series[i].data.length > 0) {
  73. series[i].type = 'scatter';
  74. series[i].yAxis = 0;
  75. series[i].tooltip = {
  76. pointFormatter: function() {
  77. moveMarkerToPosition(this);
  78. var h = this.x.getHours();
  79. var m = this.x.getMinutes();
  80. var s = this.x.getSeconds();
  81. if(m < 10) m = '0'+m;
  82. if(s < 10) s = '0'+s;
  83. return h+':'+m+':'+s;
  84. }
  85. };
  86. response.push(series[i]);
  87. }
  88. }
  89. return response;
  90. }