{% set stroke_width = 4 %} {% set margin = 2 %} {% macro path(data_points, vb_height) %} {% for value, position in data_points %} {% set x = (position * vb_width)+margin %} {% set y = (vb_height - value)+margin %} {% if loop.first %}M{{ x | int }} {{ y | int }}{% else %} L{{ x | int }} {{ y | int }}{% endif %} {% endfor %} {% endmacro %} {% macro circles_with_skipped_points(data_points, color) %} {% for i in range(data_points|length) %} {% set current_value, current_position = data_points[i] %} {% set prev_value = data_points[i - 1][0] if i > 0 else None %} {% set next_value = data_points[i + 1][0] if i < data_points|length - 1 else None %} {# Plot the circle only if the current value is different from both previous and next values #} {% if next_value != prev_value or (next_value == prev_value and next_value != current_value) %} {% set x=(current_position * vb_width) + margin %} {% set y=(vb_height - current_value) + margin %} {% endif %} {% endfor %} {% endmacro %} {% macro circles_interactive(data_points) %} {% for value, position, message in data_points %} {% set x = (position * vb_width)+margin %} {% set y = (vb_height - value)+margin %} {% endfor %} {% endmacro %} {% macro plot_line(points, color) %} {{ circles_with_skipped_points(points, color) }} {% endmacro %} {% 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 %} {% set parts = [random_int()] %} {% set unique_id = parts|join('-') %}

{{ title }}

{% for plot in plots %} {{ plot_line(plot.points, plot.color) }} {{ circles_interactive(plot.plot_labels) }} {% endfor %}
{% for plot in plots %}
{{ plot.label }}
{% endfor %}