chart-heatmap.html 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. {% assign id = include.chart-id %}
  2. {% assign class = include.class %}
  3. {% assign height = include.height | default: data.height | default: 25 %}
  4. {% assign class = include.class %}
  5. <div id="chart-{{ id }}"{% if class %} class="{{ class }}"{% endif %}></div>
  6. {% capture script %}
  7. {% assign colors = include.colors | default: 1 %}
  8. <script>
  9. // @formatter:off
  10. document.addEventListener("DOMContentLoaded", function () {
  11. {% if env == 'development' %}
  12. window.tabler_chart = window.tabler_chart || {};
  13. {% endif %}
  14. window.ApexCharts && ({% if env == 'development' %}window.tabler_chart["chart-{{ include.chart-id }}"] = {% endif %}new ApexCharts(document.getElementById('chart-{{ id }}'), {
  15. chart: {
  16. height: {{ height | times: 16 }},
  17. type: "heatmap",
  18. toolbar: {
  19. show: false,
  20. },
  21. },
  22. dataLabels: {
  23. enabled: {% if include.labels %}true{% else %}false{% endif %}
  24. },
  25. {% if include.scale %}
  26. plotOptions: {
  27. heatmap: {
  28. enableShades: {% unless include.no-shades %}true{% else %}false{% endunless %},
  29. colorScale: {
  30. ranges: [{
  31. from: 0,
  32. to: 20,
  33. name: "Low",
  34. color: tabler.getColor("green")
  35. }, {
  36. from: 21,
  37. to: 50,
  38. name: "Medium",
  39. color: tabler.getColor("blue")
  40. }, {
  41. from: 51,
  42. to: 75,
  43. name: "High",
  44. color: tabler.getColor("yellow")
  45. }, {
  46. from: 76,
  47. to: 100,
  48. name: "Extreme",
  49. color: tabler.getColor("red")
  50. }]
  51. }
  52. }
  53. },
  54. {% else %}
  55. colors: [{% if include.color %}'{{ include.color }}'{% else %}{% for color in site.colors limit: colors %}tabler.getColor("{{ color[0] }}"), {% endfor %}{% endif %}],
  56. {% endif %}
  57. series: [
  58. {% for i in site.months-short limit: 12 %}
  59. {% assign month-i = forloop.index %}
  60. { name: "{{ i }}", data: [{% for j in (1..16) %}{x: '{{ j }}', y: {{ j | random_number: 0, 100 | plus: month-i | random_number: 0, 100 }}},{% endfor %}] },
  61. {% endfor %}
  62. ],
  63. xaxis: {
  64. type: "category"
  65. },
  66. legend: {
  67. {% if include.legend %}
  68. show: true,
  69. position: 'bottom',
  70. offsetY: 8,
  71. markers: {
  72. width: 10,
  73. height: 10,
  74. radius: 100,
  75. },
  76. itemMargin: {
  77. horizontal: 8,
  78. },
  79. {% else %}
  80. show: false,
  81. {% endif %}
  82. },
  83. })).render();
  84. });
  85. // @formatter:on
  86. </script>
  87. {% endcapture %}
  88. {% capture_global scripts %}
  89. {{ script }}
  90. {% endcapture_global %}