dashboard3.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* global Chart:false */
  2. $(function () {
  3. 'use strict'
  4. var ticksStyle = {
  5. fontColor: '#495057',
  6. fontStyle: 'bold'
  7. }
  8. var mode = 'index'
  9. var intersect = true
  10. var $salesChart = $('#sales-chart')
  11. // eslint-disable-next-line no-unused-vars
  12. var salesChart = new Chart($salesChart, {
  13. type: 'bar',
  14. data: {
  15. labels: ['JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'],
  16. datasets: [
  17. {
  18. backgroundColor: '#007bff',
  19. borderColor: '#007bff',
  20. data: [1000, 2000, 3000, 2500, 2700, 2500, 3000]
  21. },
  22. {
  23. backgroundColor: '#ced4da',
  24. borderColor: '#ced4da',
  25. data: [700, 1700, 2700, 2000, 1800, 1500, 2000]
  26. }
  27. ]
  28. },
  29. options: {
  30. maintainAspectRatio: false,
  31. tooltips: {
  32. mode: mode,
  33. intersect: intersect
  34. },
  35. hover: {
  36. mode: mode,
  37. intersect: intersect
  38. },
  39. legend: {
  40. display: false
  41. },
  42. scales: {
  43. yAxes: [{
  44. // display: false,
  45. gridLines: {
  46. display: true,
  47. lineWidth: '4px',
  48. color: 'rgba(0, 0, 0, .2)',
  49. zeroLineColor: 'transparent'
  50. },
  51. ticks: $.extend({
  52. beginAtZero: true,
  53. // Include a dollar sign in the ticks
  54. callback: function (value) {
  55. if (value >= 1000) {
  56. value /= 1000
  57. value += 'k'
  58. }
  59. return '$' + value
  60. }
  61. }, ticksStyle)
  62. }],
  63. xAxes: [{
  64. display: true,
  65. gridLines: {
  66. display: false
  67. },
  68. ticks: ticksStyle
  69. }]
  70. }
  71. }
  72. })
  73. var $visitorsChart = $('#visitors-chart')
  74. // eslint-disable-next-line no-unused-vars
  75. var visitorsChart = new Chart($visitorsChart, {
  76. data: {
  77. labels: ['18th', '20th', '22nd', '24th', '26th', '28th', '30th'],
  78. datasets: [{
  79. type: 'line',
  80. data: [100, 120, 170, 167, 180, 177, 160],
  81. backgroundColor: 'transparent',
  82. borderColor: '#007bff',
  83. pointBorderColor: '#007bff',
  84. pointBackgroundColor: '#007bff',
  85. fill: false
  86. // pointHoverBackgroundColor: '#007bff',
  87. // pointHoverBorderColor : '#007bff'
  88. },
  89. {
  90. type: 'line',
  91. data: [60, 80, 70, 67, 80, 77, 100],
  92. backgroundColor: 'tansparent',
  93. borderColor: '#ced4da',
  94. pointBorderColor: '#ced4da',
  95. pointBackgroundColor: '#ced4da',
  96. fill: false
  97. // pointHoverBackgroundColor: '#ced4da',
  98. // pointHoverBorderColor : '#ced4da'
  99. }]
  100. },
  101. options: {
  102. maintainAspectRatio: false,
  103. tooltips: {
  104. mode: mode,
  105. intersect: intersect
  106. },
  107. hover: {
  108. mode: mode,
  109. intersect: intersect
  110. },
  111. legend: {
  112. display: false
  113. },
  114. scales: {
  115. yAxes: [{
  116. // display: false,
  117. gridLines: {
  118. display: true,
  119. lineWidth: '4px',
  120. color: 'rgba(0, 0, 0, .2)',
  121. zeroLineColor: 'transparent'
  122. },
  123. ticks: $.extend({
  124. beginAtZero: true,
  125. suggestedMax: 200
  126. }, ticksStyle)
  127. }],
  128. xAxes: [{
  129. display: true,
  130. gridLines: {
  131. display: false
  132. },
  133. ticks: ticksStyle
  134. }]
  135. }
  136. }
  137. })
  138. })
  139. // lgtm [js/unused-local-variable]