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.

93 lines
2.6 KiB

3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Document : db_crypto.js
  3. * Author : pixelcave
  4. * Description: Custom JS code used in Crypto Dashboard Page
  5. */
  6. // Chart.js Charts, for more examples you can check out http://www.chartjs.org/docs
  7. class pageDashboardCrypto {
  8. /*
  9. * Init Charts
  10. *
  11. */
  12. static initChartsBitcoin() {
  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.point.radius = 0;
  19. Chart.defaults.elements.point.hoverRadius = 0;
  20. Chart.defaults.plugins.tooltip.radius = 3;
  21. Chart.defaults.plugins.legend.display = false;
  22. // Get Chart Container
  23. let chartBitcoinCon = document.getElementById('js-chartjs-bitcoin');
  24. // Set up labels
  25. let chartBitcoinlabels = [];
  26. for (let i = 0; i < 30; i++) {
  27. chartBitcoinlabels[i] = (i === 29) ? '1 day ago' : (30 - i) + ' days ago';
  28. }
  29. // Crypto Data
  30. let chartBitcoinData = [10500, 10400, 9500, 8268, 10218, 8250, 8707, 9284, 9718, 9950, 9879, 10147, 10883, 11071, 11332, 11584, 11878, 13540, 16501, 16007, 15142, 14869, 16762, 17276, 16808, 16678, 16771, 12900, 13100, 14000];
  31. // Init Chart
  32. if (chartBitcoinCon !== null) {
  33. let chartBitcoin = new Chart(chartBitcoinCon, {
  34. type: 'line',
  35. data: {
  36. labels: chartBitcoinlabels,
  37. datasets: [
  38. {
  39. label: 'Bitcoin Price',
  40. fill: true,
  41. backgroundColor: 'rgba(255,193,7,.25)',
  42. borderColor: 'rgba(255,193,7,1)',
  43. pointBackgroundColor: 'rgba(255,193,7,1)',
  44. pointBorderColor: '#fff',
  45. pointHoverBackgroundColor: '#fff',
  46. pointHoverBorderColor: 'rgba(255,193,7,1)',
  47. data: chartBitcoinData
  48. }
  49. ]
  50. },
  51. options: {
  52. responsive: true,
  53. maintainAspectRatio: false,
  54. tension: .4,
  55. scales: {
  56. y: {
  57. suggestedMin: 6000,
  58. suggestedMax: 20000
  59. }
  60. },
  61. interaction: {
  62. intersect: false,
  63. },
  64. plugins: {
  65. tooltip: {
  66. callbacks: {
  67. label: function (context) {
  68. return ' $' + context.parsed.y;
  69. }
  70. }
  71. }
  72. }
  73. }
  74. });
  75. }
  76. }
  77. /*
  78. * Init functionality
  79. *
  80. */
  81. static init() {
  82. this.initChartsBitcoin();
  83. }
  84. }
  85. // Initialize when page loads
  86. Dashmix.onLoad(() => pageDashboardCrypto.init());