From 468f7c987376a3c59376b192a8cf75fab97e293d Mon Sep 17 00:00:00 2001 From: mokurin000 <1348292515a@gmail.com> Date: Mon, 4 Aug 2025 13:59:43 +0800 Subject: [PATCH] feat: generate better looking curves --- utils/flat_user_detail.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/utils/flat_user_detail.py b/utils/flat_user_detail.py index 878f212..7fc84f9 100644 --- a/utils/flat_user_detail.py +++ b/utils/flat_user_detail.py @@ -53,7 +53,10 @@ y_data = df["dxRating"].to_list() def init_chart( - x_type: Literal["value", "log"], x_min: int = 1, x_max: int = 5000 + x_type: Literal["value", "log"], + x_min: int = 1, + x_max: int = 5000, + y_max: int = 330, ) -> Scatter: return ( Scatter( @@ -73,7 +76,8 @@ def init_chart( type_="value", axistick_opts=opts.AxisTickOpts(is_show=True), splitline_opts=opts.SplitLineOpts(is_show=True), - max_=330, + min_=50, + max_=y_max, ), tooltip_opts=opts.TooltipOpts(is_show=False), visualmap_opts=opts.VisualMapOpts(max_=330), @@ -89,5 +93,16 @@ def init_chart( x_max = (x_data[-1] // 50 * 50) + 50 -init_chart("value", 1, x_max).render(f"{user_id}-pc-rating-linear.html") -init_chart("log", 1, x_max).render(f"{user_id}-pc-rating-log.html") +y_max = min(330, (y_data[-1] // 50 * 50) + 50) +init_chart( + "value", + 1, + x_max, + y_max=y_max, +).render(f"{user_id}-pc-rating-linear.html") +init_chart( + "log", + (x_max // 100) or 10, + x_max, + y_max=y_max, +).render(f"{user_id}-pc-rating-log.html")