47 lines
1.9 KiB
HTML
47 lines
1.9 KiB
HTML
{% set fill = "#dcfce7" %}
|
|
{% set stroke = "#bbf7d0" %}
|
|
{% set stroke_width = 4 %}
|
|
{% set margin = 2 %}
|
|
|
|
{% macro path(data_points, vb_height) %}
|
|
{% for value, position, message in data_points %}
|
|
{% set x = (position * vb_width)+margin %}
|
|
{% set y = (vb_height - value)+margin %}
|
|
{% if loop.first %}M{{ x }} {{ y }}{% else %} L{{ x }} {{ y }}{% endif %}
|
|
{% endfor %}
|
|
{% endmacro %}
|
|
|
|
{% macro circles(data_points, vb_height) %}
|
|
{% for value, position, message in data_points %}
|
|
{% set x = (position * vb_width)+margin %}
|
|
{% set y = (vb_height - value)+margin %}
|
|
<circle cx="{{ x }}" cy="{{ y }}" r="5" class="cursor-pointer" data-message="{{ message }}" fill-opacity="0%"
|
|
_="on mouseover
|
|
put my @data-message into #popover-{{ unique_id }}
|
|
then remove .hidden from #popover-{{ unique_id }}
|
|
on mouseout
|
|
add .hidden to #popover-{{ unique_id }}">
|
|
</circle>
|
|
<circle cx="{{ x }}" cy="{{ y }}" r="1" stroke="blue" fill="blue"></circle>
|
|
{% endfor %}
|
|
{% endmacro %}
|
|
|
|
<!-- HubSpot doesn't escape whitespace. -->
|
|
{% macro random_int() %}{% for n in [0,1,2,3,4,5] %}{{ [0,1,2,3,4,5,6,7,8,9]|random }}{% endfor %}{% endmacro %}
|
|
|
|
<!-- You have to manually call the macros in a list. -->
|
|
{% set parts = [random_int()] %}
|
|
{% set unique_id = parts|join('-') %}
|
|
|
|
<div class="relative">
|
|
<div id="popover-{{ unique_id }}" class="absolute t-0 r-0 hidden bg-white border border-gray-300 p-2 z-10">
|
|
<!-- Popover content will be dynamically inserted here -->
|
|
</div>
|
|
<svg viewBox="0 0 {{ vb_width + 4 }} {{ vb_height + 4 }}" preserveAspectRatio="none">
|
|
<path d="{{ path(data_points, vb_height) }}" stroke="blue" fill="none" />
|
|
{{ circles(data_points, vb_height) }}
|
|
</svg>
|
|
</div>
|
|
|
|
|