be_blocks_widgets_stats.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Document : be_blocks_widgets_stats.js
  3. * Author : pixelcave
  4. * Description: Custom JS code used in Widgets Stats Page
  5. */
  6. var BeBlocksWidgetsStats = function() {
  7. // Chart.js Charts, for more examples you can check out http://www.chartjs.org/docs
  8. var initWidgetsChartJS = 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.scale.ticks.suggestedMax = 11;
  16. Chart.defaults.global.elements.line.borderWidth = 2;
  17. Chart.defaults.global.elements.point.radius = 5;
  18. Chart.defaults.global.elements.point.hoverRadius = 7;
  19. Chart.defaults.global.tooltips.cornerRadius = 3;
  20. Chart.defaults.global.legend.display = false;
  21. // Chart Containers
  22. var chartWidgetLinesCon = jQuery('.js-chartjs-widget-lines');
  23. var chartWidgetLinesCon2 = jQuery('.js-chartjs-widget-lines2');
  24. var chartWidgetLinesCon3 = jQuery('.js-chartjs-widget-lines3');
  25. var chartWidgetLinesCon4 = jQuery('.js-chartjs-widget-lines4');
  26. // Charts Variables
  27. var chartWidgetLines, chartWidgetLines2, chartWidgetLines3, chartWidgetLines4;
  28. // Lines Charts Data
  29. var chartWidgetLinesData = {
  30. labels: ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'],
  31. datasets: [
  32. {
  33. label: 'This Week',
  34. fill: true,
  35. backgroundColor: 'rgba(66,165,245,.25)',
  36. borderColor: 'rgba(66,165,245,1)',
  37. pointBackgroundColor: 'rgba(66,165,245,1)',
  38. pointBorderColor: '#fff',
  39. pointHoverBackgroundColor: '#fff',
  40. pointHoverBorderColor: 'rgba(66,165,245,1)',
  41. data: [5, 7, 4, 5, 6, 8, 4]
  42. }
  43. ]
  44. };
  45. var chartWidgetLinesData2 = {
  46. labels: ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'],
  47. datasets: [
  48. {
  49. label: 'This Week',
  50. fill: true,
  51. backgroundColor: 'rgba(255,202,40,.25)',
  52. borderColor: 'rgba(255,202,40,1)',
  53. pointBackgroundColor: 'rgba(255,202,40,1)',
  54. pointBorderColor: '#fff',
  55. pointHoverBackgroundColor: '#fff',
  56. pointHoverBorderColor: 'rgba(255,202,40,1)',
  57. data: [6, 9, 5, 6, 9, 7, 10]
  58. }
  59. ]
  60. };
  61. var chartWidgetLinesData3 = {
  62. labels: ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'],
  63. datasets: [
  64. {
  65. label: 'This Week',
  66. fill: true,
  67. backgroundColor: 'rgba(1,229,148,.25)',
  68. borderColor: 'rgba(1,229,148,1)',
  69. pointBackgroundColor: 'rgba(1,229,148,1)',
  70. pointBorderColor: '#fff',
  71. pointHoverBackgroundColor: '#fff',
  72. pointHoverBorderColor: 'rgba(1,229,148,1)',
  73. data: [6, 9, 5, 6, 9, 7, 10]
  74. }
  75. ]
  76. };
  77. var chartWidgetLinesData4 = {
  78. labels: ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN'],
  79. datasets: [
  80. {
  81. label: 'This Week',
  82. fill: true,
  83. backgroundColor: 'rgba(237,83,80,.25)',
  84. borderColor: 'rgba(237,83,80,1)',
  85. pointBackgroundColor: 'rgba(237,83,80,1)',
  86. pointBorderColor: '#fff',
  87. pointHoverBackgroundColor: '#fff',
  88. pointHoverBorderColor: 'rgba(237,83,80,1)',
  89. data: [5, 7, 4, 5, 6, 8, 4]
  90. }
  91. ]
  92. };
  93. // Init Charts
  94. if (chartWidgetLinesCon.length ) {
  95. chartWidgetLines = new Chart(chartWidgetLinesCon, { type: 'line', data: chartWidgetLinesData });
  96. }
  97. if (chartWidgetLinesCon2.length ) {
  98. chartWidgetLines2 = new Chart(chartWidgetLinesCon2, { type: 'line', data: chartWidgetLinesData2 });
  99. }
  100. if (chartWidgetLinesCon3.length ) {
  101. chartWidgetLines3 = new Chart(chartWidgetLinesCon3, { type: 'line', data: chartWidgetLinesData3 });
  102. }
  103. if (chartWidgetLinesCon4.length ) {
  104. chartWidgetLines4 = new Chart(chartWidgetLinesCon4, { type: 'line', data: chartWidgetLinesData4 });
  105. }
  106. };
  107. return {
  108. init: function () {
  109. // Init Chart.js Charts
  110. initWidgetsChartJS();
  111. }
  112. };
  113. }();
  114. // Initialize when page loads
  115. jQuery(function(){ BeBlocksWidgetsStats.init(); });