dashboard.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /*
  2. * Author: Abdullah A Almsaeed
  3. * Date: 4 Jan 2014
  4. * Description:
  5. * This is a demo file used only for the main dashboard (index.html)
  6. **/
  7. /* global moment:false, Chart:false, Sparkline:false */
  8. $(function () {
  9. 'use strict'
  10. // Make the dashboard widgets sortable Using jquery UI
  11. $('.connectedSortable').sortable({
  12. placeholder: 'sort-highlight',
  13. connectWith: '.connectedSortable',
  14. handle: '.card-header, .nav-tabs',
  15. forcePlaceholderSize: true,
  16. zIndex: 999999
  17. })
  18. $('.connectedSortable .card-header').css('cursor', 'move')
  19. // jQuery UI sortable for the todo list
  20. $('.todo-list').sortable({
  21. placeholder: 'sort-highlight',
  22. handle: '.handle',
  23. forcePlaceholderSize: true,
  24. zIndex: 999999
  25. })
  26. // bootstrap WYSIHTML5 - text editor
  27. $('.textarea').summernote()
  28. $('.daterange').daterangepicker({
  29. ranges: {
  30. Today: [moment(), moment()],
  31. Yesterday: [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
  32. 'Last 7 Days': [moment().subtract(6, 'days'), moment()],
  33. 'Last 30 Days': [moment().subtract(29, 'days'), moment()],
  34. 'This Month': [moment().startOf('month'), moment().endOf('month')],
  35. 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
  36. },
  37. startDate: moment().subtract(29, 'days'),
  38. endDate: moment()
  39. }, function (start, end) {
  40. // eslint-disable-next-line no-alert
  41. alert('You chose: ' + start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'))
  42. })
  43. /* jQueryKnob */
  44. $('.knob').knob()
  45. // jvectormap data
  46. var visitorsData = {
  47. US: 398, // USA
  48. SA: 400, // Saudi Arabia
  49. CA: 1000, // Canada
  50. DE: 500, // Germany
  51. FR: 760, // France
  52. CN: 300, // China
  53. AU: 700, // Australia
  54. BR: 600, // Brazil
  55. IN: 800, // India
  56. GB: 320, // Great Britain
  57. RU: 3000 // Russia
  58. }
  59. // World map by jvectormap
  60. $('#world-map').vectorMap({
  61. map: 'usa_en',
  62. backgroundColor: 'transparent',
  63. regionStyle: {
  64. initial: {
  65. fill: 'rgba(255, 255, 255, 0.7)',
  66. 'fill-opacity': 1,
  67. stroke: 'rgba(0,0,0,.2)',
  68. 'stroke-width': 1,
  69. 'stroke-opacity': 1
  70. }
  71. },
  72. series: {
  73. regions: [{
  74. values: visitorsData,
  75. scale: ['#ffffff', '#0154ad'],
  76. normalizeFunction: 'polynomial'
  77. }]
  78. },
  79. onRegionLabelShow: function (e, el, code) {
  80. if (typeof visitorsData[code] !== 'undefined') {
  81. el.html(el.html() + ': ' + visitorsData[code] + ' new visitors')
  82. }
  83. }
  84. })
  85. // Sparkline charts
  86. var sparkline1 = new Sparkline($('#sparkline-1')[0], { width: 80, height: 50, lineColor: '#92c1dc', endColor: '#ebf4f9' })
  87. var sparkline2 = new Sparkline($('#sparkline-2')[0], { width: 80, height: 50, lineColor: '#92c1dc', endColor: '#ebf4f9' })
  88. var sparkline3 = new Sparkline($('#sparkline-3')[0], { width: 80, height: 50, lineColor: '#92c1dc', endColor: '#ebf4f9' })
  89. sparkline1.draw([1000, 1200, 920, 927, 931, 1027, 819, 930, 1021])
  90. sparkline2.draw([515, 519, 520, 522, 652, 810, 370, 627, 319, 630, 921])
  91. sparkline3.draw([15, 19, 20, 22, 33, 27, 31, 27, 19, 30, 21])
  92. // The Calender
  93. $('#calendar').datetimepicker({
  94. format: 'L',
  95. inline: true
  96. })
  97. // SLIMSCROLL FOR CHAT WIDGET
  98. $('#chat-box').overlayScrollbars({
  99. height: '250px'
  100. })
  101. /* Chart.js Charts */
  102. // Sales chart
  103. var salesChartCanvas = document.getElementById('revenue-chart-canvas').getContext('2d')
  104. // $('#revenue-chart').get(0).getContext('2d');
  105. var salesChartData = {
  106. labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
  107. datasets: [
  108. {
  109. label: 'Digital Goods',
  110. backgroundColor: 'rgba(60,141,188,0.9)',
  111. borderColor: 'rgba(60,141,188,0.8)',
  112. pointRadius: false,
  113. pointColor: '#3b8bba',
  114. pointStrokeColor: 'rgba(60,141,188,1)',
  115. pointHighlightFill: '#fff',
  116. pointHighlightStroke: 'rgba(60,141,188,1)',
  117. data: [28, 48, 40, 19, 86, 27, 90]
  118. },
  119. {
  120. label: 'Electronics',
  121. backgroundColor: 'rgba(210, 214, 222, 1)',
  122. borderColor: 'rgba(210, 214, 222, 1)',
  123. pointRadius: false,
  124. pointColor: 'rgba(210, 214, 222, 1)',
  125. pointStrokeColor: '#c1c7d1',
  126. pointHighlightFill: '#fff',
  127. pointHighlightStroke: 'rgba(220,220,220,1)',
  128. data: [65, 59, 80, 81, 56, 55, 40]
  129. }
  130. ]
  131. }
  132. var salesChartOptions = {
  133. maintainAspectRatio: false,
  134. responsive: true,
  135. legend: {
  136. display: false
  137. },
  138. scales: {
  139. xAxes: [{
  140. gridLines: {
  141. display: false
  142. }
  143. }],
  144. yAxes: [{
  145. gridLines: {
  146. display: false
  147. }
  148. }]
  149. }
  150. }
  151. // This will get the first returned node in the jQuery collection.
  152. // eslint-disable-next-line no-unused-vars
  153. var salesChart = new Chart(salesChartCanvas, { // lgtm[js/unused-local-variable]
  154. type: 'line',
  155. data: salesChartData,
  156. options: salesChartOptions
  157. })
  158. // Donut Chart
  159. var pieChartCanvas = $('#sales-chart-canvas').get(0).getContext('2d')
  160. var pieData = {
  161. labels: [
  162. 'Instore Sales',
  163. 'Download Sales',
  164. 'Mail-Order Sales'
  165. ],
  166. datasets: [
  167. {
  168. data: [30, 12, 20],
  169. backgroundColor: ['#f56954', '#00a65a', '#f39c12']
  170. }
  171. ]
  172. }
  173. var pieOptions = {
  174. legend: {
  175. display: false
  176. },
  177. maintainAspectRatio: false,
  178. responsive: true
  179. }
  180. // Create pie or douhnut chart
  181. // You can switch between pie and douhnut using the method below.
  182. // eslint-disable-next-line no-unused-vars
  183. var pieChart = new Chart(pieChartCanvas, { // lgtm[js/unused-local-variable]
  184. type: 'doughnut',
  185. data: pieData,
  186. options: pieOptions
  187. })
  188. // Sales graph chart
  189. var salesGraphChartCanvas = $('#line-chart').get(0).getContext('2d')
  190. // $('#revenue-chart').get(0).getContext('2d');
  191. var salesGraphChartData = {
  192. labels: ['2011 Q1', '2011 Q2', '2011 Q3', '2011 Q4', '2012 Q1', '2012 Q2', '2012 Q3', '2012 Q4', '2013 Q1', '2013 Q2'],
  193. datasets: [
  194. {
  195. label: 'Digital Goods',
  196. fill: false,
  197. borderWidth: 2,
  198. lineTension: 0,
  199. spanGaps: true,
  200. borderColor: '#efefef',
  201. pointRadius: 3,
  202. pointHoverRadius: 7,
  203. pointColor: '#efefef',
  204. pointBackgroundColor: '#efefef',
  205. data: [2666, 2778, 4912, 3767, 6810, 5670, 4820, 15073, 10687, 8432]
  206. }
  207. ]
  208. }
  209. var salesGraphChartOptions = {
  210. maintainAspectRatio: false,
  211. responsive: true,
  212. legend: {
  213. display: false
  214. },
  215. scales: {
  216. xAxes: [{
  217. ticks: {
  218. fontColor: '#efefef'
  219. },
  220. gridLines: {
  221. display: false,
  222. color: '#efefef',
  223. drawBorder: false
  224. }
  225. }],
  226. yAxes: [{
  227. ticks: {
  228. stepSize: 5000,
  229. fontColor: '#efefef'
  230. },
  231. gridLines: {
  232. display: true,
  233. color: '#efefef',
  234. drawBorder: false
  235. }
  236. }]
  237. }
  238. }
  239. // This will get the first returned node in the jQuery collection.
  240. // eslint-disable-next-line no-unused-vars
  241. var salesGraphChart = new Chart(salesGraphChartCanvas, { // lgtm[js/unused-local-variable]
  242. type: 'line',
  243. data: salesGraphChartData,
  244. options: salesGraphChartOptions
  245. })
  246. })