{#-----------------constants---------------------------#} {% set topGap = 24 %} {% set rightGap = 24 %} {% set barGap = 18 %} {% set barThickness = 48 %} {% set barToValue = 6 %} {% set axisPadding = 56 %} {% set arrowHead = 6 %} {% set graphPadding = 48 %} {#------calculate values from template elements--------#} {% set values = elementsToValues(elements, 'tx-..-([1-9]\d*)-value') %} {% set maxValue = values | max %} {% set n = values|length %} {% set height = topGap + barGap + (barThickness + barGap)*n %} {% set width = 456 %} {# bars #} {%for i in range(n) %} {% set y = topGap + barGap + (barGap + barThickness) * i %} {% set barWidth = (width-rightGap) * values[i] / maxValue | round(3) %} {% endfor %} {# values #} {%for i in range(n) %} {% set barWidth = (width-rightGap) * values[i] / maxValue | round(3) %} {% if barWidth > 48 + 2*barToValue %} {% set align = 'rc' %} {% set x = (width-rightGap) * values[i] / maxValue - barToValue - 48 | round(3) %} {% else %} {% set align = 'lc' %} {% set x = (width-rightGap) * values[i] / maxValue + barToValue | round(3) %} {% endif %} {% set y = topGap + barGap + barThickness/2 + (barGap + barThickness) * i %} {% endfor %} {# labels #} {%for i in range(n) %} {% set y = topGap + barGap + barThickness/2 + (barGap + barThickness) * i %} {% endfor %} {# buttons #} {%for i in range(n+1) %} {% set y = topGap + barGap + (barGap + barThickness) * i %} {% if n > 1 and n > i %} {% endif %} {% endfor %} {# axes #}