matrix.dashboard.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. $(document).ready(function(){
  2. // === Prepare peity charts === //
  3. maruti.peity();
  4. // === Prepare the chart data ===/
  5. var sin = [], cos = [];
  6. for (var i = 0; i < 14; i += 0.5) {
  7. sin.push([i, Math.sin(i)]);
  8. cos.push([i, Math.cos(i)]);
  9. }
  10. // === Make chart === //
  11. var plot = $.plot($(".chart"),
  12. [ { data: sin, label: "sin(x)", color: "#ee7951"}, { data: cos, label: "cos(x)",color: "#4fb9f0" } ], {
  13. series: {
  14. lines: { show: true },
  15. points: { show: true }
  16. },
  17. grid: { hoverable: true, clickable: true },
  18. yaxis: { min: -1.6, max: 1.6 }
  19. });
  20. // === Point hover in chart === //
  21. var previousPoint = null;
  22. $(".chart").bind("plothover", function (event, pos, item) {
  23. if (item) {
  24. if (previousPoint != item.dataIndex) {
  25. previousPoint = item.dataIndex;
  26. $('#tooltip').fadeOut(200,function(){
  27. $(this).remove();
  28. });
  29. var x = item.datapoint[0].toFixed(2),
  30. y = item.datapoint[1].toFixed(2);
  31. maruti.flot_tooltip(item.pageX, item.pageY,item.series.label + " of " + x + " = " + y);
  32. }
  33. } else {
  34. $('#tooltip').fadeOut(200,function(){
  35. $(this).remove();
  36. });
  37. previousPoint = null;
  38. }
  39. });
  40. // === Calendar === //
  41. var date = new Date();
  42. var d = date.getDate();
  43. var m = date.getMonth();
  44. var y = date.getFullYear();
  45. $('.calendar').fullCalendar({
  46. header: {
  47. left: 'prev,next',
  48. center: 'title',
  49. right: 'month,basicWeek,basicDay'
  50. },
  51. editable: true,
  52. events: [
  53. {
  54. title: 'All day event',
  55. start: new Date(y, m, 1)
  56. },
  57. {
  58. title: 'Long event',
  59. start: new Date(y, m, 5),
  60. end: new Date(y, m, 8)
  61. },
  62. {
  63. id: 999,
  64. title: 'Repeating event',
  65. start: new Date(y, m, 2, 16, 0),
  66. end: new Date(y, m, 3, 18, 0),
  67. allDay: false
  68. },
  69. {
  70. id: 999,
  71. title: 'Repeating event',
  72. start: new Date(y, m, 9, 16, 0),
  73. end: new Date(y, m, 10, 18, 0),
  74. allDay: false
  75. },
  76. {
  77. title: 'Lunch',
  78. start: new Date(y, m, 14, 12, 0),
  79. end: new Date(y, m, 15, 14, 0),
  80. allDay: false
  81. },
  82. {
  83. title: 'Birthday PARTY',
  84. start: new Date(y, m, 18),
  85. end: new Date(y, m, 20),
  86. allDay: false
  87. },
  88. {
  89. title: 'Click for Google',
  90. start: new Date(y, m, 27),
  91. end: new Date(y, m, 29),
  92. url: 'http://www.google.com'
  93. }
  94. ]
  95. });
  96. });
  97. maruti = {
  98. // === Peity charts === //
  99. peity: function(){
  100. $.fn.peity.defaults.line = {
  101. strokeWidth: 1,
  102. delimeter: ",",
  103. height: 24,
  104. max: null,
  105. min: 0,
  106. width: 50
  107. };
  108. $.fn.peity.defaults.bar = {
  109. delimeter: ",",
  110. height: 24,
  111. max: null,
  112. min: 0,
  113. width: 50
  114. };
  115. $(".peity_line_good span").peity("line", {
  116. colour: "#57a532",
  117. strokeColour: "#459D1C"
  118. });
  119. $(".peity_line_bad span").peity("line", {
  120. colour: "#FFC4C7",
  121. strokeColour: "#BA1E20"
  122. });
  123. $(".peity_line_neutral span").peity("line", {
  124. colour: "#CCCCCC",
  125. strokeColour: "#757575"
  126. });
  127. $(".peity_bar_good span").peity("bar", {
  128. colour: "#459D1C"
  129. });
  130. $(".peity_bar_bad span").peity("bar", {
  131. colour: "#BA1E20"
  132. });
  133. $(".peity_bar_neutral span").peity("bar", {
  134. colour: "#4fb9f0"
  135. });
  136. },
  137. // === Tooltip for flot charts === //
  138. flot_tooltip: function(x, y, contents) {
  139. $('<div id="tooltip">' + contents + '</div>').css( {
  140. top: y + 5,
  141. left: x + 5
  142. }).appendTo("body").fadeIn(200);
  143. }
  144. }