examples.dashboard.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. (function( $ ) {
  2. 'use strict';
  3. /*
  4. Sales Selector
  5. */
  6. $('#salesSelector').themePluginMultiSelect().on('change', function() {
  7. var rel = $(this).val();
  8. $('#salesSelectorItems .chart').removeClass('chart-active').addClass('chart-hidden');
  9. $('#salesSelectorItems .chart[data-sales-rel="' + rel + '"]').addClass('chart-active').removeClass('chart-hidden');
  10. });
  11. $('#salesSelector').trigger('change');
  12. $('#salesSelectorWrapper').addClass('ready');
  13. /*
  14. Flot: Sales 1
  15. */
  16. var flotDashSales1 = $.plot('#flotDashSales1', flotDashSales1Data, {
  17. series: {
  18. lines: {
  19. show: true,
  20. lineWidth: 2
  21. },
  22. points: {
  23. show: true
  24. },
  25. shadowSize: 0
  26. },
  27. grid: {
  28. hoverable: true,
  29. clickable: true,
  30. borderColor: 'rgba(0,0,0,0.1)',
  31. borderWidth: 1,
  32. labelMargin: 15,
  33. backgroundColor: 'transparent'
  34. },
  35. yaxis: {
  36. min: 0,
  37. color: 'rgba(0,0,0,0.1)'
  38. },
  39. xaxis: {
  40. mode: 'categories',
  41. color: 'rgba(0,0,0,0)'
  42. },
  43. legend: {
  44. show: false
  45. },
  46. tooltip: true,
  47. tooltipOpts: {
  48. content: '%x: %y',
  49. shifts: {
  50. x: -30,
  51. y: 25
  52. },
  53. defaultTheme: false
  54. }
  55. });
  56. /*
  57. Flot: Sales 2
  58. */
  59. var flotDashSales2 = $.plot('#flotDashSales2', flotDashSales2Data, {
  60. series: {
  61. lines: {
  62. show: true,
  63. lineWidth: 2
  64. },
  65. points: {
  66. show: true
  67. },
  68. shadowSize: 0
  69. },
  70. grid: {
  71. hoverable: true,
  72. clickable: true,
  73. borderColor: 'rgba(0,0,0,0.1)',
  74. borderWidth: 1,
  75. labelMargin: 15,
  76. backgroundColor: 'transparent'
  77. },
  78. yaxis: {
  79. min: 0,
  80. color: 'rgba(0,0,0,0.1)'
  81. },
  82. xaxis: {
  83. mode: 'categories',
  84. color: 'rgba(0,0,0,0)'
  85. },
  86. legend: {
  87. show: false
  88. },
  89. tooltip: true,
  90. tooltipOpts: {
  91. content: '%x: %y',
  92. shifts: {
  93. x: -30,
  94. y: 25
  95. },
  96. defaultTheme: false
  97. }
  98. });
  99. /*
  100. Flot: Sales 3
  101. */
  102. var flotDashSales3 = $.plot('#flotDashSales3', flotDashSales3Data, {
  103. series: {
  104. lines: {
  105. show: true,
  106. lineWidth: 2
  107. },
  108. points: {
  109. show: true
  110. },
  111. shadowSize: 0
  112. },
  113. grid: {
  114. hoverable: true,
  115. clickable: true,
  116. borderColor: 'rgba(0,0,0,0.1)',
  117. borderWidth: 1,
  118. labelMargin: 15,
  119. backgroundColor: 'transparent'
  120. },
  121. yaxis: {
  122. min: 0,
  123. color: 'rgba(0,0,0,0.1)'
  124. },
  125. xaxis: {
  126. mode: 'categories',
  127. color: 'rgba(0,0,0,0)'
  128. },
  129. legend: {
  130. show: false
  131. },
  132. tooltip: true,
  133. tooltipOpts: {
  134. content: '%x: %y',
  135. shifts: {
  136. x: -30,
  137. y: 25
  138. },
  139. defaultTheme: false
  140. }
  141. });
  142. /*
  143. Liquid Meter
  144. */
  145. $('#meterSales').liquidMeter({
  146. shape: 'circle',
  147. color: '#0088cc',
  148. background: '#F9F9F9',
  149. fontSize: '24px',
  150. fontWeight: '600',
  151. stroke: '#F2F2F2',
  152. textColor: '#333',
  153. liquidOpacity: 0.9,
  154. liquidPalette: ['#333'],
  155. speed: 3000,
  156. animate: !$.browser.mobile
  157. });
  158. $('#meterSalesSel a').on('click', function( ev ) {
  159. ev.preventDefault();
  160. var val = $(this).data("val"),
  161. selector = $(this).parent(),
  162. items = selector.find('a');
  163. items.removeClass('active');
  164. $(this).addClass('active');
  165. // Update Meter Value
  166. $('#meterSales').liquidMeter('set', val);
  167. });
  168. /*
  169. Flot: Basic
  170. */
  171. var flotDashBasic = $.plot('#flotDashBasic', flotDashBasicData, {
  172. series: {
  173. lines: {
  174. show: true,
  175. fill: true,
  176. lineWidth: 1,
  177. fillColor: {
  178. colors: [{
  179. opacity: 0.45
  180. }, {
  181. opacity: 0.45
  182. }]
  183. }
  184. },
  185. points: {
  186. show: true
  187. },
  188. shadowSize: 0
  189. },
  190. grid: {
  191. hoverable: true,
  192. clickable: true,
  193. borderColor: 'rgba(0,0,0,0.1)',
  194. borderWidth: 1,
  195. labelMargin: 15,
  196. backgroundColor: 'transparent'
  197. },
  198. yaxis: {
  199. min: 0,
  200. max: 200,
  201. color: 'rgba(0,0,0,0.1)'
  202. },
  203. xaxis: {
  204. color: 'rgba(0,0,0,0)'
  205. },
  206. tooltip: true,
  207. tooltipOpts: {
  208. content: '%s: Value of %x is %y',
  209. shifts: {
  210. x: -60,
  211. y: 25
  212. },
  213. defaultTheme: false
  214. }
  215. });
  216. /*
  217. Flot: Real-Time
  218. */
  219. (function() {
  220. var data = [],
  221. totalPoints = 300;
  222. function getRandomData() {
  223. if (data.length > 0)
  224. data = data.slice(1);
  225. // Do a random walk
  226. while (data.length < totalPoints) {
  227. var prev = data.length > 0 ? data[data.length - 1] : 50,
  228. y = prev + Math.random() * 10 - 5;
  229. if (y < 0) {
  230. y = 0;
  231. } else if (y > 100) {
  232. y = 100;
  233. }
  234. data.push(y);
  235. }
  236. // Zip the generated y values with the x values
  237. var res = [];
  238. for (var i = 0; i < data.length; ++i) {
  239. res.push([i, data[i]])
  240. }
  241. return res;
  242. }
  243. var flotDashRealTime = $.plot('#flotDashRealTime', [getRandomData()], {
  244. colors: ['#8CC9E8'],
  245. series: {
  246. lines: {
  247. show: true,
  248. fill: true,
  249. lineWidth: 1,
  250. fillColor: {
  251. colors: [{
  252. opacity: 0.45
  253. }, {
  254. opacity: 0.45
  255. }]
  256. }
  257. },
  258. points: {
  259. show: false
  260. },
  261. shadowSize: 0
  262. },
  263. grid: {
  264. borderColor: 'rgba(0,0,0,0.1)',
  265. borderWidth: 1,
  266. labelMargin: 15,
  267. backgroundColor: 'transparent'
  268. },
  269. yaxis: {
  270. min: 0,
  271. max: 100,
  272. color: 'rgba(0,0,0,0.1)'
  273. },
  274. xaxis: {
  275. show: false
  276. }
  277. });
  278. function update() {
  279. flotDashRealTime.setData([getRandomData()]);
  280. // Since the axes don't change, we don't need to call plot.setupGrid()
  281. flotDashRealTime.draw();
  282. setTimeout(update, ($('html').hasClass( 'mobile-device' ) ? 1000 : 30) );
  283. }
  284. update();
  285. })();
  286. /*
  287. Sparkline: Bar
  288. */
  289. var sparklineBarDashOptions = {
  290. type: 'bar',
  291. width: '80',
  292. height: '55',
  293. barColor: '#0088cc',
  294. negBarColor: '#B20000'
  295. };
  296. $("#sparklineBarDash").sparkline(sparklineBarDashData, sparklineBarDashOptions);
  297. /*
  298. Sparkline: Line
  299. */
  300. var sparklineLineDashOptions = {
  301. type: 'line',
  302. width: '80',
  303. height: '55',
  304. lineColor: '#0088cc'
  305. };
  306. $("#sparklineLineDash").sparkline(sparklineLineDashData, sparklineLineDashOptions);
  307. /*
  308. Map
  309. */
  310. var vectorMapDashOptions = {
  311. map: 'world_en',
  312. backgroundColor: null,
  313. color: '#FFFFFF',
  314. hoverOpacity: 0.7,
  315. selectedColor: '#005599',
  316. enableZoom: true,
  317. borderWidth:1,
  318. showTooltip: true,
  319. values: sample_data,
  320. scaleColors: ['#0088cc'],
  321. normalizeFunction: 'polynomial'
  322. };
  323. $('#vectorMapWorld').vectorMap(vectorMapDashOptions);
  324. }).apply( this, [ jQuery ]);