You are here

content-state-statistic.html.twig in Content Planner 8

{%
  set colors = [
    '#ffb2fc',
    '#fca747',
    '#0096d0',
    '#505050',
    '#99529a',
    '#5ebc68',
    '#d3d3d3',
  ]
%}
{# Calculate total #}
{% set total_count = 0 %}
{% for state in data %}
  {% set total_count = total_count + state.count %}
{% endfor %}

{# visual bar #}
<div class="content-states-visual-bar">

  {% set color_index = 1 %}
  {% for state in data %}

    {% set slice_percentage = (state.count / total_count) * 100 %}

    <div class="content-state-slice" style="background-color: {{ colors[color_index] }}; width: {{ slice_percentage }}%;">&nbsp;</div>
    {% set color_index = color_index + 1 %}
  {% endfor %}
</div>

{# count list #}
<ul class="dashboard-content-status-counts">
  {% set color_index = 1 %}
  {% for state in data %}
    <li class="content-state">
      <span class="color" style="background-color: {{ colors[color_index] }}"></span>
      <span class="label">{{ state.label }} ({{ state.count }})</span>
    </li>
    {% set color_index = color_index + 1 %}
  {% endfor %}
</ul>
<strong>Total: {{ total_count }}</strong>

File

modules/content_kanban/templates/content-state-statistic.html.twig
View source
  1. {%
  2. set colors = [
  3. '#ffb2fc',
  4. '#fca747',
  5. '#0096d0',
  6. '#505050',
  7. '#99529a',
  8. '#5ebc68',
  9. '#d3d3d3',
  10. ]
  11. %}
  12. {# Calculate total #}
  13. {% set total_count = 0 %}
  14. {% for state in data %}
  15. {% set total_count = total_count + state.count %}
  16. {% endfor %}
  17. {# visual bar #}
  18. <div class="content-states-visual-bar">
  19. {% set color_index = 1 %}
  20. {% for state in data %}
  21. {% set slice_percentage = (state.count / total_count) * 100 %}
  22. <div class="content-state-slice" style="background-color: {{ colors[color_index] }}; width: {{ slice_percentage }}%;">&nbsp;</div>
  23. {% set color_index = color_index + 1 %}
  24. {% endfor %}
  25. </div>
  26. {# count list #}
  27. <ul class="dashboard-content-status-counts">
  28. {% set color_index = 1 %}
  29. {% for state in data %}
  30. <li class="content-state">
  31. <span class="color" style="background-color: {{ colors[color_index] }}"></span>
  32. <span class="label">{{ state.label }} ({{ state.count }})</span>
  33. </li>
  34. {% set color_index = color_index + 1 %}
  35. {% endfor %}
  36. </ul>
  37. <strong>Total: {{ total_count }}</strong>