fix: graph start from left axis

https://github.com/babybuddy/babybuddy/pull/444#issuecomment-1281767322
This commit is contained in:
Michael Salaverry 2023-09-30 06:39:41 +00:00 committed by Christopher Charbonneau Wells
parent 26e8a1f689
commit 1ebe5a5ce0
3 changed files with 6 additions and 5 deletions

View File

@ -37,7 +37,7 @@ def diaperchange_intervals(changes):
trace_solid = go.Scatter( trace_solid = go.Scatter(
name=_("Solid"), name=_("Solid"),
line=dict(shape="spline"), line=dict(shape="spline"),
x=list(changes.values_list("time", flat=True)), x=list(changes.values_list("time", flat=True))[1:],
y=[i.total_seconds() / 3600 for i in intervals_solid], y=[i.total_seconds() / 3600 for i in intervals_solid],
hoverinfo="text", hoverinfo="text",
text=[_duration_string_hms(i) for i in intervals_solid], text=[_duration_string_hms(i) for i in intervals_solid],
@ -46,7 +46,7 @@ def diaperchange_intervals(changes):
trace_wet = go.Scatter( trace_wet = go.Scatter(
name=_("Wet"), name=_("Wet"),
line=dict(shape="spline"), line=dict(shape="spline"),
x=list(changes.values_list("time", flat=True)), x=list(changes.values_list("time", flat=True))[1:],
y=[i.total_seconds() / 3600 for i in intervals_wet], y=[i.total_seconds() / 3600 for i in intervals_wet],
hoverinfo="text", hoverinfo="text",
text=[_duration_string_hms(i) for i in intervals_wet], text=[_duration_string_hms(i) for i in intervals_wet],
@ -55,7 +55,7 @@ def diaperchange_intervals(changes):
trace_total = go.Scatter( trace_total = go.Scatter(
name=_("Total"), name=_("Total"),
line=dict(shape="spline"), line=dict(shape="spline"),
x=list(changes.values_list("time", flat=True)), x=list(changes.values_list("time", flat=True))[1:],
y=[i.total_seconds() / 3600 for i in intervals], y=[i.total_seconds() / 3600 for i in intervals],
hoverinfo="text", hoverinfo="text",
text=[_duration_string_hms(i) for i in intervals], text=[_duration_string_hms(i) for i in intervals],

View File

@ -19,13 +19,13 @@
<a href="{% url 'reports:report-bmi-change-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Body Mass Index (BMI)" %}</a> <a href="{% url 'reports:report-bmi-change-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Body Mass Index (BMI)" %}</a>
<a href="{% url 'reports:report-diaperchange-amounts-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Diaper Change Amounts" %}</a> <a href="{% url 'reports:report-diaperchange-amounts-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Diaper Change Amounts" %}</a>
<a href="{% url 'reports:report-diaperchange-types-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Diaper Change Types" %}</a> <a href="{% url 'reports:report-diaperchange-types-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Diaper Change Types" %}</a>
<a href="{% url 'reports:report-diaperchange-lifetimes-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Diaper Lifetimes" %}</a>
<a href="{% url 'reports:report-diaperchange-intervals-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Diaper Intervals" %}</a> <a href="{% url 'reports:report-diaperchange-intervals-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Diaper Intervals" %}</a>
<a href="{% url 'reports:report-diaperchange-lifetimes-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Diaper Lifetimes" %}</a>
<a href="{% url 'reports:report-feeding-amounts-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Feeding Amounts" %}</a> <a href="{% url 'reports:report-feeding-amounts-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Feeding Amounts" %}</a>
<a href="{% url 'reports:report-feeding-duration-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Feeding Durations (Average)" %}</a> <a href="{% url 'reports:report-feeding-duration-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Feeding Durations (Average)" %}</a>
<a href="{% url 'reports:report-feeding-intervals-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Feeding Intervals" %}</a>
<a href="{% url 'reports:report-head-circumference-change-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Head Circumference" %}</a> <a href="{% url 'reports:report-head-circumference-change-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Head Circumference" %}</a>
<a href="{% url 'reports:report-height-change-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Height" %}</a> <a href="{% url 'reports:report-height-change-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Height" %}</a>
<a href="{% url 'reports:report-feeding-intervals-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Feeding Intervals" %}</a>
<a href="{% url 'reports:report-pumping-amounts-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Pumping Amounts" %}</a> <a href="{% url 'reports:report-pumping-amounts-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Pumping Amounts" %}</a>
<a href="{% url 'reports:report-sleep-pattern-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Sleep Pattern" %}</a> <a href="{% url 'reports:report-sleep-pattern-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Sleep Pattern" %}</a>
<a href="{% url 'reports:report-sleep-totals-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Sleep Totals" %}</a> <a href="{% url 'reports:report-sleep-totals-child' object.slug %}" class="list-group-item list-group-item-action">{% trans "Sleep Totals" %}</a>

View File

@ -174,6 +174,7 @@ class FeedingIntervalsChildReport(PermissionRequiredMixin, DetailView):
context["html"], context["js"] = graphs.feeding_intervals(instances) context["html"], context["js"] = graphs.feeding_intervals(instances)
return context return context
class HeadCircumferenceChangeChildReport(PermissionRequiredMixin, DetailView): class HeadCircumferenceChangeChildReport(PermissionRequiredMixin, DetailView):
""" """
Graph of head circumference change over time. Graph of head circumference change over time.