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.

73 lines
2.2 KiB

3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Document : db_analytics.js
  3. * Author : pixelcave
  4. * Description: Custom JS code used in Analytics Dashboard Page
  5. */
  6. // Chart.js Charts, for more examples you can check out http://www.chartjs.org/docs
  7. class pageDashboardAnalytics {
  8. /*
  9. * Init Charts
  10. *
  11. */
  12. static initChartsBars() {
  13. // Set Global Chart.js configuration
  14. Chart.defaults.color = '#818d96';
  15. Chart.defaults.scale.grid.color = 'transparent';
  16. Chart.defaults.scale.grid.zeroLineColor = 'transparent';
  17. Chart.defaults.scale.beginAtZero = true;
  18. Chart.defaults.elements.line.borderWidth = 1;
  19. Chart.defaults.plugins.legend.labels.boxWidth = 12;
  20. // Get Chart Containers
  21. let chartBarsCon = document.getElementById('js-chartjs-analytics-bars');
  22. // Set Chart and Chart Data variables
  23. let chartBars, chartLinesBarsData;
  24. // Bars Chart Data
  25. chartLinesBarsData = {
  26. labels: ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'],
  27. datasets: [
  28. {
  29. label: 'This Week',
  30. fill: true,
  31. backgroundColor: 'rgba(103, 114, 229, .75)',
  32. borderColor: 'rgba(103, 114, 229, 1)',
  33. pointBackgroundColor: 'rgba(103, 114, 229, 1)',
  34. pointBorderColor: '#fff',
  35. pointHoverBackgroundColor: '#fff',
  36. pointHoverBorderColor: 'rgba(103, 114, 229, 1)',
  37. data: [500, 750, 650, 570, 582, 480, 680]
  38. },
  39. {
  40. label: 'Last Week',
  41. fill: true,
  42. backgroundColor: 'rgba(108, 117, 125, .15)',
  43. borderColor: 'rgba(108, 117, 125, .75)',
  44. pointBackgroundColor: 'rgba(108, 117, 125, 1)',
  45. pointBorderColor: '#fff',
  46. pointHoverBackgroundColor: '#fff',
  47. pointHoverBorderColor: 'rgba(108, 117, 125, 1)',
  48. data: [352, 530, 541, 521, 410, 395, 460]
  49. }
  50. ]
  51. };
  52. // Init Chart
  53. if (chartBarsCon !== null) {
  54. chartBars = new Chart(chartBarsCon, {type: 'bar', data: chartLinesBarsData, options: { responsive: true, maintainAspectRatio: false }});
  55. }
  56. }
  57. /*
  58. * Init functionality
  59. *
  60. */
  61. static init() {
  62. this.initChartsBars();
  63. }
  64. }
  65. // Initialize when page loads
  66. Dashmix.onLoad(() => pageDashboardAnalytics.init());