dashboard-lite.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*=========================================================================================
  2. File Name: dashboard-lite.js
  3. Description: intialize advance cards
  4. ----------------------------------------------------------------------------------------
  5. Item Name: Robust - Responsive Admin Theme
  6. Version: 1.2
  7. Author: GeeksLabs
  8. Author URL: http://www.themeforest.net/user/geekslabs
  9. ==========================================================================================*/
  10. (function(window, document, $) {
  11. 'use strict';
  12. /**********************************************************
  13. * Projects Task Status *
  14. **********************************************************/
  15. //Get the context of the Chart canvas element we want to select
  16. var ctx2 = $("#line-stacked-area");
  17. // Chart Options
  18. var userPageVisitOptions = {
  19. responsive: true,
  20. maintainAspectRatio: false,
  21. pointDotStrokeWidth : 4,
  22. legend: {
  23. display: false,
  24. labels: {
  25. fontColor: '#FFF',
  26. boxWidth: 10,
  27. },
  28. position: 'top',
  29. },
  30. hover: {
  31. mode: 'label'
  32. },
  33. scales: {
  34. xAxes: [{
  35. display: false,
  36. }],
  37. yAxes: [{
  38. display: true,
  39. gridLines: {
  40. color: "rgba(255,255,255, 0.3)",
  41. drawTicks: false,
  42. drawBorder: false
  43. },
  44. ticks: {
  45. display: false,
  46. min: 0,
  47. max: 70,
  48. maxTicksLimit: 4
  49. },
  50. }]
  51. },
  52. title: {
  53. display: false,
  54. text: 'Chart.js Line Chart - Legend'
  55. },
  56. };
  57. /****************************************************
  58. * Employee Satisfaction *
  59. ****************************************************/
  60. //Get the context of the Chart canvas element we want to select
  61. var ctx1 = document.getElementById("emp-satisfaction").getContext("2d");
  62. // Create Linear Gradient
  63. var white_gradient = ctx1.createLinearGradient(0, 0, 0,400);
  64. white_gradient.addColorStop(0, 'rgba(255,255,255,0.5)');
  65. white_gradient.addColorStop(1, 'rgba(255,255,255,0)');
  66. // Chart Options
  67. var empSatOptions = {
  68. responsive: true,
  69. maintainAspectRatio: false,
  70. datasetStrokeWidth : 3,
  71. pointDotStrokeWidth : 4,
  72. tooltipFillColor: "rgba(0,0,0,0.8)",
  73. legend: {
  74. display: false,
  75. },
  76. hover: {
  77. mode: 'label'
  78. },
  79. scales: {
  80. xAxes: [{
  81. display: false,
  82. }],
  83. yAxes: [{
  84. display: false,
  85. ticks: {
  86. min: 0,
  87. max: 85
  88. },
  89. }]
  90. },
  91. title: {
  92. display: false,
  93. fontColor: "#FFF",
  94. fullWidth: false,
  95. fontSize: 40,
  96. text: '82%'
  97. }
  98. };
  99. // Chart Data
  100. var empSatData = {
  101. labels: ["January", "February", "March", "April", "May", "June", "July"],
  102. datasets: [{
  103. label: "Employees",
  104. data: [28, 35, 36, 48, 46, 42, 60],
  105. backgroundColor: white_gradient,
  106. borderColor: "rgba(255,255,255,1)",
  107. borderWidth: 2,
  108. strokeColor : "#ff6c23",
  109. pointColor : "#fff",
  110. pointBorderColor: "rgba(255,255,255,1)",
  111. pointBackgroundColor: "#3BAFDA",
  112. pointBorderWidth: 2,
  113. pointHoverBorderWidth: 2,
  114. pointRadius: 5,
  115. }]
  116. };
  117. var empSatconfig = {
  118. type: 'line',
  119. // Chart Options
  120. options : empSatOptions,
  121. // Chart Data
  122. data : empSatData
  123. };
  124. // Create the chart
  125. var areaChart = new Chart(ctx1, empSatconfig);
  126. // Chart Data
  127. var userPageVisitData = {
  128. labels: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
  129. datasets: [
  130. {
  131. label: "Android",
  132. data: [18, 15, 30, 25, 28, 35, 14, 18, 12, 20, 18, 24],
  133. backgroundColor: 'transparent',
  134. borderColor: "#FF6E40",
  135. pointColor : "#fff",
  136. pointBorderColor: "#FF6E40",
  137. pointBackgroundColor: "#fff",
  138. pointBorderWidth: 2,
  139. pointHoverBorderWidth: 2,
  140. pointRadius: 3,
  141. },{
  142. label: "iOS",
  143. data: [30, 35, 60, 40, 45, 55, 32, 45, 58, 53, 45, 60],
  144. backgroundColor: 'transparent',
  145. borderColor: "#1DE9B6",
  146. pointColor : "#fff",
  147. pointBorderColor: "#1DE9B6",
  148. pointBackgroundColor: "#fff",
  149. pointBorderWidth: 2,
  150. pointHoverBorderWidth: 2,
  151. pointRadius: 3,
  152. }]
  153. };
  154. var userPageVisitConfig = {
  155. type: 'line',
  156. // Chart Options
  157. options : userPageVisitOptions,
  158. // Chart Data
  159. data : userPageVisitData
  160. };
  161. // Create the chart
  162. var stackedAreaChart = new Chart(ctx2, userPageVisitConfig);
  163. // Live chart update random data for the new entry
  164. setInterval(function() {
  165. setStackedAreaChartData(stackedAreaChart.data.datasets[0].data, 5, 25);
  166. setStackedAreaChartData(stackedAreaChart.data.datasets[1].data, 35, 60);
  167. }, 3500);
  168. function setStackedAreaChartData(data, minValue, maxValue) {
  169. data.push(Math.floor(Math.random() * (maxValue - minValue + 1)) + minValue);
  170. data.shift();
  171. stackedAreaChart.update();
  172. }
  173. })(window, document, jQuery);