Dashboard sipadu mbip
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.

ecommerce-dashboard.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. 'use strict';
  2. $(document).ready(function() {
  3. $('[data-toggle="tooltip"]').tooltip();
  4. // sale report start
  5. var ctx = document.getElementById('sale-report-1').getContext("2d");
  6. var myChart = new Chart(ctx, {
  7. type: 'bar',
  8. data: salereportchart('#448aff', [25, 30, 15, 20, 25, 30, 15, 1], '#448aff'),
  9. options: salereportbuildoption(),
  10. });
  11. var ctx = document.getElementById('sale-report-2').getContext("2d");
  12. var myChart = new Chart(ctx, {
  13. type: 'bar',
  14. data: salereportchart('#11c15b', [15, 20, 25,10, 12, 30, 15, 1], '#11c15b'),
  15. options: salereportbuildoption(),
  16. });
  17. var ctx = document.getElementById('sale-report-3').getContext("2d");
  18. var myChart = new Chart(ctx, {
  19. type: 'bar',
  20. data: salereportchart('#536dfe', [15, 20, 25,10, 30, 15, 25, 1], '#536dfe'),
  21. options: salereportbuildoption(),
  22. });
  23. var ctx = document.getElementById('sale-report-4').getContext("2d");
  24. var myChart = new Chart(ctx, {
  25. type: 'bar',
  26. data: salereportchart('#ff5252', [30, 15, 25, 35, 30, 20, 15, 1], '#ff5252'),
  27. options: salereportbuildoption(),
  28. });
  29. function salereportchart(a, b, f) {
  30. if (f == null) {
  31. f = "rgba(0,0,0,0)";
  32. }
  33. return {
  34. labels: ["1","2","3","4","5","6","7","8"],
  35. datasets: [{
  36. label: "",
  37. borderColor: a,
  38. borderWidth: 2,
  39. hitRadius: 30,
  40. pointRadius: 0,
  41. pointHoverRadius: 4,
  42. pointBorderWidth: 2,
  43. pointHoverBorderWidth: 12,
  44. pointBackgroundColor: Chart.helpers.color("#000000").alpha(0).rgbString(),
  45. // pointBorderColor: Chart.helpers.color("#000000").alpha(0).rgbString(),
  46. pointBorderColor: a,
  47. pointHoverBackgroundColor: a,
  48. pointHoverBorderColor: Chart.helpers.color("#000000").alpha(.1).rgbString(),
  49. fill: true,
  50. lineTension: 0,
  51. backgroundColor: f,
  52. data: b,
  53. }]
  54. };
  55. }
  56. function salereportbuildoption() {
  57. return {
  58. title: {
  59. display: !1
  60. },
  61. tooltips: {
  62. position: 'nearest',
  63. mode: 'index',
  64. intersect: false,
  65. yPadding: 10,
  66. xPadding: 10,
  67. },
  68. legend: {
  69. display: !1,
  70. labels: {
  71. usePointStyle: !1
  72. }
  73. },
  74. responsive: !0,
  75. maintainAspectRatio: !0,
  76. hover: {
  77. mode: "index"
  78. },
  79. scales: {
  80. xAxes: [{
  81. display: !1,
  82. gridLines: !1,
  83. scaleLabel: {
  84. display: !0,
  85. labelString: "Month"
  86. }
  87. }],
  88. yAxes: [{
  89. display: !1,
  90. gridLines: !1,
  91. scaleLabel: {
  92. display: !0,
  93. labelString: "Value"
  94. },
  95. ticks: {
  96. beginAtZero: !0
  97. }
  98. }]
  99. },
  100. elements: {
  101. point: {
  102. radius: 4,
  103. borderWidth: 12
  104. }
  105. },
  106. layout: {
  107. padding: {
  108. left: 10,
  109. right: 10,
  110. top: 10,
  111. bottom: 10
  112. }
  113. }
  114. };
  115. }
  116. // sale report end
  117. // pageview and prod sale start
  118. var chart = AmCharts.makeChart("product-sales-chart", {
  119. "type": "serial",
  120. "theme": "light",
  121. "dataDateFormat": "YYYY-MM-DD",
  122. "precision": 2,
  123. "valueAxes": [{
  124. "id": "v1",
  125. "title": "Sales",
  126. "position": "left",
  127. "autoGridCount": false,
  128. "labelFunction": function(value) {
  129. return "$" + Math.round(value) + "M";
  130. }
  131. }, {
  132. "id": "v2",
  133. "gridAlpha": 0.1,
  134. "autoGridCount": false
  135. }],
  136. "graphs": [{
  137. "id": "g1",
  138. "valueAxis": "v2",
  139. "lineThickness": 0,
  140. "fillAlphas": 0.9,
  141. "lineColor": "#448aff",
  142. "type": "smoothedLine",
  143. "title": "Laptop",
  144. "useLineColorForBulletBorder": true,
  145. "valueField": "market1",
  146. "balloonText": "[[title]]<br /><b style='font-size: 130%'>[[value]]</b>"
  147. }, {
  148. "id": "g2",
  149. "valueAxis": "v2",
  150. "fillAlphas": 0.9,
  151. "bulletColor": "#ff5252",
  152. "lineThickness": 0,
  153. "lineColor": "#ff5252",
  154. "type": "smoothedLine",
  155. "title": "TV",
  156. "useLineColorForBulletBorder": true,
  157. "valueField": "market2",
  158. "balloonText": "[[title]]<br /><b style='font-size: 130%'>[[value]]</b>"
  159. }, {
  160. "id": "g3",
  161. "valueAxis": "v2",
  162. "fillAlphas": 0.9,
  163. "bulletColor": "#11c15b",
  164. "lineThickness": 0,
  165. "lineColor": "#11c15b",
  166. "type": "smoothedLine",
  167. "title": "Mobile",
  168. "useLineColorForBulletBorder": true,
  169. "valueField": "sales1",
  170. "balloonText": "[[title]]<br /><b style='font-size: 130%'>[[value]]</b>"
  171. }],
  172. "chartCursor": {
  173. "pan": true,
  174. "valueLineEnabled": true,
  175. "valueLineBalloonEnabled": true,
  176. "cursorAlpha": 0,
  177. "valueLineAlpha": 0.2
  178. },
  179. "categoryField": "date",
  180. "categoryAxis": {
  181. "parseDates": true,
  182. "gridAlpha" : 0,
  183. "minorGridEnabled": true
  184. },
  185. "legend": {
  186. "position":"top",
  187. },
  188. "balloon": {
  189. "borderThickness": 1,
  190. "shadowAlpha": 0
  191. },
  192. "export": {
  193. "enabled": true
  194. },
  195. "dataProvider": [{
  196. "date": "2013-01-01",
  197. "market1": 0,
  198. "market2": 0,
  199. "sales1": 0
  200. }, {
  201. "date": "2013-02-01",
  202. "market1": 0,
  203. "market2": 0,
  204. "sales1": 40
  205. }, {
  206. "date": "2013-03-01",
  207. "market1": 0,
  208. "market2": 0,
  209. "sales1": 0
  210. }, {
  211. "date": "2013-04-01",
  212. "market1": 30,
  213. "market2": 0,
  214. "sales1": 0
  215. }, {
  216. "date": "2013-05-01",
  217. "market1": 0,
  218. "market2": 20,
  219. "sales1": 0
  220. }, {
  221. "date": "2013-06-01",
  222. "market1": 25,
  223. "market2": 0,
  224. "sales1": 0
  225. }, {
  226. "date": "2013-07-01",
  227. "market1": 0,
  228. "market2": 0,
  229. "sales1": 0
  230. }, {
  231. "date": "2013-08-01",
  232. "market1": 0,
  233. "market2": 0,
  234. "sales1": 30
  235. }, {
  236. "date": "2013-09-01",
  237. "market1": 0,
  238. "market2": 0,
  239. "sales1": 0
  240. }, {
  241. "date": "2013-10-01",
  242. "market1": 0,
  243. "market2": 50,
  244. "sales1": 0
  245. }, {
  246. "date": "2013-11-01",
  247. "market1": 0,
  248. "market2": 0,
  249. "sales1": 65
  250. }, {
  251. "date": "2013-12-01",
  252. "market1": 0,
  253. "market2": 0,
  254. "sales1": 0
  255. }]
  256. });
  257. // pageview and prod sale end
  258. // sale order start
  259. var ctx = document.getElementById('sale-chart1').getContext("2d");
  260. var myChart = new Chart(ctx, {
  261. type: 'line',
  262. data: salechart('#b71c1c', [25, 30, 15, 20, 25, 30, 15, 25, 35, 30, 20, 10, 12, 1], 'transparent'),
  263. options: salebuildoption(),
  264. });
  265. function salechart(a, b, f) {
  266. if (f == null) {
  267. f = "rgba(0,0,0,0)";
  268. }
  269. return {
  270. labels: ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"],
  271. datasets: [{
  272. label: "",
  273. borderColor: a,
  274. borderWidth: 2,
  275. hitRadius: 30,
  276. pointRadius: 3,
  277. pointHoverRadius: 4,
  278. pointBorderWidth: 5,
  279. pointHoverBorderWidth: 12,
  280. pointBackgroundColor: Chart.helpers.color("#000000").alpha(0).rgbString(),
  281. // pointBorderColor: Chart.helpers.color("#000000").alpha(0).rgbString(),
  282. pointBorderColor: a,
  283. pointHoverBackgroundColor: a,
  284. pointHoverBorderColor: Chart.helpers.color("#000000").alpha(.1).rgbString(),
  285. fill: true,
  286. lineTension: 0,
  287. backgroundColor: f,
  288. data: b,
  289. }]
  290. };
  291. }
  292. function salebuildoption() {
  293. return {
  294. title: {
  295. display: !1
  296. },
  297. tooltips: {
  298. position: 'nearest',
  299. mode: 'index',
  300. intersect: false,
  301. yPadding: 10,
  302. xPadding: 10,
  303. },
  304. legend: {
  305. display: !1,
  306. labels: {
  307. usePointStyle: !1
  308. }
  309. },
  310. responsive: !0,
  311. maintainAspectRatio: !0,
  312. hover: {
  313. mode: "index"
  314. },
  315. scales: {
  316. xAxes: [{
  317. display: !1,
  318. gridLines: !1,
  319. scaleLabel: {
  320. display: !0,
  321. labelString: "Month"
  322. }
  323. }],
  324. yAxes: [{
  325. display: !1,
  326. gridLines: !1,
  327. scaleLabel: {
  328. display: !0,
  329. labelString: "Value"
  330. },
  331. ticks: {
  332. beginAtZero: !0
  333. }
  334. }]
  335. },
  336. elements: {
  337. point: {
  338. radius: 4,
  339. borderWidth: 12
  340. }
  341. },
  342. layout: {
  343. padding: {
  344. left: 10,
  345. right: 10,
  346. top: 25,
  347. bottom: 25
  348. }
  349. }
  350. };
  351. }
  352. // sale order end
  353. });