tabler-charts.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. (function ($) {
  2. $(document).ready(function () {
  3. $().peity &&
  4. $('[data-spark]').each(function () {
  5. const $this = $(this),
  6. data = $this.attr('data-spark'),
  7. color = $this.attr('data-spark-color') || 'blue',
  8. type = $this.attr('data-spark-type') || 'line';
  9. const $div = $('<div />').html(data);
  10. $this.append($div);
  11. let strokeColor = tabler.colors[color],
  12. fillColor = tabler.colors[color];
  13. if (type === 'donut' || type === 'pie') {
  14. fillColor = [fillColor, tabler.hexToRgbA(fillColor, 0.1)];
  15. } else if (type === 'bar') {
  16. fillColor = [fillColor];
  17. } else if (type === 'line') {
  18. fillColor = tabler.hexToRgbA(fillColor, 0.1);
  19. }
  20. $div.peity(type, {
  21. width: $this.width(),
  22. height: $this.height(),
  23. // max: 100,
  24. // min: 0,
  25. stroke: strokeColor,
  26. strokeWidth: 2,
  27. fill: fillColor,
  28. padding: 0.2,
  29. innerRadius: type === 'donut' ? 17 : 0,
  30. });
  31. });
  32. });
  33. })(jQuery);
  34. /*
  35. charts default configuration
  36. */
  37. if (window.Apex) {
  38. const borderColor = 'rgba(0, 0, 0, 0.09)';
  39. const mutedColor = '#888e9a';
  40. window.Apex = {
  41. chart: {
  42. fontFamily: 'inherit',
  43. foreColor: 'currentColor',
  44. toolbar: {
  45. show: false,
  46. },
  47. zoom: {
  48. enabled: false,
  49. },
  50. animations: {
  51. enabled: false,
  52. },
  53. },
  54. grid: {
  55. show: false,
  56. position: 'back',
  57. borderColor: borderColor,
  58. padding: {
  59. right: 0,
  60. left: 0,
  61. bottom: 0,
  62. top: 0,
  63. },
  64. },
  65. dataLabels: {
  66. enabled: false,
  67. dropShadow: {
  68. enabled: false,
  69. },
  70. },
  71. plotOptions: {
  72. pie: {
  73. customScale: 1,
  74. expandOnClick: false,
  75. dataLabels: {
  76. minAngleToShowLabel: 10,
  77. },
  78. donut: {
  79. size: '80%'
  80. }
  81. },
  82. },
  83. stroke: {
  84. width: 2,
  85. curve: 'smooth',
  86. lineCap: "round",
  87. colors: ["transparent"]
  88. },
  89. fill: {
  90. type: 'solid',
  91. opacity: 1,
  92. },
  93. markers: {
  94. size: 0,
  95. strokeWidth: 1,
  96. radius: 2,
  97. hover: {
  98. size: 4,
  99. },
  100. },
  101. legend: {
  102. show: true,
  103. fontSize: '14px',
  104. markers: {
  105. width: 8,
  106. height: 8,
  107. },
  108. itemMargin: {
  109. horizontal: 0,
  110. vertical: 8,
  111. },
  112. },
  113. title: {
  114. margin: 0,
  115. floating: true,
  116. offsetX: 10,
  117. style: {
  118. fontSize: '18px',
  119. },
  120. },
  121. subtitle: {
  122. margin: 0,
  123. },
  124. tooltip: {
  125. fillSeriesColor: false,
  126. },
  127. xaxis: {
  128. labels: {
  129. style: {
  130. colors: mutedColor,
  131. fontSize: '12px',
  132. },
  133. datetimeFormatter: {
  134. year: 'yyyy',
  135. month: 'MMM \'yy',
  136. day: 'd MMM',
  137. hour: 'HH:mm'
  138. }
  139. },
  140. tooltip: {
  141. enabled: false,
  142. },
  143. axisBorder: {
  144. color: borderColor,
  145. height: 0,
  146. },
  147. axisTicks: {
  148. show: true,
  149. height: 4,
  150. color: borderColor,
  151. },
  152. },
  153. yaxis: {
  154. show: false,
  155. labels: {
  156. show: false,
  157. },
  158. },
  159. };
  160. }