暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

cards-statistics.js 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. /**
  2. * Statistics Cards
  3. */
  4. 'use strict';
  5. document.addEventListener('DOMContentLoaded', function (e) {
  6. let cardColor, shadeColor, labelColor, headingColor, fontFamily, legendColor;
  7. if (isDarkStyle) {
  8. shadeColor = 'dark';
  9. } else {
  10. shadeColor = 'light';
  11. }
  12. cardColor = config.colors.cardColor;
  13. labelColor = config.colors.textMuted;
  14. legendColor = config.colors.bodyColor;
  15. headingColor = config.colors.headingColor;
  16. fontFamily = config.fontFamily;
  17. // Donut Chart Colors
  18. const chartColors = {
  19. donut: {
  20. series1: '#66C732',
  21. series2: '#8DE45F',
  22. series3: '#AAEB87',
  23. series4: '#E3F8D7'
  24. }
  25. };
  26. // Order Area Chart
  27. // --------------------------------------------------------------------
  28. const orderAreaChartEl = document.querySelector('#orderChart'),
  29. orderAreaChartConfig = {
  30. chart: {
  31. height: 104,
  32. type: 'area',
  33. toolbar: {
  34. show: false
  35. },
  36. sparkline: {
  37. enabled: true
  38. }
  39. },
  40. markers: {
  41. size: 6,
  42. colors: 'transparent',
  43. strokeColors: 'transparent',
  44. strokeWidth: 4,
  45. discrete: [
  46. {
  47. fillColor: cardColor,
  48. seriesIndex: 0,
  49. dataPointIndex: 6,
  50. strokeColor: config.colors.success,
  51. strokeWidth: 2,
  52. size: 5,
  53. radius: 8
  54. }
  55. ],
  56. hover: {
  57. size: 7
  58. }
  59. },
  60. grid: {
  61. show: false,
  62. padding: {
  63. top: 15,
  64. right: 7,
  65. left: 0
  66. }
  67. },
  68. colors: [config.colors.success],
  69. fill: {
  70. type: 'gradient',
  71. gradient: {
  72. shadeIntensity: 1,
  73. opacityFrom: 0.4,
  74. gradientToColors: [config.colors.cardColor],
  75. opacityTo: 0.4,
  76. stops: [0, 100]
  77. }
  78. },
  79. dataLabels: {
  80. enabled: false
  81. },
  82. stroke: {
  83. width: 2,
  84. curve: 'smooth'
  85. },
  86. series: [
  87. {
  88. data: [180, 175, 275, 140, 205, 190, 295]
  89. }
  90. ],
  91. xaxis: {
  92. show: false,
  93. lines: {
  94. show: false
  95. },
  96. labels: {
  97. show: false
  98. },
  99. stroke: {
  100. width: 0
  101. },
  102. axisBorder: {
  103. show: false
  104. }
  105. },
  106. yaxis: {
  107. stroke: {
  108. width: 0
  109. },
  110. show: false
  111. }
  112. };
  113. if (typeof orderAreaChartEl !== undefined && orderAreaChartEl !== null) {
  114. const orderAreaChart = new ApexCharts(orderAreaChartEl, orderAreaChartConfig);
  115. orderAreaChart.render();
  116. }
  117. // Revenue Bar Chart
  118. // --------------------------------------------------------------------
  119. const revenueBarChartEl = document.querySelector('#revenueChart'),
  120. revenueBarChartConfig = {
  121. chart: {
  122. height: 95,
  123. type: 'bar',
  124. toolbar: {
  125. show: false
  126. }
  127. },
  128. plotOptions: {
  129. bar: {
  130. barHeight: '80%',
  131. columnWidth: '54%',
  132. startingShape: 'rounded',
  133. endingShape: 'rounded',
  134. borderRadius: 2,
  135. distributed: true
  136. }
  137. },
  138. grid: {
  139. show: false,
  140. padding: {
  141. top: -20,
  142. bottom: -12,
  143. left: -10,
  144. right: 0
  145. }
  146. },
  147. colors: [
  148. config.colors_label.primary,
  149. config.colors_label.primary,
  150. config.colors_label.primary,
  151. config.colors_label.primary,
  152. config.colors.primary,
  153. config.colors_label.primary,
  154. config.colors_label.primary
  155. ],
  156. dataLabels: {
  157. enabled: false
  158. },
  159. series: [
  160. {
  161. data: [40, 95, 60, 45, 90, 50, 75]
  162. }
  163. ],
  164. states: {
  165. hover: {
  166. filter: {
  167. type: 'none'
  168. }
  169. },
  170. active: {
  171. filter: {
  172. type: 'none'
  173. }
  174. }
  175. },
  176. legend: {
  177. show: false
  178. },
  179. xaxis: {
  180. categories: ['M', 'T', 'W', 'T', 'F', 'S', 'S'],
  181. axisBorder: {
  182. show: false
  183. },
  184. axisTicks: {
  185. show: false
  186. },
  187. labels: {
  188. style: {
  189. colors: labelColor,
  190. fontSize: '13px'
  191. }
  192. }
  193. },
  194. yaxis: {
  195. labels: {
  196. show: false
  197. }
  198. }
  199. };
  200. if (typeof revenueBarChartEl !== undefined && revenueBarChartEl !== null) {
  201. const revenueBarChart = new ApexCharts(revenueBarChartEl, revenueBarChartConfig);
  202. revenueBarChart.render();
  203. }
  204. // Profit Bar Chart
  205. // --------------------------------------------------------------------
  206. const profitBarChartEl = document.querySelector('#profitChart'),
  207. profitBarChartConfig = {
  208. series: [
  209. {
  210. data: [73, 56, 56, 100]
  211. },
  212. {
  213. data: [61, 42, 74, 72]
  214. }
  215. ],
  216. chart: {
  217. type: 'bar',
  218. height: 90,
  219. toolbar: {
  220. tools: {
  221. download: false
  222. }
  223. }
  224. },
  225. plotOptions: {
  226. bar: {
  227. columnWidth: '69%',
  228. startingShape: 'rounded',
  229. endingShape: 'rounded',
  230. borderRadius: 3,
  231. dataLabels: {
  232. show: false
  233. }
  234. }
  235. },
  236. states: {
  237. hover: {
  238. filter: {
  239. type: 'none'
  240. }
  241. },
  242. active: {
  243. filter: {
  244. type: 'none'
  245. }
  246. }
  247. },
  248. grid: {
  249. show: false,
  250. padding: {
  251. top: -30,
  252. bottom: -12,
  253. left: -10,
  254. right: 0
  255. }
  256. },
  257. colors: [config.colors.success, config.colors_label.success],
  258. dataLabels: {
  259. enabled: false
  260. },
  261. stroke: {
  262. show: true,
  263. width: 5,
  264. colors: cardColor
  265. },
  266. legend: {
  267. show: false
  268. },
  269. xaxis: {
  270. categories: ['Jan', 'Apr', 'Jul', 'Oct'],
  271. axisBorder: {
  272. show: false
  273. },
  274. axisTicks: {
  275. show: false
  276. },
  277. labels: {
  278. style: {
  279. colors: labelColor,
  280. fontSize: '13px'
  281. }
  282. }
  283. },
  284. yaxis: {
  285. labels: {
  286. show: false
  287. }
  288. }
  289. };
  290. if (typeof profitBarChartEl !== undefined && profitBarChartEl !== null) {
  291. const profitBarChart = new ApexCharts(profitBarChartEl, profitBarChartConfig);
  292. profitBarChart.render();
  293. }
  294. // Session Area Chart
  295. // --------------------------------------------------------------------
  296. const sessionAreaChartEl = document.querySelector('#sessionsChart'),
  297. sessionAreaChartConfig = {
  298. chart: {
  299. height: 104,
  300. type: 'area',
  301. toolbar: {
  302. show: false
  303. },
  304. sparkline: {
  305. enabled: true
  306. }
  307. },
  308. markers: {
  309. size: 6,
  310. colors: 'transparent',
  311. strokeColors: 'transparent',
  312. strokeWidth: 4,
  313. discrete: [
  314. {
  315. fillColor: cardColor,
  316. seriesIndex: 0,
  317. dataPointIndex: 8,
  318. strokeColor: config.colors.warning,
  319. strokeWidth: 2,
  320. size: 5,
  321. radius: 8
  322. }
  323. ],
  324. hover: {
  325. size: 7
  326. }
  327. },
  328. grid: {
  329. show: false,
  330. padding: {
  331. right: 8
  332. }
  333. },
  334. colors: [config.colors.warning],
  335. fill: {
  336. type: 'gradient',
  337. gradient: {
  338. shadeIntensity: 1,
  339. opacityFrom: 0.4,
  340. gradientToColors: [config.colors.cardColor],
  341. opacityTo: 0.4,
  342. stops: [0, 85, 100]
  343. }
  344. },
  345. dataLabels: {
  346. enabled: false
  347. },
  348. stroke: {
  349. width: 2,
  350. curve: 'straight'
  351. },
  352. series: [
  353. {
  354. data: [340, 340, 300, 300, 240, 240, 320, 320, 370]
  355. }
  356. ],
  357. xaxis: {
  358. show: false,
  359. lines: {
  360. show: false
  361. },
  362. labels: {
  363. show: false
  364. },
  365. axisBorder: {
  366. show: false
  367. }
  368. },
  369. yaxis: {
  370. show: false
  371. }
  372. };
  373. if (typeof sessionAreaChartEl !== undefined && sessionAreaChartEl !== null) {
  374. const sessionAreaChart = new ApexCharts(sessionAreaChartEl, sessionAreaChartConfig);
  375. sessionAreaChart.render();
  376. }
  377. // Total Sales Radial Bar Chart
  378. // --------------------------------------------------------------------
  379. const expensesRadialChartEl = document.querySelector('#expensesChart'),
  380. expensesRadialChartConfig = {
  381. chart: {
  382. sparkline: {
  383. enabled: true
  384. },
  385. parentHeightOffset: 0,
  386. type: 'radialBar'
  387. },
  388. colors: [config.colors.primary],
  389. series: [78],
  390. plotOptions: {
  391. radialBar: {
  392. startAngle: -90,
  393. endAngle: 90,
  394. hollow: {
  395. size: '65%'
  396. },
  397. track: {
  398. background: config.colors_label.secondary
  399. },
  400. dataLabels: {
  401. name: {
  402. show: false
  403. },
  404. value: {
  405. fontSize: '18px',
  406. fontFamily: fontFamily,
  407. color: headingColor,
  408. fontWeight: 500,
  409. offsetY: -5
  410. }
  411. }
  412. }
  413. },
  414. grid: {
  415. show: false,
  416. padding: {
  417. left: -10,
  418. right: -10,
  419. bottom: 5
  420. }
  421. },
  422. stroke: {
  423. lineCap: 'round'
  424. },
  425. labels: ['Progress']
  426. };
  427. if (typeof expensesRadialChartEl !== undefined && expensesRadialChartEl !== null) {
  428. const expensesRadialChart = new ApexCharts(expensesRadialChartEl, expensesRadialChartConfig);
  429. expensesRadialChart.render();
  430. }
  431. // Visitor Bar Chart
  432. // --------------------------------------------------------------------
  433. const visitorBarChartEl = document.querySelector('#visitorsChart'),
  434. visitorBarChartConfig = {
  435. chart: {
  436. height: 120,
  437. width: 200,
  438. parentHeightOffset: 0,
  439. type: 'bar',
  440. toolbar: {
  441. show: false
  442. }
  443. },
  444. plotOptions: {
  445. bar: {
  446. barHeight: '75%',
  447. columnWidth: '54%',
  448. startingShape: 'rounded',
  449. endingShape: 'rounded',
  450. borderRadius: 5,
  451. distributed: true
  452. }
  453. },
  454. grid: {
  455. show: false,
  456. padding: {
  457. top: -25,
  458. bottom: -12
  459. }
  460. },
  461. states: {
  462. hover: {
  463. filter: {
  464. type: 'none'
  465. }
  466. },
  467. active: {
  468. filter: {
  469. type: 'none'
  470. }
  471. }
  472. },
  473. colors: [
  474. config.colors_label.primary,
  475. config.colors_label.primary,
  476. config.colors_label.primary,
  477. config.colors_label.primary,
  478. config.colors_label.primary,
  479. config.colors.primary,
  480. config.colors_label.primary
  481. ],
  482. dataLabels: {
  483. enabled: false
  484. },
  485. series: [
  486. {
  487. data: [40, 95, 60, 45, 90, 50, 75]
  488. }
  489. ],
  490. legend: {
  491. show: false
  492. },
  493. xaxis: {
  494. categories: ['M', 'T', 'W', 'T', 'F', 'S', 'S'],
  495. axisBorder: {
  496. show: false
  497. },
  498. axisTicks: {
  499. show: false
  500. },
  501. labels: {
  502. style: {
  503. colors: labelColor,
  504. fontSize: '13px'
  505. }
  506. }
  507. },
  508. yaxis: {
  509. labels: {
  510. show: false
  511. }
  512. },
  513. responsive: [
  514. {
  515. breakpoint: 1440,
  516. options: {
  517. plotOptions: {
  518. bar: {
  519. borderRadius: 9,
  520. columnWidth: '60%'
  521. }
  522. }
  523. }
  524. },
  525. {
  526. breakpoint: 1300,
  527. options: {
  528. plotOptions: {
  529. bar: {
  530. borderRadius: 9,
  531. columnWidth: '60%'
  532. }
  533. }
  534. }
  535. },
  536. {
  537. breakpoint: 1200,
  538. options: {
  539. plotOptions: {
  540. bar: {
  541. borderRadius: 8,
  542. columnWidth: '50%'
  543. }
  544. }
  545. }
  546. },
  547. {
  548. breakpoint: 1040,
  549. options: {
  550. plotOptions: {
  551. bar: {
  552. borderRadius: 8,
  553. columnWidth: '50%'
  554. }
  555. }
  556. }
  557. },
  558. {
  559. breakpoint: 991,
  560. options: {
  561. plotOptions: {
  562. bar: {
  563. borderRadius: 8,
  564. columnWidth: '50%'
  565. }
  566. }
  567. }
  568. },
  569. {
  570. breakpoint: 420,
  571. options: {
  572. plotOptions: {
  573. bar: {
  574. borderRadius: 8,
  575. columnWidth: '50%'
  576. }
  577. }
  578. }
  579. }
  580. ]
  581. };
  582. if (typeof visitorBarChartEl !== undefined && visitorBarChartEl !== null) {
  583. const visitorBarChart = new ApexCharts(visitorBarChartEl, visitorBarChartConfig);
  584. visitorBarChart.render();
  585. }
  586. // Activity Area Chart
  587. // --------------------------------------------------------------------
  588. const activityAreaChartEl = document.querySelector('#activityChart'),
  589. activityAreaChartConfig = {
  590. chart: {
  591. height: 110,
  592. width: 220,
  593. parentHeightOffset: 0,
  594. toolbar: {
  595. show: false
  596. },
  597. type: 'area'
  598. },
  599. dataLabels: {
  600. enabled: false
  601. },
  602. stroke: {
  603. width: 2,
  604. curve: 'smooth'
  605. },
  606. series: [
  607. {
  608. data: [15, 22, 17, 39, 12, 35, 25]
  609. }
  610. ],
  611. colors: [config.colors.success],
  612. fill: {
  613. type: 'gradient',
  614. gradient: {
  615. shadeIntensity: 1,
  616. opacityFrom: 0.7,
  617. gradientToColors: [config.colors.cardColor],
  618. opacityTo: 0.2,
  619. stops: [0, 85, 100]
  620. }
  621. },
  622. grid: {
  623. show: false,
  624. padding: {
  625. top: -20,
  626. bottom: -8
  627. }
  628. },
  629. legend: {
  630. show: false
  631. },
  632. xaxis: {
  633. categories: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
  634. axisBorder: {
  635. show: false
  636. },
  637. axisTicks: {
  638. show: false
  639. },
  640. labels: {
  641. style: {
  642. fontSize: '13px',
  643. colors: labelColor
  644. }
  645. }
  646. },
  647. yaxis: {
  648. labels: {
  649. show: false
  650. }
  651. }
  652. };
  653. if (typeof activityAreaChartEl !== undefined && activityAreaChartEl !== null) {
  654. const activityAreaChart = new ApexCharts(activityAreaChartEl, activityAreaChartConfig);
  655. activityAreaChart.render();
  656. }
  657. // Order Statistics Chart
  658. // --------------------------------------------------------------------
  659. const leadsReportChartEl = document.querySelector('#leadsReportChart'),
  660. leadsReportChartConfig = {
  661. chart: {
  662. height: 157,
  663. width: 130,
  664. parentHeightOffset: 0,
  665. type: 'donut'
  666. },
  667. labels: ['Electronic', 'Sports', 'Decor', 'Fashion'],
  668. series: [20, 30, 20, 30],
  669. colors: [
  670. chartColors.donut.series1,
  671. chartColors.donut.series4,
  672. chartColors.donut.series3,
  673. chartColors.donut.series2
  674. ],
  675. stroke: {
  676. width: 0
  677. },
  678. dataLabels: {
  679. enabled: false,
  680. formatter: function (val, opt) {
  681. return parseInt(val) + '%';
  682. }
  683. },
  684. legend: {
  685. show: false
  686. },
  687. tooltip: {
  688. theme: false
  689. },
  690. grid: {
  691. padding: {
  692. top: 15
  693. }
  694. },
  695. states: {
  696. hover: {
  697. filter: {
  698. type: 'none'
  699. }
  700. },
  701. active: {
  702. filter: {
  703. type: 'none'
  704. }
  705. }
  706. },
  707. plotOptions: {
  708. pie: {
  709. donut: {
  710. size: '75%',
  711. labels: {
  712. show: true,
  713. value: {
  714. fontSize: '1.5rem',
  715. fontFamily: fontFamily,
  716. color: headingColor,
  717. fontWeight: 500,
  718. offsetY: -15,
  719. formatter: function (val) {
  720. return parseInt(val) + '%';
  721. }
  722. },
  723. name: {
  724. offsetY: 20,
  725. fontFamily: fontFamily
  726. },
  727. total: {
  728. show: true,
  729. fontSize: '15px',
  730. fontFamily: fontFamily,
  731. label: 'Average',
  732. color: legendColor,
  733. formatter: function (w) {
  734. return '25%';
  735. }
  736. }
  737. }
  738. }
  739. }
  740. }
  741. };
  742. if (typeof leadsReportChartEl !== undefined && leadsReportChartEl !== null) {
  743. const leadsReportChart = new ApexCharts(leadsReportChartEl, leadsReportChartConfig);
  744. leadsReportChart.render();
  745. }
  746. });