Dashboard sipadu mbip
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.

chart-sparkline.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. "use strict";
  2. $(document).ready(function() {
  3. /*Line*/
  4. setTimeout(function(){
  5. $(".linechart").sparkline([5, 6, 7, 9, 9, 5, 3, 2, 2, 4, 6, 7], {
  6. type: 'line',
  7. width: '100%',
  8. height: '300px',
  9. tooltipClassname: 'chart-sparkline',
  10. lineColor: 'rgba(255, 82, 82, 0.92)',
  11. fillColor: 'rgba(255, 82, 82, 0.50)',
  12. spotColor: '#bdc3c7'
  13. });
  14. /*Bar*/
  15. $(".barchart").sparkline([5, 2, 2, 4, 9, 5, 7, 5, 2, 2, 6], {
  16. type: 'bar',
  17. barWidth: '40px',
  18. height: '300px',
  19. tooltipClassname: 'chart-sparkline',
  20. barColor: 'rgba(17, 193, 91, 0.80)'
  21. });
  22. /*Pie*/
  23. $(".piechart").sparkline([1, 1, 2, 2], {
  24. type: 'pie',
  25. width: '100%',
  26. height: '300px',
  27. sliceColors: ['#ff5252','#448aff','#11c15b','#536dfe'],
  28. tooltipClassname: 'chart-sparkline'
  29. });
  30. /*Mouse Speed*/
  31. var mrefreshinterval = 500; // update display every 500ms
  32. var lastmousex = -1;
  33. var lastmousey = -1;
  34. var lastmousetime;
  35. var mousetravel = 0;
  36. var mpoints = [];
  37. var mpoints_max = 30;
  38. $('body').mousemove(function(e) {
  39. var mousex = e.pageX;
  40. var mousey = e.pageY;
  41. if (lastmousex > -1)
  42. mousetravel += Math.max(Math.abs(mousex - lastmousex), Math.abs(mousey - lastmousey));
  43. lastmousex = mousex;
  44. lastmousey = mousey;
  45. });
  46. var mdraw = function() {
  47. var md = new Date();
  48. var timenow = md.getTime();
  49. if (lastmousetime && lastmousetime != timenow) {
  50. var pps = Math.round(mousetravel / (timenow - lastmousetime) * 1000);
  51. mpoints.push(pps);
  52. if (mpoints.length > mpoints_max)
  53. mpoints.splice(0, 1);
  54. mousetravel = 0;
  55. var mouse_wid = $('#mousespeed').parent('.card-block').parent().width();
  56. var a = mpoints - mouse_wid;
  57. $('#mousespeed').sparkline(mpoints, {
  58. width: '100%',
  59. height: '300px',
  60. tooltipClassname: 'chart-sparkline',
  61. tooltipSuffix: 'pixels per second',
  62. lineColor: 'rgb(83, 109, 254)',
  63. fillColor: 'rgba(83, 109, 254, 0.38)'
  64. });
  65. }
  66. lastmousetime = timenow;
  67. mtimer = setTimeout(mdraw, mrefreshinterval);
  68. }
  69. var mtimer = setTimeout(mdraw, mrefreshinterval); // We could use setInterval instead, but I prefer To Do it this way
  70. $.sparkline_display_visible();
  71. /*custom line chart*/
  72. $(".customchart").sparkline([15, 30, 27, 35, 50, 71, 60], {
  73. type: 'line',
  74. width: '100%',
  75. height: '300px',
  76. tooltipClassname: 'chart-sparkline',
  77. chartRangeMax: '50',
  78. lineColor: '#11c15b',
  79. fillColor: '#11c15b'
  80. });
  81. $(".customchart").sparkline([0, 5, 10, 7, 25, 35, 30], {
  82. type: 'line',
  83. width: '100%',
  84. height: '300px',
  85. composite: '!0',
  86. tooltipClassname: 'chart-sparkline',
  87. chartRangeMax: '40',
  88. lineColor: '#448aff',
  89. fillColor: '#448aff'
  90. });
  91. /* Tristate chart */
  92. $(".tristate").sparkline([1, 1, 0, 1, -1, -1, 1, -1, 0, 0, 1, 1], {
  93. type: 'tristate',
  94. height: '300',
  95. posBarColor: '#448aff',
  96. negBarColor: '#11c15b',
  97. zeroBarColor: '#ff5252',
  98. barWidth: 30
  99. });
  100. },350);
  101. });