dashboard2.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. $(function () {
  2. 'use strict'
  3. /* ChartJS
  4. * -------
  5. * Here we will create a few charts using ChartJS
  6. */
  7. //-----------------------
  8. //- MONTHLY SALES CHART -
  9. //-----------------------
  10. // Get context with jQuery - using jQuery's .get() method.
  11. var salesChartCanvas = $('#salesChart').get(0).getContext('2d')
  12. // This will get the first returned node in the jQuery collection.
  13. var salesChart = new Chart(salesChartCanvas)
  14. var salesChartData = {
  15. labels : ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
  16. datasets: [
  17. {
  18. label : 'Electronics',
  19. fillColor : '#dee2e6',
  20. strokeColor : '#ced4da',
  21. pointColor : '#ced4da',
  22. pointStrokeColor : '#c1c7d1',
  23. pointHighlightFill : '#fff',
  24. pointHighlightStroke: 'rgb(220,220,220)',
  25. data : [65, 59, 80, 81, 56, 55, 40]
  26. },
  27. {
  28. label : 'Digital Goods',
  29. fillColor : 'rgba(0, 123, 255, 0.9)',
  30. strokeColor : 'rgba(0, 123, 255, 1)',
  31. pointColor : '#3b8bba',
  32. pointStrokeColor : 'rgba(0, 123, 255, 1)',
  33. pointHighlightFill : '#fff',
  34. pointHighlightStroke: 'rgba(0, 123, 255, 1)',
  35. data : [28, 48, 40, 19, 86, 27, 90]
  36. }
  37. ]
  38. }
  39. var salesChartOptions = {
  40. //Boolean - If we should show the scale at all
  41. showScale : true,
  42. //Boolean - Whether grid lines are shown across the chart
  43. scaleShowGridLines : false,
  44. //String - Colour of the grid lines
  45. scaleGridLineColor : 'rgba(0,0,0,.05)',
  46. //Number - Width of the grid lines
  47. scaleGridLineWidth : 1,
  48. //Boolean - Whether to show horizontal lines (except X axis)
  49. scaleShowHorizontalLines: true,
  50. //Boolean - Whether to show vertical lines (except Y axis)
  51. scaleShowVerticalLines : true,
  52. //Boolean - Whether the line is curved between points
  53. bezierCurve : true,
  54. //Number - Tension of the bezier curve between points
  55. bezierCurveTension : 0.3,
  56. //Boolean - Whether to show a dot for each point
  57. pointDot : false,
  58. //Number - Radius of each point dot in pixels
  59. pointDotRadius : 4,
  60. //Number - Pixel width of point dot stroke
  61. pointDotStrokeWidth : 1,
  62. //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
  63. pointHitDetectionRadius : 20,
  64. //Boolean - Whether to show a stroke for datasets
  65. datasetStroke : true,
  66. //Number - Pixel width of dataset stroke
  67. datasetStrokeWidth : 2,
  68. //Boolean - Whether to fill the dataset with a color
  69. datasetFill : true,
  70. //String - A legend template
  71. legendTemplate : '<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].lineColor%>"></span><%=datasets[i].label%></li><%}%></ul>',
  72. //Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
  73. maintainAspectRatio : false,
  74. //Boolean - whether to make the chart responsive to window resizing
  75. responsive : true
  76. }
  77. //Create the line chart
  78. salesChart.Line(salesChartData, salesChartOptions)
  79. //---------------------------
  80. //- END MONTHLY SALES CHART -
  81. //---------------------------
  82. //-------------
  83. //- PIE CHART -
  84. //-------------
  85. // Get context with jQuery - using jQuery's .get() method.
  86. var pieChartCanvas = $('#pieChart').get(0).getContext('2d')
  87. var pieChart = new Chart(pieChartCanvas)
  88. var PieData = [
  89. {
  90. value : 700,
  91. color : '#dc3545',
  92. highlight: '#dc3545',
  93. label : 'Chrome'
  94. },
  95. {
  96. value : 500,
  97. color : '#28a745',
  98. highlight: '#28a745',
  99. label : 'IE'
  100. },
  101. {
  102. value : 400,
  103. color : '#ffc107',
  104. highlight: '#ffc107',
  105. label : 'FireFox'
  106. },
  107. {
  108. value : 600,
  109. color : '#17a2b8',
  110. highlight: '#17a2b8',
  111. label : 'Safari'
  112. },
  113. {
  114. value : 300,
  115. color : '#007bff',
  116. highlight: '#007bff',
  117. label : 'Opera'
  118. },
  119. {
  120. value : 100,
  121. color : '#6c757d',
  122. highlight: '#6c757d',
  123. label : 'Navigator'
  124. }
  125. ]
  126. var pieOptions = {
  127. //Boolean - Whether we should show a stroke on each segment
  128. segmentShowStroke : true,
  129. //String - The colour of each segment stroke
  130. segmentStrokeColor : '#fff',
  131. //Number - The width of each segment stroke
  132. segmentStrokeWidth : 1,
  133. //Number - The percentage of the chart that we cut out of the middle
  134. percentageInnerCutout: 50, // This is 0 for Pie charts
  135. //Number - Amount of animation steps
  136. animationSteps : 100,
  137. //String - Animation easing effect
  138. animationEasing : 'easeOutBounce',
  139. //Boolean - Whether we animate the rotation of the Doughnut
  140. animateRotate : true,
  141. //Boolean - Whether we animate scaling the Doughnut from the centre
  142. animateScale : false,
  143. //Boolean - whether to make the chart responsive to window resizing
  144. responsive : true,
  145. // Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
  146. maintainAspectRatio : false,
  147. //String - A legend template
  148. legendTemplate : '<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<segments.length; i++){%><li><span style="background-color:<%=segments[i].fillColor%>"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>',
  149. //String - A tooltip template
  150. tooltipTemplate : '<%=value %> <%=label%> users'
  151. }
  152. //Create pie or douhnut chart
  153. // You can switch between pie and douhnut using the method below.
  154. pieChart.Doughnut(PieData, pieOptions)
  155. //-----------------
  156. //- END PIE CHART -
  157. //-----------------
  158. /* jVector Maps
  159. * ------------
  160. * Create a world map with markers
  161. */
  162. $('#world-map-markers').vectorMap({
  163. map : 'world_mill_en',
  164. normalizeFunction: 'polynomial',
  165. hoverOpacity : 0.7,
  166. hoverColor : false,
  167. backgroundColor : 'transparent',
  168. regionStyle : {
  169. initial : {
  170. fill : 'rgba(210, 214, 222, 1)',
  171. 'fill-opacity' : 1,
  172. stroke : 'none',
  173. 'stroke-width' : 0,
  174. 'stroke-opacity': 1
  175. },
  176. hover : {
  177. 'fill-opacity': 0.7,
  178. cursor : 'pointer'
  179. },
  180. selected : {
  181. fill: 'yellow'
  182. },
  183. selectedHover: {}
  184. },
  185. markerStyle : {
  186. initial: {
  187. fill : '#00a65a',
  188. stroke: '#111'
  189. }
  190. },
  191. markers : [
  192. {
  193. latLng: [41.90, 12.45],
  194. name : 'Vatican City'
  195. },
  196. {
  197. latLng: [43.73, 7.41],
  198. name : 'Monaco'
  199. },
  200. {
  201. latLng: [-0.52, 166.93],
  202. name : 'Nauru'
  203. },
  204. {
  205. latLng: [-8.51, 179.21],
  206. name : 'Tuvalu'
  207. },
  208. {
  209. latLng: [43.93, 12.46],
  210. name : 'San Marino'
  211. },
  212. {
  213. latLng: [47.14, 9.52],
  214. name : 'Liechtenstein'
  215. },
  216. {
  217. latLng: [7.11, 171.06],
  218. name : 'Marshall Islands'
  219. },
  220. {
  221. latLng: [17.3, -62.73],
  222. name : 'Saint Kitts and Nevis'
  223. },
  224. {
  225. latLng: [3.2, 73.22],
  226. name : 'Maldives'
  227. },
  228. {
  229. latLng: [35.88, 14.5],
  230. name : 'Malta'
  231. },
  232. {
  233. latLng: [12.05, -61.75],
  234. name : 'Grenada'
  235. },
  236. {
  237. latLng: [13.16, -61.23],
  238. name : 'Saint Vincent and the Grenadines'
  239. },
  240. {
  241. latLng: [13.16, -59.55],
  242. name : 'Barbados'
  243. },
  244. {
  245. latLng: [17.11, -61.85],
  246. name : 'Antigua and Barbuda'
  247. },
  248. {
  249. latLng: [-4.61, 55.45],
  250. name : 'Seychelles'
  251. },
  252. {
  253. latLng: [7.35, 134.46],
  254. name : 'Palau'
  255. },
  256. {
  257. latLng: [42.5, 1.51],
  258. name : 'Andorra'
  259. },
  260. {
  261. latLng: [14.01, -60.98],
  262. name : 'Saint Lucia'
  263. },
  264. {
  265. latLng: [6.91, 158.18],
  266. name : 'Federated States of Micronesia'
  267. },
  268. {
  269. latLng: [1.3, 103.8],
  270. name : 'Singapore'
  271. },
  272. {
  273. latLng: [1.46, 173.03],
  274. name : 'Kiribati'
  275. },
  276. {
  277. latLng: [-21.13, -175.2],
  278. name : 'Tonga'
  279. },
  280. {
  281. latLng: [15.3, -61.38],
  282. name : 'Dominica'
  283. },
  284. {
  285. latLng: [-20.2, 57.5],
  286. name : 'Mauritius'
  287. },
  288. {
  289. latLng: [26.02, 50.55],
  290. name : 'Bahrain'
  291. },
  292. {
  293. latLng: [0.33, 6.73],
  294. name : 'São Tomé and Príncipe'
  295. }
  296. ]
  297. })
  298. /* SPARKLINE CHARTS
  299. * ----------------
  300. * Create a inline charts with spark line
  301. */
  302. //-----------------
  303. //- SPARKLINE BAR -
  304. //-----------------
  305. $('.sparkbar').each(function () {
  306. var $this = $(this)
  307. $this.sparkline('html', {
  308. type : 'bar',
  309. height : $this.data('height') ? $this.data('height') : '30',
  310. barColor: $this.data('color')
  311. })
  312. })
  313. //-----------------
  314. //- SPARKLINE PIE -
  315. //-----------------
  316. $('.sparkpie').each(function () {
  317. var $this = $(this)
  318. $this.sparkline('html', {
  319. type : 'pie',
  320. height : $this.data('height') ? $this.data('height') : '90',
  321. sliceColors: $this.data('color')
  322. })
  323. })
  324. //------------------
  325. //- SPARKLINE LINE -
  326. //------------------
  327. $('.sparkline').each(function () {
  328. var $this = $(this)
  329. $this.sparkline('html', {
  330. type : 'line',
  331. height : $this.data('height') ? $this.data('height') : '90',
  332. width : '100%',
  333. lineColor: $this.data('linecolor'),
  334. fillColor: $this.data('fillcolor'),
  335. spotColor: $this.data('spotcolor')
  336. })
  337. })
  338. })