From 39ba6171d546e7fa45172483d575d8e14cb7c52b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20MADET?= Date: Tue, 12 Sep 2023 09:50:50 +0200 Subject: [PATCH] Improved co-purchaser graph --- tapir/statistics/utils.py | 12 ++++++++++-- tapir/statistics/views.py | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tapir/statistics/utils.py b/tapir/statistics/utils.py index 1361f28d5..276316975 100644 --- a/tapir/statistics/utils.py +++ b/tapir/statistics/utils.py @@ -13,8 +13,13 @@ def build_pie_chart_data(labels: list, data: list): } -def build_line_chart_data(x_axis_values: list, y_axis_values: list, data_label: str): - return { +def build_line_chart_data( + x_axis_values: list, + y_axis_values: list, + data_label: str, + y_axis_max: float | None = None, +): + data = { "type": "line", "data": { "labels": x_axis_values, @@ -26,3 +31,6 @@ def build_line_chart_data(x_axis_values: list, y_axis_values: list, data_label: ], }, } + if y_axis_max: + data["options"] = {"scales": {"y": {"max": y_axis_max}}} + return data diff --git a/tapir/statistics/views.py b/tapir/statistics/views.py index 3cd82b12e..62985b9d6 100644 --- a/tapir/statistics/views.py +++ b/tapir/statistics/views.py @@ -209,6 +209,7 @@ def get_context_data(self, **kwargs): data_label=_( "Percentage of members with a co-purchaser relative to the number of active members" ), + y_axis_max=100, ) def get_dates(self):