You are here

opigno-statistics-chart--user-per-day.html.twig in Opigno statistics 8

Default theme implementation to display the statistics chart.

Available variables:

  • data: The data array.
  • max_count: Max value of data.

File

templates/opigno-statistics-chart--user-per-day.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation to display the statistics chart.
  5. *
  6. * Available variables:
  7. * - data: The data array.
  8. * - max_count: Max value of data.
  9. */
  10. #}
  11. {% set min_day = 1 %}
  12. {% set max_day = 31 %}
  13. {% set day_x_step = 15 %}
  14. {% set height = 175 %}
  15. {% set h_lines = 5 %}
  16. {% set padding = 20 %}
  17. <h3 class="users-per-day-title">
  18. {{ 'Number of active users per day'|t }}
  19. <div class="popover-help" data-toggle="popover" data-content="{{ 'This chart persents the number of unique user login per day.'|t }}" data-drupal-selector="edit-0">?</div>
  20. </h3>
  21. <svg class="users-per-day" viewBox="-20 -20 500 220">
  22. {% for i in 0..h_lines %}
  23. {% set y = height - height * i / h_lines %}
  24. <line x1="{{ padding }}" y1="{{ y }}" x2="{{ padding + day_x_step * (max_day - min_day) }}" y2="{{ y }}"></line>
  25. <text x="0" y="{{ y }}">{{ (max_count * i / h_lines)|round }}</text>
  26. {% endfor %}
  27. {% for i in min_day..max_day %}
  28. {% set x = -5 + padding + day_x_step * (i - min_day) %}
  29. {% set y = padding + height %}
  30. <text x="{{ x }}" y="{{ y }}">{{ i }}</text>
  31. {% endfor %}
  32. <path d="
  33. {% set y = height - height * data[min_day] / max_count %}
  34. M{{ padding }},{{ y }}
  35. {% for i in (min_day + 1)..max_day %}
  36. {% set x = padding + day_x_step * (i - min_day) %}
  37. {% set y = height - height * data[i] / max_count %}
  38. L{{ x }},{{ y }}
  39. {% endfor %}
  40. "></path>
  41. {% for i in min_day..max_day %}
  42. {% set x = padding + day_x_step * (i - min_day) %}
  43. {% set y = height - height * data[i] / max_count %}
  44. <circle cx="{{ x }}" cy="{{ y }}" r="4"></circle>
  45. {% endfor %}
  46. </svg>