The JS snippet I created relies on the forloop.counter variable being available within a {% for key, value in data.items %}..{% endfor %} tag.
Is there
It's possible to use django built-in widthratio template tag and add filter:
{{forloop.counter|add:5}}{{forloop.counter|add:"-5"}}{% widthratio forloop.counter 5 1 %}{% widthratio forloop.counter 1 5 %}