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.

dashboard.js 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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], {
  87. width: 80,
  88. height: 50,
  89. lineColor: '#92c1dc',
  90. endColor: '#ebf4f9'
  91. })
  92. var sparkline2 = new Sparkline($('#sparkline-2')[0], {
  93. width: 80,
  94. height: 50,
  95. lineColor: '#92c1dc',
  96. endColor: '#ebf4f9'
  97. })
  98. var sparkline3 = new Sparkline($('#sparkline-3')[0], {
  99. width: 80,
  100. height: 50,
  101. lineColor: '#92c1dc',
  102. endColor: '#ebf4f9'
  103. })
  104. sparkline1.draw([1000, 1200, 920, 927, 931, 1027, 819, 930, 1021])
  105. sparkline2.draw([515, 519, 520, 522, 652, 810, 370, 627, 319, 630, 921])
  106. sparkline3.draw([15, 19, 20, 22, 33, 27, 31, 27, 19, 30, 21])
  107. // The Calender
  108. $('#calendar').datetimepicker({
  109. format: 'L',
  110. inline: true
  111. })
  112. // SLIMSCROLL FOR CHAT WIDGET
  113. $('#chat-box').overlayScrollbars({
  114. height: '250px'
  115. })
  116. /* Chart.js Charts */
  117. // Sales chart
  118. var salesChartCanvas = document.getElementById('revenue-chart-canvas').getContext('2d')
  119. // $('#revenue-chart').get(0).getContext('2d');
  120. var salesChartData = {
  121. labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
  122. datasets: [
  123. {
  124. label: 'Digital Goods',
  125. backgroundColor: 'rgba(60,141,188,0.9)',
  126. borderColor: 'rgba(60,141,188,0.8)',
  127. pointRadius: false,
  128. pointColor: '#3b8bba',
  129. pointStrokeColor: 'rgba(60,141,188,1)',
  130. pointHighlightFill: '#fff',
  131. pointHighlightStroke: 'rgba(60,141,188,1)',
  132. data: [28, 48, 40, 19, 86, 27, 90]
  133. },
  134. {
  135. label: 'Electronics',
  136. backgroundColor: 'rgba(210, 214, 222, 1)',
  137. borderColor: 'rgba(210, 214, 222, 1)',
  138. pointRadius: false,
  139. pointColor: 'rgba(210, 214, 222, 1)',
  140. pointStrokeColor: '#c1c7d1',
  141. pointHighlightFill: '#fff',
  142. pointHighlightStroke: 'rgba(220,220,220,1)',
  143. data: [65, 59, 80, 81, 56, 55, 40]
  144. }
  145. ]
  146. }
  147. var salesChartOptions = {
  148. maintainAspectRatio: false,
  149. responsive: true,
  150. legend: {
  151. display: false
  152. },
  153. scales: {
  154. xAxes: [{
  155. gridLines: {
  156. display: false
  157. }
  158. }],
  159. yAxes: [{
  160. gridLines: {
  161. display: false
  162. }
  163. }]
  164. }
  165. }
  166. // This will get the first returned node in the jQuery collection.
  167. // eslint-disable-next-line no-unused-vars
  168. var salesChart = new Chart(salesChartCanvas, { // lgtm[js/unused-local-variable]
  169. type: 'line',
  170. data: salesChartData,
  171. options: salesChartOptions
  172. })
  173. // Donut Chart
  174. var pieChartCanvas = $('#sales-chart-canvas').get(0).getContext('2d')
  175. var pieData = {
  176. labels: [
  177. 'Instore Sales',
  178. 'Download Sales',
  179. 'Mail-Order Sales'
  180. ],
  181. datasets: [
  182. {
  183. data: [30, 12, 20],
  184. backgroundColor: ['#f56954', '#00a65a', '#f39c12']
  185. }
  186. ]
  187. }
  188. var pieOptions = {
  189. legend: {
  190. display: false
  191. },
  192. maintainAspectRatio: false,
  193. responsive: true
  194. }
  195. // Create pie or douhnut chart
  196. // You can switch between pie and douhnut using the method below.
  197. // eslint-disable-next-line no-unused-vars
  198. var pieChart = new Chart(pieChartCanvas, { // lgtm[js/unused-local-variable]
  199. type: 'doughnut',
  200. data: pieData,
  201. options: pieOptions
  202. })
  203. // Sales graph chart
  204. var salesGraphChartCanvas = $('#line-chart').get(0).getContext('2d')
  205. // $('#revenue-chart').get(0).getContext('2d');
  206. var salesGraphChartData = {
  207. labels: ['2011 Q1', '2011 Q2', '2011 Q3', '2011 Q4', '2012 Q1', '2012 Q2', '2012 Q3', '2012 Q4', '2013 Q1', '2013 Q2'],
  208. datasets: [
  209. {
  210. label: 'Digital Goods',
  211. fill: false,
  212. borderWidth: 2,
  213. lineTension: 0,
  214. spanGaps: true,
  215. borderColor: '#efefef',
  216. pointRadius: 3,
  217. pointHoverRadius: 7,
  218. pointColor: '#efefef',
  219. pointBackgroundColor: '#efefef',
  220. data: [2666, 2778, 4912, 3767, 6810, 5670, 4820, 15073, 10687, 8432]
  221. }
  222. ]
  223. }
  224. var salesGraphChartOptions = {
  225. maintainAspectRatio: false,
  226. responsive: true,
  227. legend: {
  228. display: false
  229. },
  230. scales: {
  231. xAxes: [{
  232. ticks: {
  233. fontColor: '#efefef'
  234. },
  235. gridLines: {
  236. display: false,
  237. color: '#efefef',
  238. drawBorder: false
  239. }
  240. }],
  241. yAxes: [{
  242. ticks: {
  243. stepSize: 5000,
  244. fontColor: '#efefef'
  245. },
  246. gridLines: {
  247. display: true,
  248. color: '#efefef',
  249. drawBorder: false
  250. }
  251. }]
  252. }
  253. }
  254. // This will get the first returned node in the jQuery collection.
  255. // eslint-disable-next-line no-unused-vars
  256. var salesGraphChart = new Chart(salesGraphChartCanvas, { // lgtm[js/unused-local-variable]
  257. type: 'line',
  258. data: salesGraphChartData,
  259. options: salesGraphChartOptions
  260. })
  261. })