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 }} {{ block.super }}
<li class="breadcrumb-item active" aria-current="page">Diaper Lifetimes</li> <li class="breadcrumb-item active" aria-current="page">Diaper Lifetimes</li>
{% endblock %} {% endblock %}
{% block javascript %}
{{ block.super }}
{{ javascript|safe }}
{% endblock %}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,8 +6,3 @@
{{ block.super }} {{ block.super }}
<li class="breadcrumb-item active" aria-current="page">Weight</li> <li class="breadcrumb-item active" aria-current="page">Weight</li>
{% endblock %} {% 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. :param output: a string of html and javascript comprising the graph.
:returns: a tuple of the the graph's html and javascript. :returns: a tuple of the the graph's html and javascript.
""" """
html, javascript = output.split('<script') html, js_graph, js_listener = output.split('<script')
javascript = '<script' + javascript js_graph = '<script' + js_graph
return html, javascript js_listener = '<script' + js_listener
return html, js_graph, js_listener

View File

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