Update report graph output processing for new Plot.ly data output.

This commit is contained in:
Christopher C. Wells 2019-02-02 19:11:20 -08:00
parent 3bee8017a0
commit a47767355d
9 changed files with 12 additions and 39 deletions

View File

@ -6,8 +6,3 @@
{{ block.super }}
<li class="breadcrumb-item active" aria-current="page">Diaper Lifetimes</li>
{% endblock %}
{% block javascript %}
{{ block.super }}
{{ javascript|safe }}
{% endblock %}

View File

@ -6,8 +6,3 @@
{{ block.super }}
<li class="breadcrumb-item active" aria-current="page">Diaper Types</li>
{% endblock %}
{% block javascript %}
{{ block.super }}
{{ javascript|safe }}
{% endblock %}

View File

@ -6,8 +6,3 @@
{{ block.super }}
<li class="breadcrumb-item active" aria-current="page">Average Feeding Durations</li>
{% endblock %}
{% block javascript %}
{{ block.super }}
{{ javascript|safe }}
{% endblock %}

View File

@ -25,4 +25,6 @@
{% block javascript %}
<script src="{% static "babybuddy/js/graph.js" %}"></script>
{{ js_graph|safe }}
{{ js_listener|safe }}
{% endblock %}

View File

@ -6,8 +6,3 @@
{{ block.super }}
<li class="breadcrumb-item active" aria-current="page">Sleep Pattern</li>
{% endblock %}
{% block javascript %}
{{ block.super }}
{{ javascript|safe }}
{% endblock %}

View File

@ -6,8 +6,3 @@
{{ block.super }}
<li class="breadcrumb-item active" aria-current="page">Sleep Totals</li>
{% endblock %}
{% block javascript %}
{{ block.super }}
{{ javascript|safe }}
{% endblock %}

View File

@ -6,8 +6,3 @@
{{ block.super }}
<li class="breadcrumb-item active" aria-current="page">Weight</li>
{% endblock %}
{% block javascript %}
{{ block.super }}
{{ javascript|safe }}
{% endblock %}

View File

@ -82,6 +82,7 @@ def split_graph_output(output):
:param output: a string of html and javascript comprising the graph.
:returns: a tuple of the the graph's html and javascript.
"""
html, javascript = output.split('<script')
javascript = '<script' + javascript
return html, javascript
html, js_graph, js_listener = output.split('<script')
js_graph = '<script' + js_graph
js_listener = '<script' + js_listener
return html, js_graph, js_listener

View File

@ -21,7 +21,7 @@ class DiaperChangeLifetimesChildReport(PermissionRequired403Mixin, DetailView):
child = context['object']
changes = models.DiaperChange.objects.filter(child=child)
if changes and changes.count() > 1:
context['html'], context['javascript'] = \
context['html'], context['js_graph'], context['js_listener'] = \
graphs.diaperchange_lifetimes(changes)
return context
@ -40,7 +40,7 @@ class DiaperChangeTypesChildReport(PermissionRequired403Mixin, DetailView):
child = context['object']
changes = models.DiaperChange.objects.filter(child=child)
if changes:
context['html'], context['javascript'] = \
context['html'], context['js_graph'], context['js_listener'] = \
graphs.diaperchange_types(changes)
return context
@ -64,7 +64,7 @@ class FeedingDurationChildReport(PermissionRequired403Mixin, DetailView):
child = context['object']
instances = models.Feeding.objects.filter(child=child)
if instances:
context['html'], context['javascript'] = \
context['html'], context['js_graph'], context['js_listener'] = \
graphs.feeding_duration(instances)
return context
@ -88,7 +88,7 @@ class SleepPatternChildReport(PermissionRequired403Mixin, DetailView):
child = context['object']
instances = models.Sleep.objects.filter(child=child).order_by('start')
if instances:
context['html'], context['javascript'] = \
context['html'], context['js_graph'], context['js_listener'] = \
graphs.sleep_pattern(instances)
return context
@ -112,7 +112,7 @@ class SleepTotalsChildReport(PermissionRequired403Mixin, DetailView):
child = context['object']
instances = models.Sleep.objects.filter(child=child).order_by('start')
if instances:
context['html'], context['javascript'] = \
context['html'], context['js_graph'], context['js_listener'] = \
graphs.sleep_totals(instances)
return context
@ -131,6 +131,6 @@ class WeightWeightChildReport(PermissionRequired403Mixin, DetailView):
child = context['object']
objects = models.Weight.objects.filter(child=child)
if objects:
context['html'], context['javascript'] = \
context['html'], context['js_graph'], context['js_listener'] = \
graphs.weight_weight(objects)
return context