dashboard2.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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 : 'rgb(210, 214, 222)',
  20. strokeColor : 'rgb(210, 214, 222)',
  21. pointColor : 'rgb(210, 214, 222)',
  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(60,141,188,0.9)',
  30. strokeColor : 'rgba(60,141,188,0.8)',
  31. pointColor : '#3b8bba',
  32. pointStrokeColor : 'rgba(60,141,188,1)',
  33. pointHighlightFill : '#fff',
  34. pointHighlightStroke: 'rgba(60,141,188,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 : true,
  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 : '#f56954',
  92. highlight: '#f56954',
  93. label : 'Chrome'
  94. },
  95. {
  96. value : 500,
  97. color : '#00a65a',
  98. highlight: '#00a65a',
  99. label : 'IE'
  100. },
  101. {
  102. value : 400,
  103. color : '#f39c12',
  104. highlight: '#f39c12',
  105. label : 'FireFox'
  106. },
  107. {
  108. value : 600,
  109. color : '#00c0ef',
  110. highlight: '#00c0ef',
  111. label : 'Safari'
  112. },
  113. {
  114. value : 300,
  115. color : '#3c8dbc',
  116. highlight: '#3c8dbc',
  117. label : 'Opera'
  118. },
  119. {
  120. value : 100,
  121. color : '#d2d6de',
  122. highlight: '#d2d6de',
  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. { latLng: [41.90, 12.45], name: 'Vatican City' },
  193. { latLng: [43.73, 7.41], name: 'Monaco' },
  194. { latLng: [-0.52, 166.93], name: 'Nauru' },
  195. { latLng: [-8.51, 179.21], name: 'Tuvalu' },
  196. { latLng: [43.93, 12.46], name: 'San Marino' },
  197. { latLng: [47.14, 9.52], name: 'Liechtenstein' },
  198. { latLng: [7.11, 171.06], name: 'Marshall Islands' },
  199. { latLng: [17.3, -62.73], name: 'Saint Kitts and Nevis' },
  200. { latLng: [3.2, 73.22], name: 'Maldives' },
  201. { latLng: [35.88, 14.5], name: 'Malta' },
  202. { latLng: [12.05, -61.75], name: 'Grenada' },
  203. { latLng: [13.16, -61.23], name: 'Saint Vincent and the Grenadines' },
  204. { latLng: [13.16, -59.55], name: 'Barbados' },
  205. { latLng: [17.11, -61.85], name: 'Antigua and Barbuda' },
  206. { latLng: [-4.61, 55.45], name: 'Seychelles' },
  207. { latLng: [7.35, 134.46], name: 'Palau' },
  208. { latLng: [42.5, 1.51], name: 'Andorra' },
  209. { latLng: [14.01, -60.98], name: 'Saint Lucia' },
  210. { latLng: [6.91, 158.18], name: 'Federated States of Micronesia' },
  211. { latLng: [1.3, 103.8], name: 'Singapore' },
  212. { latLng: [1.46, 173.03], name: 'Kiribati' },
  213. { latLng: [-21.13, -175.2], name: 'Tonga' },
  214. { latLng: [15.3, -61.38], name: 'Dominica' },
  215. { latLng: [-20.2, 57.5], name: 'Mauritius' },
  216. { latLng: [26.02, 50.55], name: 'Bahrain' },
  217. { latLng: [0.33, 6.73], name: 'São Tomé and Príncipe' }
  218. ]
  219. });
  220. /* SPARKLINE CHARTS
  221. * ----------------
  222. * Create a inline charts with spark line
  223. */
  224. // -----------------
  225. // - SPARKLINE BAR -
  226. // -----------------
  227. $('.sparkbar').each(function () {
  228. var $this = $(this);
  229. $this.sparkline('html', {
  230. type : 'bar',
  231. height : $this.data('height') ? $this.data('height') : '30',
  232. barColor: $this.data('color')
  233. });
  234. });
  235. // -----------------
  236. // - SPARKLINE PIE -
  237. // -----------------
  238. $('.sparkpie').each(function () {
  239. var $this = $(this);
  240. $this.sparkline('html', {
  241. type : 'pie',
  242. height : $this.data('height') ? $this.data('height') : '90',
  243. sliceColors: $this.data('color')
  244. });
  245. });
  246. // ------------------
  247. // - SPARKLINE LINE -
  248. // ------------------
  249. $('.sparkline').each(function () {
  250. var $this = $(this);
  251. $this.sparkline('html', {
  252. type : 'line',
  253. height : $this.data('height') ? $this.data('height') : '90',
  254. width : '100%',
  255. lineColor: $this.data('linecolor'),
  256. fillColor: $this.data('fillcolor'),
  257. spotColor: $this.data('spotcolor')
  258. });
  259. });
  260. });