1
0
mirror of https://github.com/tabler/tabler.git synced 2026-07-26 13:04:39 +04:00
Files
tabler/pages/_includes/ui/sparkline.html
T
2019-12-25 15:32:40 +01:00

29 lines
1.0 KiB
HTML

{% assign type = include.type %}
{% assign id = 0 | random_id %}
{% assign color = include.color | default: 'blue' %}
{% assign data = include.data %}
{% if include.percentage %}
{% assign data = include.percentage | append: "/100" %}
{% endif %}
{% append_lib peity %}
<div class="chart-sparkline{% if type == 'pie' %} chart-sparkline-square{% endif %}{% if include.wide %} chart-sparkline-wide{% endif %}" id="sparkline-{{ id }}"></div>
{% capture_global scripts %}
<script>
document.addEventListener("DOMContentLoaded", function () {
$().peity && $('#sparkline-{{ id }}').text("{{ data }}").peity("{{ type | default: 'bar' }}", {
width: {% if type == 'pie' %}40{% else %}64{% endif %},
height: 40,
stroke: "{{ color | tabler_color }}",
strokeWidth: 2,
fill: {% if type == 'pie' %}["{{ color | default: 'blue' | tabler_color }}", "{{ 'gray-200' | tabler_color }}"]{% elsif type == 'bar' %}["{{ color | tabler_color }}"]{% else %}"transparent"{% endif %},
padding: .2,
innerRadius: 17,
});
});
</script>
{% endcapture_global %}