{#-----------------constants---------------------------#} {% set barGap = 24 %} {% set barThickness = 96 %} {% set barToValue = 6 %} {% set arrowHead = 6 %} {% set graphPadding = 48 %} {#------calculate values from template elements--------#} {% set values = elementsToValues(elements, 'tx-..-([1-9]\d*)-value') %} {% set n = values | length %} {% if n == 0 %} {% set values = [ 0 ] %} {% set n = 1 %} {% endif %} {% set maxValue = values | max %} {% if maxValue == 0 %} {% set maxValue = 1.0 %} {% endif %} {% set height = 240 %} {% set width = barGap + (barThickness + barGap) * n %} {# bars #} {%for i in range(n) %} {% set x = barGap + (barGap + barThickness) * i %} {% set barHeight = height * values[i] / maxValue | round(3) %} {% endfor %} {# values #} {%for i in range(n) %} {% set x = barGap + barThickness/2 + 24 + (barGap + barThickness) * i %} {% set barHeight = height * values[i] / maxValue | round(3) %} {% if barHeight > 24 + barToValue %} {% set align = 'ct' %} {% set y = height - barHeight + barToValue %} {% else %} {% set align = 'cb' %} {% set y = height - barHeight - barToValue - 24 %} {% endif %} {% endfor %} {# labels #} {%for i in range(n) %} {% set textWidth = barGap + barThickness - 2 %} {% set x = barGap + barThickness/2 + textWidth/2 + (barGap + barThickness) * i %} {% endfor %} {# buttons #} {%for i in range(n+1) %} {% set x = barGap + (barGap + barThickness) * i %} {% if n > 1 and n > i %} {% endif %} {% endfor %} {# axes #}