Skip to content

Commit

Permalink
Fix ApexChart heatmap initialization on the charts docs page (#1152)
Browse files Browse the repository at this point in the history
  • Loading branch information
dheineman committed Aug 31, 2022
1 parent c4a6a86 commit e738cc4
Showing 1 changed file with 73 additions and 66 deletions.
139 changes: 73 additions & 66 deletions src/pages/_includes/ui/chart-heatmap.html
Expand Up @@ -8,77 +8,84 @@
{% capture script %}
{% assign colors = include.colors | default: 1 %}
<script>
var options = {
chart: {
height: {{ height | times: 16 }},
type: "heatmap",
toolbar: {
show: false,
},
},
dataLabels: {
enabled: {% if include.labels %}true{% else %}false{% endif %}
},
{% if include.scale %}
plotOptions: {
heatmap: {
enableShades: {% unless include.no-shades %}true{% else %}false{% endunless %},
colorScale: {
ranges: [{
from: 0,
to: 20,
name: "Low",
color: "{{ "green" | tabler_color }}"
}, {
from: 21,
to: 50,
name: "Medium",
color: "{{ "blue" | tabler_color }}"
}, {
from: 51,
to: 75,
name: "High",
color: "{{ "yellow" | tabler_color }}"
}, {
from: 76,
to: 100,
name: "Extreme",
color: "{{ "red" | tabler_color }}"
}]
}
}
},
{% else %}
colors: [{% if include.color %}'{{ include.color }}'{% else %}{% for color in site.colors limit: colors %}"{{ color[0] | tabler_color }}", {% endfor %}{% endif %}],
// @formatter:off
document.addEventListener("DOMContentLoaded", function () {
{% if jekyll.environment == 'development' %}
window.tabler_chart = window.tabler_chart || {};
{% endif %}
series: [
{% for i in site.months-short limit: 12 %}
{% assign month-i = forloop.index %}
{ name: "{{ i }}", data: [{% for j in (1..16) %}{x: '{{ j }}', y: {{ j | random_number: 0, 100 | plus: month-i | random_number: 0, 100 }}},{% endfor %}] },{% endfor %}
],
xaxis: {
type: "category"
},
legend: {
{% if include.legend %}
show: true,
position: 'bottom',
offsetY: 8,
markers: {
width: 10,
height: 10,
radius: 100,

window.ApexCharts && ({% if jekyll.environment == 'development' %}window.tabler_chart["chart-{{ include.chart-id }}"] = {% endif %}new ApexCharts(document.getElementById('chart-{{ id }}'), {
chart: {
height: {{ height | times: 16 }},
type: "heatmap",
toolbar: {
show: false,
},
},
dataLabels: {
enabled: {% if include.labels %}true{% else %}false{% endif %}
},
itemMargin: {
horizontal: 8,
{% if include.scale %}
plotOptions: {
heatmap: {
enableShades: {% unless include.no-shades %}true{% else %}false{% endunless %},
colorScale: {
ranges: [{
from: 0,
to: 20,
name: "Low",
color: "{{ "green" | tabler_color }}"
}, {
from: 21,
to: 50,
name: "Medium",
color: "{{ "blue" | tabler_color }}"
}, {
from: 51,
to: 75,
name: "High",
color: "{{ "yellow" | tabler_color }}"
}, {
from: 76,
to: 100,
name: "Extreme",
color: "{{ "red" | tabler_color }}"
}]
}
}
},
{% else %}
show: false,
colors: [{% if include.color %}'{{ include.color }}'{% else %}{% for color in site.colors limit: colors %}"{{ color[0] | tabler_color }}", {% endfor %}{% endif %}],
{% endif %}
},
};

(new ApexCharts(document.querySelector("#chart-{{ id }}"),options)).render();
series: [
{% for i in site.months-short limit: 12 %}
{% assign month-i = forloop.index %}
{ name: "{{ i }}", data: [{% for j in (1..16) %}{x: '{{ j }}', y: {{ j | random_number: 0, 100 | plus: month-i | random_number: 0, 100 }}},{% endfor %}] },
{% endfor %}
],
xaxis: {
type: "category"
},
legend: {
{% if include.legend %}
show: true,
position: 'bottom',
offsetY: 8,
markers: {
width: 10,
height: 10,
radius: 100,
},
itemMargin: {
horizontal: 8,
},
{% else %}
show: false,
{% endif %}
},
})).render();
});
// @formatter:on
</script>
{% endcapture %}

Expand Down

1 comment on commit e738cc4

@vercel
Copy link

@vercel vercel bot commented on e738cc4 Aug 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

tabler – ./

tabler-git-main-tabler-ui.vercel.app
tabler-tabler-ui.vercel.app
demo.tabler.io
preview.tabler.io

Please sign in to comment.