Render svg graphs in initial response rather then requesting each graph individually. Initial load file size of dashboard will be larger, unsure if I will rollback this change

This commit is contained in:
Peter Stockings
2023-12-09 23:10:13 +11:00
parent c5e825f4df
commit d0afd92126
4 changed files with 90 additions and 71 deletions

View File

@@ -133,10 +133,7 @@
<div class="align-middle inline-block min-w-full">
<div class="shadow overflow-hidden sm:rounded-lg">
<div class="w-full mt-2 pb-2 aspect-video">
<div class="hidden"
hx-get="{{ url_for('get_exercise_progress_for_user', person_id=p['PersonId'], exercise_id=e['ExerciseId'], min_date=min_date, max_date=max_date) }}"
hx-trigger="load" hx-target="this" hx-swap="outerHTML">
</div>
{{ render_partial('partials/sparkline.html', **e['ExerciseProgressGraph']) }}
</div>
<table class="min-w-full divide-y divide-gray-200">

View File

@@ -2,7 +2,7 @@
{% set margin = 2 %}
{% macro path(data_points, vb_height) %}
{% for value, position, message in data_points %}
{% for value, position in data_points %}
{% set x = (position * vb_width)+margin %}
{% set y = (vb_height - value)+margin %}
{% if loop.first %}M{{ x | int }} {{ y | int }}{% else %} L{{ x | int }} {{ y | int }}{% endif %}
@@ -18,7 +18,7 @@
{% endmacro %}
{% macro circles(data_points, color) %}
{% for value, position, message in data_points %}
{% for value, position in data_points %}
{% set x = (position * vb_width)+margin %}
{% set y = (vb_height - value)+margin %}
<circle cx="{{ x | int }}" cy="{{ y | int }}" r="1"></circle>