Ei kuvausta
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.

app-ecommerce-dashboard.js 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860
  1. /**
  2. * Dashboard eCommerce
  3. */
  4. 'use strict';
  5. document.addEventListener('DOMContentLoaded', function (e) {
  6. let cardColor,
  7. headingColor,
  8. labelColor,
  9. shadeColor,
  10. borderColor,
  11. heatMap1,
  12. heatMap2,
  13. heatMap3,
  14. heatMap4,
  15. fontFamily,
  16. legendColor;
  17. if (isDarkStyle) {
  18. shadeColor = 'dark';
  19. heatMap1 = '#4f51c0';
  20. heatMap2 = '#595cd9';
  21. heatMap3 = '#8789ff';
  22. heatMap4 = '#c3c4ff';
  23. } else {
  24. shadeColor = '';
  25. heatMap1 = '#e1e2ff';
  26. heatMap2 = '#c3c4ff';
  27. heatMap3 = '#a5a7ff';
  28. heatMap4 = '#696cff';
  29. }
  30. cardColor = config.colors.cardColor;
  31. headingColor = config.colors.headingColor;
  32. labelColor = config.colors.textMuted;
  33. borderColor = config.colors.borderColor;
  34. fontFamily = config.fontFamily;
  35. legendColor = config.colors.bodyColor;
  36. // Visitor Bar Chart
  37. // --------------------------------------------------------------------
  38. const visitorBarChartEl = document.querySelector('#visitorsChart'),
  39. visitorBarChartConfig = {
  40. chart: {
  41. height: 120,
  42. width: 200,
  43. parentHeightOffset: 0,
  44. type: 'bar',
  45. toolbar: {
  46. show: false
  47. }
  48. },
  49. plotOptions: {
  50. bar: {
  51. barHeight: '75%',
  52. columnWidth: '60%',
  53. startingShape: 'rounded',
  54. endingShape: 'rounded',
  55. borderRadius: 7,
  56. distributed: true
  57. }
  58. },
  59. grid: {
  60. show: false,
  61. padding: {
  62. top: -25,
  63. bottom: -12
  64. }
  65. },
  66. colors: [
  67. config.colors_label.primary,
  68. config.colors_label.primary,
  69. config.colors_label.primary,
  70. config.colors_label.primary,
  71. config.colors_label.primary,
  72. config.colors.primary,
  73. config.colors_label.primary
  74. ],
  75. dataLabels: {
  76. enabled: false
  77. },
  78. series: [
  79. {
  80. data: [40, 95, 60, 45, 90, 50, 75]
  81. }
  82. ],
  83. legend: {
  84. show: false
  85. },
  86. responsive: [
  87. {
  88. breakpoint: 1440,
  89. options: {
  90. plotOptions: {
  91. bar: {
  92. borderRadius: 9,
  93. columnWidth: '60%'
  94. }
  95. }
  96. }
  97. },
  98. {
  99. breakpoint: 1300,
  100. options: {
  101. plotOptions: {
  102. bar: {
  103. borderRadius: 9,
  104. columnWidth: '60%'
  105. }
  106. }
  107. }
  108. },
  109. {
  110. breakpoint: 1200,
  111. options: {
  112. plotOptions: {
  113. bar: {
  114. borderRadius: 8,
  115. columnWidth: '50%'
  116. }
  117. }
  118. }
  119. },
  120. {
  121. breakpoint: 1040,
  122. options: {
  123. plotOptions: {
  124. bar: {
  125. borderRadius: 8,
  126. columnWidth: '50%'
  127. }
  128. }
  129. }
  130. },
  131. {
  132. breakpoint: 991,
  133. options: {
  134. plotOptions: {
  135. bar: {
  136. borderRadius: 8,
  137. columnWidth: '50%'
  138. }
  139. }
  140. }
  141. },
  142. {
  143. breakpoint: 420,
  144. options: {
  145. plotOptions: {
  146. bar: {
  147. borderRadius: 8,
  148. columnWidth: '50%'
  149. }
  150. }
  151. }
  152. }
  153. ],
  154. xaxis: {
  155. categories: ['M', 'T', 'W', 'T', 'F', 'S', 'S'],
  156. axisBorder: {
  157. show: false
  158. },
  159. axisTicks: {
  160. show: false
  161. },
  162. labels: {
  163. style: {
  164. colors: labelColor,
  165. fontSize: '13px'
  166. }
  167. }
  168. },
  169. yaxis: {
  170. labels: {
  171. show: false
  172. }
  173. }
  174. };
  175. if (typeof visitorBarChartEl !== undefined && visitorBarChartEl !== null) {
  176. const visitorBarChart = new ApexCharts(visitorBarChartEl, visitorBarChartConfig);
  177. visitorBarChart.render();
  178. }
  179. // Activity Area Chart
  180. // --------------------------------------------------------------------
  181. const activityAreaChartEl = document.querySelector('#activityChart'),
  182. activityAreaChartConfig = {
  183. chart: {
  184. height: 110,
  185. width: 220,
  186. parentHeightOffset: 0,
  187. toolbar: {
  188. show: false
  189. },
  190. type: 'area'
  191. },
  192. dataLabels: {
  193. enabled: false
  194. },
  195. stroke: {
  196. width: 2,
  197. curve: 'smooth'
  198. },
  199. series: [
  200. {
  201. data: [15, 22, 17, 39, 12, 35, 25]
  202. }
  203. ],
  204. colors: [config.colors.success],
  205. fill: {
  206. type: 'gradient',
  207. gradient: {
  208. shadeIntensity: 1,
  209. opacityFrom: 0.7,
  210. gradientToColors: [config.colors.cardColor],
  211. opacityTo: 0.2,
  212. stops: [0, 85, 100]
  213. }
  214. },
  215. grid: {
  216. show: false,
  217. padding: {
  218. top: -20,
  219. bottom: -8
  220. }
  221. },
  222. legend: {
  223. show: false
  224. },
  225. xaxis: {
  226. categories: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
  227. axisBorder: {
  228. show: false
  229. },
  230. axisTicks: {
  231. show: false
  232. },
  233. labels: {
  234. style: {
  235. fontSize: '13px',
  236. colors: labelColor
  237. }
  238. }
  239. },
  240. yaxis: {
  241. labels: {
  242. show: false
  243. }
  244. }
  245. };
  246. if (typeof activityAreaChartEl !== undefined && activityAreaChartEl !== null) {
  247. const activityAreaChart = new ApexCharts(activityAreaChartEl, activityAreaChartConfig);
  248. activityAreaChart.render();
  249. }
  250. // Profit Bar Chart
  251. // --------------------------------------------------------------------
  252. const profitBarChartEl = document.querySelector('#profitChart'),
  253. profitBarChartConfig = {
  254. series: [
  255. {
  256. data: [73, 56, 56, 100]
  257. },
  258. {
  259. data: [61, 42, 74, 72]
  260. }
  261. ],
  262. chart: {
  263. type: 'bar',
  264. height: 90,
  265. toolbar: {
  266. tools: {
  267. download: false
  268. }
  269. }
  270. },
  271. plotOptions: {
  272. bar: {
  273. columnWidth: '69%',
  274. startingShape: 'rounded',
  275. endingShape: 'rounded',
  276. borderRadius: 3,
  277. dataLabels: {
  278. show: false
  279. }
  280. }
  281. },
  282. states: {
  283. hover: {
  284. filter: {
  285. type: 'none'
  286. }
  287. },
  288. active: {
  289. filter: {
  290. type: 'none'
  291. }
  292. }
  293. },
  294. grid: {
  295. show: false,
  296. padding: {
  297. top: -30,
  298. bottom: -12,
  299. left: -10,
  300. right: 0
  301. }
  302. },
  303. colors: [config.colors.success, config.colors_label.success],
  304. dataLabels: {
  305. enabled: false
  306. },
  307. stroke: {
  308. show: true,
  309. width: 5,
  310. colors: cardColor
  311. },
  312. legend: {
  313. show: false
  314. },
  315. xaxis: {
  316. categories: ['Jan', 'Apr', 'Jul', 'Oct'],
  317. axisBorder: {
  318. show: false
  319. },
  320. axisTicks: {
  321. show: false
  322. },
  323. labels: {
  324. style: {
  325. colors: labelColor,
  326. fontSize: '13px'
  327. }
  328. }
  329. },
  330. yaxis: {
  331. labels: {
  332. show: false
  333. }
  334. }
  335. };
  336. if (typeof profitBarChartEl !== undefined && profitBarChartEl !== null) {
  337. const profitBarChart = new ApexCharts(profitBarChartEl, profitBarChartConfig);
  338. profitBarChart.render();
  339. }
  340. // Total Sales Radial Bar Chart
  341. // --------------------------------------------------------------------
  342. const expensesRadialChartEl = document.querySelector('#expensesChart'),
  343. expensesRadialChartConfig = {
  344. chart: {
  345. height: 130,
  346. sparkline: {
  347. enabled: true
  348. },
  349. parentHeightOffset: 0,
  350. type: 'radialBar'
  351. },
  352. colors: [config.colors.primary],
  353. series: [78],
  354. plotOptions: {
  355. radialBar: {
  356. startAngle: -90,
  357. endAngle: 90,
  358. hollow: {
  359. size: '55%'
  360. },
  361. track: {
  362. background: config.colors_label.secondary
  363. },
  364. dataLabels: {
  365. name: {
  366. show: false
  367. },
  368. value: {
  369. fontSize: '18px',
  370. fontFamily: fontFamily,
  371. color: headingColor,
  372. fontWeight: 500,
  373. offsetY: -5
  374. }
  375. }
  376. }
  377. },
  378. grid: {
  379. show: false,
  380. padding: {
  381. left: -10,
  382. right: -10,
  383. bottom: 5
  384. }
  385. },
  386. stroke: {
  387. lineCap: 'round'
  388. },
  389. labels: ['Progress']
  390. };
  391. if (typeof expensesRadialChartEl !== undefined && expensesRadialChartEl !== null) {
  392. const expensesRadialChart = new ApexCharts(expensesRadialChartEl, expensesRadialChartConfig);
  393. expensesRadialChart.render();
  394. }
  395. // Total Income - Area Chart
  396. // --------------------------------------------------------------------
  397. const totalIncomeEl = document.querySelector('#totalIncomeChart'),
  398. totalIncomeConfig = {
  399. chart: {
  400. height: 290,
  401. type: 'area',
  402. toolbar: false,
  403. dropShadow: {
  404. enabled: true,
  405. top: 14,
  406. left: 2,
  407. blur: 3,
  408. color: config.colors.primary,
  409. opacity: 0.15
  410. }
  411. },
  412. series: [
  413. {
  414. data: [3350, 3350, 4800, 4800, 2950, 2950, 1800, 1800, 3750, 3750, 5700, 5700]
  415. }
  416. ],
  417. dataLabels: {
  418. enabled: false
  419. },
  420. stroke: {
  421. width: 3,
  422. curve: 'straight'
  423. },
  424. colors: [config.colors.primary],
  425. fill: {
  426. type: 'gradient',
  427. gradient: {
  428. shadeIntensity: 1,
  429. opacityFrom: 0.3,
  430. gradientToColors: [config.colors.cardColor],
  431. opacityTo: 0.3,
  432. stops: [0, 100]
  433. }
  434. },
  435. grid: {
  436. show: true,
  437. strokeDashArray: 10,
  438. borderColor: borderColor,
  439. padding: {
  440. top: -15,
  441. bottom: -10,
  442. left: 0,
  443. right: 0
  444. }
  445. },
  446. xaxis: {
  447. categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
  448. labels: {
  449. offsetX: 0,
  450. style: {
  451. colors: labelColor,
  452. fontFamily: fontFamily,
  453. fontSize: '13px'
  454. }
  455. },
  456. axisBorder: {
  457. show: false
  458. },
  459. axisTicks: {
  460. show: false
  461. },
  462. lines: {
  463. show: false
  464. }
  465. },
  466. yaxis: {
  467. labels: {
  468. offsetX: -15,
  469. formatter: function (val) {
  470. return '$' + parseInt(val / 1000) + 'k';
  471. },
  472. style: {
  473. fontSize: '13px',
  474. fontFamily: fontFamily,
  475. colors: labelColor
  476. }
  477. },
  478. min: 1000,
  479. max: 6000,
  480. tickAmount: 5
  481. }
  482. };
  483. if (typeof totalIncomeEl !== undefined && totalIncomeEl !== null) {
  484. const totalIncome = new ApexCharts(totalIncomeEl, totalIncomeConfig);
  485. totalIncome.render();
  486. }
  487. // Performance - Radar Chart
  488. // --------------------------------------------------------------------
  489. const performanceChartEl = document.querySelector('#performanceChart'),
  490. performanceChartConfig = {
  491. series: [
  492. {
  493. name: 'Income',
  494. data: [26, 29, 31, 40, 29, 24]
  495. },
  496. {
  497. name: 'Earning',
  498. data: [30, 26, 24, 26, 24, 40]
  499. }
  500. ],
  501. chart: {
  502. height: 310,
  503. type: 'radar',
  504. toolbar: {
  505. show: false
  506. },
  507. dropShadow: {
  508. enabled: true,
  509. enabledOnSeries: undefined,
  510. top: 6,
  511. left: 0,
  512. blur: 6,
  513. color: '#000',
  514. opacity: 0.14
  515. }
  516. },
  517. plotOptions: {
  518. radar: {
  519. polygons: {
  520. strokeColors: borderColor,
  521. connectorColors: borderColor
  522. }
  523. }
  524. },
  525. stroke: {
  526. show: false,
  527. width: 0
  528. },
  529. legend: {
  530. show: true,
  531. fontSize: '13px',
  532. position: 'bottom',
  533. labels: {
  534. colors: legendColor,
  535. useSeriesColors: false
  536. },
  537. markers: {
  538. size: 5,
  539. offsetX: -5,
  540. strokeWidth: 0
  541. },
  542. itemMargin: {
  543. horizontal: 10
  544. },
  545. onItemHover: {
  546. highlightDataSeries: false
  547. }
  548. },
  549. colors: [config.colors.primary, config.colors.info],
  550. fill: {
  551. opacity: [1, 0.85]
  552. },
  553. markers: {
  554. size: 0
  555. },
  556. grid: {
  557. show: false,
  558. padding: {
  559. top: -8,
  560. bottom: -5
  561. }
  562. },
  563. xaxis: {
  564. categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
  565. labels: {
  566. show: true,
  567. style: {
  568. colors: [labelColor, labelColor, labelColor, labelColor, labelColor, labelColor],
  569. fontSize: '13px',
  570. fontFamily: fontFamily
  571. }
  572. }
  573. },
  574. yaxis: {
  575. show: false,
  576. min: 0,
  577. max: 40,
  578. tickAmount: 4
  579. }
  580. };
  581. if (typeof performanceChartEl !== undefined && performanceChartEl !== null) {
  582. const performanceChart = new ApexCharts(performanceChartEl, performanceChartConfig);
  583. performanceChart.render();
  584. }
  585. // Conversion rate Line Chart
  586. // --------------------------------------------------------------------
  587. const conversionLineChartEl = document.querySelector('#conversionRateChart'),
  588. conversionLineChartConfig = {
  589. chart: {
  590. height: 80,
  591. width: 140,
  592. type: 'line',
  593. toolbar: {
  594. show: false
  595. },
  596. dropShadow: {
  597. enabled: true,
  598. top: 10,
  599. left: 5,
  600. blur: 3,
  601. color: config.colors.primary,
  602. opacity: 0.15
  603. },
  604. sparkline: {
  605. enabled: true
  606. }
  607. },
  608. markers: {
  609. size: 6,
  610. colors: 'transparent',
  611. strokeColors: 'transparent',
  612. strokeWidth: 4,
  613. discrete: [
  614. {
  615. fillColor: config.colors.white,
  616. seriesIndex: 0,
  617. dataPointIndex: 3,
  618. strokeColor: config.colors.primary,
  619. strokeWidth: 4,
  620. size: 6,
  621. radius: 2
  622. }
  623. ],
  624. offsetX: -1,
  625. hover: {
  626. size: 7
  627. }
  628. },
  629. grid: {
  630. show: false,
  631. padding: {
  632. right: 8
  633. }
  634. },
  635. colors: [config.colors.primary],
  636. dataLabels: {
  637. enabled: false
  638. },
  639. stroke: {
  640. width: 5,
  641. curve: 'smooth'
  642. },
  643. series: [
  644. {
  645. data: [137, 210, 160, 245]
  646. }
  647. ],
  648. xaxis: {
  649. show: false,
  650. lines: {
  651. show: false
  652. },
  653. labels: {
  654. show: false
  655. },
  656. axisBorder: {
  657. show: false
  658. }
  659. },
  660. yaxis: {
  661. show: false
  662. }
  663. };
  664. if (typeof conversionLineChartEl !== undefined && conversionLineChartEl !== null) {
  665. const conversionLineChart = new ApexCharts(conversionLineChartEl, conversionLineChartConfig);
  666. conversionLineChart.render();
  667. }
  668. // Conversion rate Line Chart
  669. // --------------------------------------------------------------------
  670. const expensesBarChartEl = document.querySelector('#expensesBarChart'),
  671. expensesBarChartConfig = {
  672. chart: {
  673. height: 190,
  674. stacked: true,
  675. type: 'bar',
  676. toolbar: { show: false }
  677. },
  678. series: [
  679. {
  680. name: '2021',
  681. data: [15, 37, 14, 30, 38, 30, 20, 13, 14, 23]
  682. },
  683. {
  684. name: '2020',
  685. data: [-33, -23, -29, -21, -25, -21, -23, -19, -37, -22]
  686. }
  687. ],
  688. plotOptions: {
  689. bar: {
  690. horizontal: false,
  691. columnWidth: '40%',
  692. borderRadius: 5,
  693. startingShape: 'rounded',
  694. endingShape: 'rounded',
  695. borderRadiusApplication: 'around'
  696. }
  697. },
  698. colors: [config.colors.primary, config.colors.warning],
  699. dataLabels: {
  700. enabled: false
  701. },
  702. stroke: {
  703. curve: 'smooth',
  704. width: 2,
  705. lineCap: 'round',
  706. colors: [cardColor]
  707. },
  708. legend: {
  709. show: false
  710. },
  711. grid: {
  712. show: false,
  713. padding: {
  714. top: -10
  715. }
  716. },
  717. fill: {
  718. opacity: [1, 1]
  719. },
  720. xaxis: {
  721. show: false,
  722. categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'],
  723. labels: {
  724. show: false
  725. },
  726. axisTicks: {
  727. show: false
  728. },
  729. axisBorder: {
  730. show: false
  731. }
  732. },
  733. yaxis: {
  734. show: false
  735. },
  736. states: {
  737. hover: {
  738. filter: {
  739. type: 'none'
  740. }
  741. },
  742. active: {
  743. filter: {
  744. type: 'none'
  745. }
  746. }
  747. }
  748. };
  749. if (typeof expensesBarChartEl !== undefined && expensesBarChartEl !== null) {
  750. const expensesBarChart = new ApexCharts(expensesBarChartEl, expensesBarChartConfig);
  751. expensesBarChart.render();
  752. }
  753. // Total Balance - Line Chart
  754. // --------------------------------------------------------------------
  755. const totalBalanceChartEl = document.querySelector('#totalBalanceChart'),
  756. totalBalanceChartConfig = {
  757. series: [
  758. {
  759. data: [137, 210, 160, 275, 205, 315]
  760. }
  761. ],
  762. chart: {
  763. height: 245,
  764. parentHeightOffset: 0,
  765. parentWidthOffset: 0,
  766. type: 'line',
  767. dropShadow: {
  768. enabled: true,
  769. top: 10,
  770. left: 5,
  771. blur: 3,
  772. color: config.colors.warning,
  773. opacity: 0.25
  774. },
  775. toolbar: {
  776. show: false
  777. }
  778. },
  779. dataLabels: {
  780. enabled: false
  781. },
  782. stroke: {
  783. width: 4,
  784. curve: 'smooth'
  785. },
  786. legend: {
  787. show: false
  788. },
  789. colors: [config.colors.warning],
  790. markers: {
  791. size: 6,
  792. colors: 'transparent',
  793. strokeColors: 'transparent',
  794. strokeWidth: 4,
  795. discrete: [
  796. {
  797. fillColor: config.colors.white,
  798. seriesIndex: 0,
  799. dataPointIndex: 5,
  800. strokeColor: config.colors.warning,
  801. strokeWidth: 8,
  802. size: 8,
  803. radius: 8
  804. }
  805. ],
  806. offsetX: -1,
  807. hover: {
  808. size: 9
  809. }
  810. },
  811. grid: {
  812. show: false,
  813. padding: {
  814. top: -10,
  815. left: 0,
  816. right: 0,
  817. bottom: 10
  818. }
  819. },
  820. xaxis: {
  821. categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
  822. axisBorder: {
  823. show: false
  824. },
  825. axisTicks: {
  826. show: false
  827. },
  828. labels: {
  829. show: true,
  830. style: {
  831. fontSize: '13px',
  832. fontFamily: fontFamily,
  833. colors: labelColor
  834. }
  835. }
  836. },
  837. yaxis: {
  838. labels: {
  839. show: false
  840. }
  841. }
  842. };
  843. if (typeof totalBalanceChartEl !== undefined && totalBalanceChartEl !== null) {
  844. const totalBalanceChart = new ApexCharts(totalBalanceChartEl, totalBalanceChartConfig);
  845. totalBalanceChart.render();
  846. }
  847. });