A web framework for aspiring media terrorists – PRE-ALPHA – DO NOT DEPLOY!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
5.3KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <svg
  3. xmlns="http://www.w3.org/2000/svg"
  4. xmlns:dc="http://purl.org/dc/elements/1.1/"
  5. version="1.1"
  6. width="{{ content.width }}"
  7. height="{{ content.height }}"
  8. viewBox="0 0 {{ content.width }} {{ content.height }}"
  9. preserveAspectRatio="xMinYMin meet"
  10. class="plot {{ content.__class__.__name__.lower()}}"
  11. >
  12. <!-- a json representation of all visualized data, not used since there's a strict nojs policy, but included for your convenience -->
  13. {# content.render('json') #}
  14. <style>
  15. {{ content.style }}
  16. </style>
  17. {% include "svg/defs.jinja" %}
  18. <text class="axis-label axis-x" x="{{ content.padding }}" y="{{ content.plot_height + content.padding + 20 }}" dominant-baseline="hanging">{{ content.label_x }}</text>
  19. <text class="axis-label axis-y" transform="rotate(-90 0 {{ content.plot_height + content.padding }}) translate(5 15)" x="0" y="{{ content.plot_height + content.padding }}">{{ content.label_y }}</text>
  20. <svg class="plot-inner" x="{{ content.padding }}" y="{{ content.padding }}" width="{{ content.inner_width }}" height="{{ content.inner_height }}" viewBox="0 0 {{ content.inner_width }} {{ content.inner_height }}" preserveAspectRatio="xMinYMin meet">
  21. {% if content.has_grid %}
  22. <g class="grid">
  23. {% block grid %}
  24. {% for i in range(0, content.grid_x|length) %}
  25. {% set x = content.grid_x[i] %}
  26. {% if content.grid_x|length >= 4 %}
  27. {% set highlighted = i % (content.grid_x|length / 4.0)|int == 0 %} {# whether this line should be highlighted and have a value shown next to it #}
  28. {% else %}
  29. {% set highlighted = True %}
  30. {% endif %}
  31. <line class="grid-x{% if highlighted %} highlighted{% endif %}" x1="{{ content.normalize_x(x) }}" y1="0%" x2="{{ content.normalize_x(x) }}" y2="{{ content.plot_height }}" />
  32. {% if highlighted %}
  33. <text class="grid-label axis-x" x="{{ content.normalize_x(x) }}" y="{{ content.plot_height }}" dominant-baseline="hanging">{{ "%.3f"|format(x) }}</text>
  34. {% endif %}
  35. {% endfor %}
  36. {% for i in range(0, content.grid_y|length) %}
  37. {% set y = content.grid_y[i] %}
  38. {% if content.grid_y|length >= 4 %}
  39. {% set highlighted = i % (content.grid_y|length / 4)|int == 0 %} {# whether this line should be highlighted and have a value shown next to it #}
  40. {% else %}
  41. {% set highlighted = True %}
  42. {% endif %}
  43. <line class="grid-y{% if highlighted %} highlighted{% endif %}" x1="0%" y1="{{ content.normalize_y(y) }}" x2="100%" y2="{{ content.normalize_y(y) }}" />
  44. {% if highlighted %}
  45. <text class="grid-label axis-y" transform="rotate(-90 0 {{ content.normalize_y(y) }}) translate(5 -15)" x="0" y="{{ content.normalize_y(y) }}" dominant-baseline="hanging">{{ "%.3f"|format(y) }}</text>
  46. {% endif %}
  47. {% endfor %}
  48. {% endblock %}
  49. </g>
  50. {% endif %}
  51. <g id="{{ content.dataset.ref_id }}" class="dataset">
  52. {% block dataset scoped %}
  53. {% if content.is_dataframe(content.dataset.data) %}
  54. {% for series_index in content.dataset.data %}
  55. {% set series = content.dataset.data[series_index] %}
  56. {% for x, y in series.iteritems() %}
  57. <a href="#{{ content.dataset.datapoint_id(x) }}">
  58. <g id="{{ content.dataset.datapoint_id(x) }}" class="datapoint">
  59. {% block datapoint scoped %}
  60. <use href="#marker" class="marker" x="{{ content.normalize_x(x) }}" y="{{ content.normalize_y(y) }}" />
  61. <text class="datapoint-value" x="{{ content.normalize_x(x) + 5 }}" y="{{ content.normalize_y(y) - 20 }}">{{ "%.5f"|format(y) }}</text>
  62. {% endblock %}
  63. </g>
  64. </a>
  65. {% endfor %}
  66. {% endfor %}
  67. {% else %}
  68. <text>{{ content.dataset.data.__class__.__name__ }}</text>
  69. {% endif %}
  70. <a class="dataset-link" href="#{{ content.dataset.ref_id }}">
  71. {# <text class="dataset-name" x="{{ content.inner_width }}" y="{{ 10 + (idx * 20) }}" text-anchor="end">{{ content.dataset.title }}</text> #}
  72. </a>
  73. <g class="description">
  74. <foreignObject class="html" x="0" y="{{ content.plot_height + content.padding }}" width="100%" height="{{ content.description_height }}px"> {# either render HTML #}
  75. <body xmlns="http://www.w3.org/1999/xhtml">
  76. <h1>{{ content.dataset.title }}</h1>
  77. {{ content.dataset.description.render() }}
  78. </body>
  79. </foreignObject>
  80. </g>
  81. {% endblock dataset %}
  82. </g> <!-- / .dataset -->
  83. </svg>
  84. </svg>