{# il2ks-template: templates/il2ks/components/bar_chart.html v1 - copy this line along when you override #} {% load i18n il2ks %}{% comment %} bar_chart.html ({% bar_chart spec %}, spec = il2ks.web.charts.ChartSpec): an inline-SVG bar chart (FR-WEB-16). Context: spec (title, desc, chart_id, ...), chart (the BarChart layout: bars with SVG paths, y_ticks, x_labels, legend, table_head, table_rows, is_empty). Colours are the --il2-chart-* tokens (site.css), so it follows light and dark mode; each bar has a (native tooltip); the numbers are in the "Show the numbers" table. {% endcomment %}<figure class="chart" id="{{ spec.chart_id }}"> <figcaption class="chart__title">{{ spec.title }}</figcaption> {% if chart.is_empty %} <p class="muted">{% translate "Nothing to show yet." %}</p> {% else %} {% if chart.legend %} <ul class="chart__legend"> {% for label in chart.legend %}<li><span class="chart__swatch chart__swatch--s{{ forloop.counter0 }}" aria-hidden="true"></span>{{ label }}</li>{% endfor %} </ul> {% endif %} <svg class="chart__svg" viewBox="0 0 {{ chart.width }} {{ chart.height }}" role="img" aria-labelledby="{{ spec.chart_id }}-t {{ spec.chart_id }}-d" focusable="false"> <title id="{{ spec.chart_id }}-t">{{ spec.title }} {{ spec.desc }} {% for bar in chart.bars %}{{ bar.tip }}{% endfor %}
{% translate "Show the numbers" %}
{% for label in chart.table_head %}{% endfor %} {% for category, values in chart.table_rows %} {% for value in values %}{% endfor %} {% endfor %}
{{ spec.title }}{{ label }}
{{ category }}{{ value|num }}
{% endif %}