dashboard.js 7.4 KB

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