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.

88 lines
1.9 KiB

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