dashboard3.js 3.6 KB

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