be_pages_dashboard.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Document : be_pages_dahboard.js
  3. * Author : pixelcave
  4. * Description: Custom JS code used in Dashboard Page
  5. */
  6. var BePagesDashboard = function() {
  7. // Chart.js Charts, for more examples you can check out http://www.chartjs.org/docs
  8. var initDashboardChartJS = function () {
  9. // Set Global Chart.js configuration
  10. Chart.defaults.global.defaultFontColor = '#555555';
  11. Chart.defaults.scale.gridLines.color = "transparent";
  12. Chart.defaults.scale.gridLines.zeroLineColor = "transparent";
  13. Chart.defaults.scale.display = false;
  14. Chart.defaults.scale.ticks.beginAtZero = true;
  15. Chart.defaults.global.elements.line.borderWidth = 2;
  16. Chart.defaults.global.elements.point.radius = 5;
  17. Chart.defaults.global.elements.point.hoverRadius = 7;
  18. Chart.defaults.global.tooltips.cornerRadius = 3;
  19. Chart.defaults.global.legend.display = false;
  20. // Chart Containers
  21. var chartDashboardLinesCon = jQuery('.js-chartjs-dashboard-lines');
  22. var chartDashboardLinesCon2 = jQuery('.js-chartjs-dashboard-lines2');
  23. // Chart Variables
  24. var chartDashboardLines, chartDashboardLines2;
  25. // Lines Charts Data
  26. var chartDashboardLinesData = {
  27. labels: ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'],
  28. datasets: [
  29. {
  30. label: 'This Week',
  31. fill: true,
  32. backgroundColor: 'rgba(66,165,245,.25)',
  33. borderColor: 'rgba(66,165,245,1)',
  34. pointBackgroundColor: 'rgba(66,165,245,1)',
  35. pointBorderColor: '#fff',
  36. pointHoverBackgroundColor: '#fff',
  37. pointHoverBorderColor: 'rgba(66,165,245,1)',
  38. data: [25, 21, 23, 38, 36, 35, 39]
  39. }
  40. ]
  41. };
  42. var chartDashboardLinesOptions = {
  43. scales: {
  44. yAxes: [{
  45. ticks: {
  46. suggestedMax: 50
  47. }
  48. }]
  49. },
  50. tooltips: {
  51. callbacks: {
  52. label: function(tooltipItems, data) {
  53. return ' ' + tooltipItems.yLabel + ' Sales';
  54. }
  55. }
  56. }
  57. };
  58. var chartDashboardLinesData2 = {
  59. labels: ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'],
  60. datasets: [
  61. {
  62. label: 'This Week',
  63. fill: true,
  64. backgroundColor: 'rgba(156,204,101,.25)',
  65. borderColor: 'rgba(156,204,101,1)',
  66. pointBackgroundColor: 'rgba(156,204,101,1)',
  67. pointBorderColor: '#fff',
  68. pointHoverBackgroundColor: '#fff',
  69. pointHoverBorderColor: 'rgba(156,204,101,1)',
  70. data: [190, 219, 235, 320, 360, 354, 390]
  71. }
  72. ]
  73. };
  74. var chartDashboardLinesOptions2 = {
  75. scales: {
  76. yAxes: [{
  77. ticks: {
  78. suggestedMax: 480
  79. }
  80. }]
  81. },
  82. tooltips: {
  83. callbacks: {
  84. label: function(tooltipItems, data) {
  85. return ' $ ' + tooltipItems.yLabel;
  86. }
  87. }
  88. }
  89. };
  90. // Init Charts
  91. if ( chartDashboardLinesCon.length ) {
  92. chartDashboardLines = new Chart(chartDashboardLinesCon, { type: 'line', data: chartDashboardLinesData, options: chartDashboardLinesOptions });
  93. }
  94. if ( chartDashboardLinesCon2.length ) {
  95. chartDashboardLines2 = new Chart(chartDashboardLinesCon2, { type: 'line', data: chartDashboardLinesData2, options: chartDashboardLinesOptions2 });
  96. }
  97. };
  98. return {
  99. init: function () {
  100. // Init Chart.js Charts
  101. initDashboardChartJS();
  102. }
  103. };
  104. }();
  105. // Initialize when page loads
  106. jQuery(function(){ BePagesDashboard.init(); });