Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

dashboards-analytics.js 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. /**
  2. * Dashboard Analytics
  3. */
  4. 'use strict';
  5. (function () {
  6. let cardColor, headingColor, labelColor, shadeColor, grayColor;
  7. if (isDarkStyle) {
  8. cardColor = config.colors_dark.cardColor;
  9. labelColor = config.colors_dark.textMuted;
  10. headingColor = config.colors_dark.headingColor;
  11. shadeColor = 'dark';
  12. grayColor = '#5E6692'; // gray color is for stacked bar chart
  13. } else {
  14. cardColor = config.colors.cardColor;
  15. labelColor = config.colors.textMuted;
  16. headingColor = config.colors.headingColor;
  17. shadeColor = '';
  18. grayColor = '#817D8D';
  19. }
  20. // swiper loop and autoplay
  21. // --------------------------------------------------------------------
  22. const swiperWithPagination = document.querySelector('#swiper-with-pagination-cards');
  23. if (swiperWithPagination) {
  24. new Swiper(swiperWithPagination, {
  25. loop: true,
  26. autoplay: {
  27. delay: 2500,
  28. disableOnInteraction: false
  29. },
  30. pagination: {
  31. clickable: true,
  32. el: '.swiper-pagination'
  33. }
  34. });
  35. }
  36. // Revenue Generated Area Chart
  37. // --------------------------------------------------------------------
  38. const revenueGeneratedEl = document.querySelector('#revenueGenerated'),
  39. revenueGeneratedConfig = {
  40. chart: {
  41. height: 130,
  42. type: 'area',
  43. parentHeightOffset: 0,
  44. toolbar: {
  45. show: false
  46. },
  47. sparkline: {
  48. enabled: true
  49. }
  50. },
  51. markers: {
  52. colors: 'transparent',
  53. strokeColors: 'transparent'
  54. },
  55. grid: {
  56. show: false
  57. },
  58. colors: [config.colors.success],
  59. fill: {
  60. type: 'gradient',
  61. gradient: {
  62. shade: shadeColor,
  63. shadeIntensity: 0.8,
  64. opacityFrom: 0.6,
  65. opacityTo: 0.1
  66. }
  67. },
  68. dataLabels: {
  69. enabled: false
  70. },
  71. stroke: {
  72. width: 2,
  73. curve: 'smooth'
  74. },
  75. series: [
  76. {
  77. data: [300, 350, 330, 380, 340, 400, 380]
  78. }
  79. ],
  80. xaxis: {
  81. show: true,
  82. lines: {
  83. show: false
  84. },
  85. labels: {
  86. show: false
  87. },
  88. stroke: {
  89. width: 0
  90. },
  91. axisBorder: {
  92. show: false
  93. }
  94. },
  95. yaxis: {
  96. stroke: {
  97. width: 0
  98. },
  99. show: false
  100. },
  101. tooltip: {
  102. enabled: false
  103. }
  104. };
  105. if (typeof revenueGeneratedEl !== undefined && revenueGeneratedEl !== null) {
  106. const revenueGenerated = new ApexCharts(revenueGeneratedEl, revenueGeneratedConfig);
  107. revenueGenerated.render();
  108. }
  109. // Earning Reports Bar Chart
  110. // --------------------------------------------------------------------
  111. const weeklyEarningReportsEl = document.querySelector('#weeklyEarningReports'),
  112. weeklyEarningReportsConfig = {
  113. chart: {
  114. height: 202,
  115. parentHeightOffset: 0,
  116. type: 'bar',
  117. toolbar: {
  118. show: false
  119. }
  120. },
  121. plotOptions: {
  122. bar: {
  123. barHeight: '60%',
  124. columnWidth: '38%',
  125. startingShape: 'rounded',
  126. endingShape: 'rounded',
  127. borderRadius: 4,
  128. distributed: true
  129. }
  130. },
  131. grid: {
  132. show: false,
  133. padding: {
  134. top: -30,
  135. bottom: 0,
  136. left: -10,
  137. right: -10
  138. }
  139. },
  140. colors: [
  141. config.colors_label.primary,
  142. config.colors_label.primary,
  143. config.colors_label.primary,
  144. config.colors_label.primary,
  145. config.colors.primary,
  146. config.colors_label.primary,
  147. config.colors_label.primary
  148. ],
  149. dataLabels: {
  150. enabled: false
  151. },
  152. series: [
  153. {
  154. data: [40, 65, 50, 45, 90, 55, 70]
  155. }
  156. ],
  157. legend: {
  158. show: false
  159. },
  160. xaxis: {
  161. categories: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
  162. axisBorder: {
  163. show: false
  164. },
  165. axisTicks: {
  166. show: false
  167. },
  168. labels: {
  169. style: {
  170. colors: labelColor,
  171. fontSize: '13px',
  172. fontFamily: 'Public Sans'
  173. }
  174. }
  175. },
  176. yaxis: {
  177. labels: {
  178. show: false
  179. }
  180. },
  181. tooltip: {
  182. enabled: false
  183. },
  184. responsive: [
  185. {
  186. breakpoint: 1025,
  187. options: {
  188. chart: {
  189. height: 199
  190. }
  191. }
  192. }
  193. ]
  194. };
  195. if (typeof weeklyEarningReportsEl !== undefined && weeklyEarningReportsEl !== null) {
  196. const weeklyEarningReports = new ApexCharts(weeklyEarningReportsEl, weeklyEarningReportsConfig);
  197. weeklyEarningReports.render();
  198. }
  199. // Support Tracker - Radial Bar Chart
  200. // --------------------------------------------------------------------
  201. const supportTrackerEl = document.querySelector('#supportTracker'),
  202. supportTrackerOptions = {
  203. series: [85],
  204. labels: ['Completed Task'],
  205. chart: {
  206. height: 360,
  207. type: 'radialBar'
  208. },
  209. plotOptions: {
  210. radialBar: {
  211. offsetY: 10,
  212. startAngle: -140,
  213. endAngle: 130,
  214. hollow: {
  215. size: '65%'
  216. },
  217. track: {
  218. background: cardColor,
  219. strokeWidth: '100%'
  220. },
  221. dataLabels: {
  222. name: {
  223. offsetY: -20,
  224. color: labelColor,
  225. fontSize: '13px',
  226. fontWeight: '400',
  227. fontFamily: 'Public Sans'
  228. },
  229. value: {
  230. offsetY: 10,
  231. color: headingColor,
  232. fontSize: '38px',
  233. fontWeight: '500',
  234. fontFamily: 'Public Sans'
  235. }
  236. }
  237. }
  238. },
  239. colors: [config.colors.primary],
  240. fill: {
  241. type: 'gradient',
  242. gradient: {
  243. shade: 'dark',
  244. shadeIntensity: 0.5,
  245. gradientToColors: [config.colors.primary],
  246. inverseColors: true,
  247. opacityFrom: 1,
  248. opacityTo: 0.6,
  249. stops: [30, 70, 100]
  250. }
  251. },
  252. stroke: {
  253. dashArray: 10
  254. },
  255. grid: {
  256. padding: {
  257. top: -20,
  258. bottom: 5
  259. }
  260. },
  261. states: {
  262. hover: {
  263. filter: {
  264. type: 'none'
  265. }
  266. },
  267. active: {
  268. filter: {
  269. type: 'none'
  270. }
  271. }
  272. },
  273. responsive: [
  274. {
  275. breakpoint: 1025,
  276. options: {
  277. chart: {
  278. height: 330
  279. }
  280. }
  281. },
  282. {
  283. breakpoint: 769,
  284. options: {
  285. chart: {
  286. height: 280
  287. }
  288. }
  289. }
  290. ]
  291. };
  292. if (typeof supportTrackerEl !== undefined && supportTrackerEl !== null) {
  293. const supportTracker = new ApexCharts(supportTrackerEl, supportTrackerOptions);
  294. supportTracker.render();
  295. }
  296. // Total Earning Chart - Bar Chart
  297. // --------------------------------------------------------------------
  298. const totalEarningChartEl = document.querySelector('#totalEarningChart'),
  299. totalEarningChartOptions = {
  300. series: [
  301. {
  302. name: 'Earning',
  303. data: [15, 10, 20, 8, 12, 18, 12, 5]
  304. },
  305. {
  306. name: 'Expense',
  307. data: [-7, -10, -7, -12, -6, -9, -5, -8]
  308. }
  309. ],
  310. chart: {
  311. height: 230,
  312. parentHeightOffset: 0,
  313. stacked: true,
  314. type: 'bar',
  315. toolbar: { show: false }
  316. },
  317. tooltip: {
  318. enabled: false
  319. },
  320. legend: {
  321. show: false
  322. },
  323. plotOptions: {
  324. bar: {
  325. horizontal: false,
  326. columnWidth: '18%',
  327. borderRadius: 5,
  328. startingShape: 'rounded',
  329. endingShape: 'rounded'
  330. }
  331. },
  332. colors: [config.colors.primary, grayColor],
  333. dataLabels: {
  334. enabled: false
  335. },
  336. grid: {
  337. show: false,
  338. padding: {
  339. top: -40,
  340. bottom: -20,
  341. left: -10,
  342. right: -2
  343. }
  344. },
  345. xaxis: {
  346. labels: {
  347. show: false
  348. },
  349. axisTicks: {
  350. show: false
  351. },
  352. axisBorder: {
  353. show: false
  354. }
  355. },
  356. yaxis: {
  357. labels: {
  358. show: false
  359. }
  360. },
  361. responsive: [
  362. {
  363. breakpoint: 1468,
  364. options: {
  365. plotOptions: {
  366. bar: {
  367. columnWidth: '22%'
  368. }
  369. }
  370. }
  371. },
  372. {
  373. breakpoint: 1197,
  374. options: {
  375. chart: {
  376. height: 228
  377. },
  378. plotOptions: {
  379. bar: {
  380. borderRadius: 8,
  381. columnWidth: '26%'
  382. }
  383. }
  384. }
  385. },
  386. {
  387. breakpoint: 783,
  388. options: {
  389. chart: {
  390. height: 232
  391. },
  392. plotOptions: {
  393. bar: {
  394. borderRadius: 6,
  395. columnWidth: '28%'
  396. }
  397. }
  398. }
  399. },
  400. {
  401. breakpoint: 589,
  402. options: {
  403. plotOptions: {
  404. bar: {
  405. columnWidth: '16%'
  406. }
  407. }
  408. }
  409. },
  410. {
  411. breakpoint: 520,
  412. options: {
  413. plotOptions: {
  414. bar: {
  415. borderRadius: 6,
  416. columnWidth: '18%'
  417. }
  418. }
  419. }
  420. },
  421. {
  422. breakpoint: 426,
  423. options: {
  424. plotOptions: {
  425. bar: {
  426. borderRadius: 5,
  427. columnWidth: '20%'
  428. }
  429. }
  430. }
  431. },
  432. {
  433. breakpoint: 381,
  434. options: {
  435. plotOptions: {
  436. bar: {
  437. columnWidth: '24%'
  438. }
  439. }
  440. }
  441. }
  442. ],
  443. states: {
  444. hover: {
  445. filter: {
  446. type: 'none'
  447. }
  448. },
  449. active: {
  450. filter: {
  451. type: 'none'
  452. }
  453. }
  454. }
  455. };
  456. if (typeof totalEarningChartEl !== undefined && totalEarningChartEl !== null) {
  457. const totalEarningChart = new ApexCharts(totalEarningChartEl, totalEarningChartOptions);
  458. totalEarningChart.render();
  459. }
  460. // For Datatable
  461. // --------------------------------------------------------------------
  462. var dt_projects_table = $('.datatables-projects');
  463. if (dt_projects_table.length) {
  464. var dt_project = dt_projects_table.DataTable({
  465. ajax: assetsPath + 'json/user-profile.json',
  466. columns: [
  467. { data: '' },
  468. { data: 'id' },
  469. { data: 'project_name' },
  470. { data: 'project_leader' },
  471. { data: '' },
  472. { data: 'status' },
  473. { data: '' }
  474. ],
  475. columnDefs: [
  476. {
  477. // For Responsive
  478. className: 'control',
  479. searchable: false,
  480. orderable: false,
  481. responsivePriority: 2,
  482. targets: 0,
  483. render: function (data, type, full, meta) {
  484. return '';
  485. }
  486. },
  487. {
  488. // For Checkboxes
  489. targets: 1,
  490. orderable: false,
  491. searchable: false,
  492. responsivePriority: 3,
  493. checkboxes: true,
  494. render: function () {
  495. return '<input type="checkbox" class="dt-checkboxes form-check-input">';
  496. },
  497. checkboxes: {
  498. selectAllRender: '<input type="checkbox" class="form-check-input">'
  499. }
  500. },
  501. {
  502. // Avatar image/badge, Name and post
  503. targets: 2,
  504. responsivePriority: 4,
  505. render: function (data, type, full, meta) {
  506. var $user_img = full['project_img'],
  507. $name = full['project_name'],
  508. $date = full['date'];
  509. if ($user_img) {
  510. // For Avatar image
  511. var $output =
  512. '<img src="' + assetsPath + 'img/icons/brands/' + $user_img + '" alt="Avatar" class="rounded-circle">';
  513. } else {
  514. // For Avatar badge
  515. var stateNum = Math.floor(Math.random() * 6);
  516. var states = ['success', 'danger', 'warning', 'info', 'primary', 'secondary'];
  517. var $state = states[stateNum],
  518. $name = full['project_name'],
  519. $initials = $name.match(/\b\w/g) || [];
  520. $initials = (($initials.shift() || '') + ($initials.pop() || '')).toUpperCase();
  521. $output = '<span class="avatar-initial rounded-circle bg-label-' + $state + '">' + $initials + '</span>';
  522. }
  523. // Creates full output for row
  524. var $row_output =
  525. '<div class="d-flex justify-content-left align-items-center">' +
  526. '<div class="avatar-wrapper">' +
  527. '<div class="avatar me-2">' +
  528. $output +
  529. '</div>' +
  530. '</div>' +
  531. '<div class="d-flex flex-column">' +
  532. '<span class="text-truncate fw-medium">' +
  533. $name +
  534. '</span>' +
  535. '<small class="text-truncate text-muted">' +
  536. $date +
  537. '</small>' +
  538. '</div>' +
  539. '</div>';
  540. return $row_output;
  541. }
  542. },
  543. {
  544. // Teams
  545. targets: 4,
  546. orderable: false,
  547. searchable: false,
  548. render: function (data, type, full, meta) {
  549. var $team = full['team'],
  550. $output;
  551. $output = '<div class="d-flex align-items-center avatar-group">';
  552. for (var i = 0; i < $team.length; i++) {
  553. $output +=
  554. '<div class="avatar avatar-sm">' +
  555. '<img src="' +
  556. assetsPath +
  557. 'img/avatars/' +
  558. $team[i] +
  559. '" alt="Avatar" class="rounded-circle pull-up">' +
  560. '</div>';
  561. }
  562. $output += '</div>';
  563. return $output;
  564. }
  565. },
  566. {
  567. // Label
  568. targets: -2,
  569. render: function (data, type, full, meta) {
  570. var $status_number = full['status'];
  571. return (
  572. '<div class="d-flex align-items-center">' +
  573. '<div class="progress w-100 me-3" style="height: 6px;">' +
  574. '<div class="progress-bar" style="width: ' +
  575. $status_number +
  576. '" aria-valuenow="' +
  577. $status_number +
  578. '" aria-valuemin="0" aria-valuemax="100"></div>' +
  579. '</div>' +
  580. '<span>' +
  581. $status_number +
  582. '</span></div>'
  583. );
  584. }
  585. },
  586. {
  587. // Actions
  588. targets: -1,
  589. searchable: false,
  590. title: 'Actions',
  591. orderable: false,
  592. render: function (data, type, full, meta) {
  593. return (
  594. '<div class="d-inline-block">' +
  595. '<a href="javascript:;" class="btn btn-sm btn-icon dropdown-toggle hide-arrow" data-bs-toggle="dropdown"><i class="ti ti-dots-vertical"></i></a>' +
  596. '<div class="dropdown-menu dropdown-menu-end m-0">' +
  597. '<a href="javascript:;" class="dropdown-item">Details</a>' +
  598. '<a href="javascript:;" class="dropdown-item">Archive</a>' +
  599. '<div class="dropdown-divider"></div>' +
  600. '<a href="javascript:;" class="dropdown-item text-danger delete-record">Delete</a>' +
  601. '</div>' +
  602. '</div>'
  603. );
  604. }
  605. }
  606. ],
  607. order: [[2, 'desc']],
  608. dom: '<"card-header pb-0 pt-sm-0"<"head-label text-center"><"d-flex justify-content-center justify-content-md-end"f>>t<"row mx-2"<"col-sm-12 col-md-6"i><"col-sm-12 col-md-6"p>>',
  609. displayLength: 5,
  610. lengthMenu: [5, 10, 25, 50, 75, 100],
  611. responsive: {
  612. details: {
  613. display: $.fn.dataTable.Responsive.display.modal({
  614. header: function (row) {
  615. var data = row.data();
  616. return 'Details of "' + data['project_name'] + '" Project';
  617. }
  618. }),
  619. type: 'column',
  620. renderer: function (api, rowIdx, columns) {
  621. var data = $.map(columns, function (col, i) {
  622. return col.title !== '' // ? Do not show row in modal popup if title is blank (for check box)
  623. ? '<tr data-dt-row="' +
  624. col.rowIndex +
  625. '" data-dt-column="' +
  626. col.columnIndex +
  627. '">' +
  628. '<td>' +
  629. col.title +
  630. ':' +
  631. '</td> ' +
  632. '<td>' +
  633. col.data +
  634. '</td>' +
  635. '</tr>'
  636. : '';
  637. }).join('');
  638. return data ? $('<table class="table"/><tbody />').append(data) : false;
  639. }
  640. }
  641. }
  642. });
  643. $('div.head-label').html('<h5 class="card-title mb-0">Projects</h5>');
  644. }
  645. // Filter form control to default size
  646. // ? setTimeout used for multilingual table initialization
  647. setTimeout(() => {
  648. $('.dataTables_filter .form-control').removeClass('form-control-sm');
  649. $('.dataTables_length .form-select').removeClass('form-select-sm');
  650. }, 300);
  651. })();