Text showing error

Why do some texts appear repeatedly when using Iphone Safari (the same applies to chrome)?

Display on laptop screen is OK

Show on iphone

def plot_twrr(twrr: pl.DataFrame, window_width: int, year: int = None):
        fig = go.Figure()
        strategy_trace = go.Scatter(
            x=twrr["buy_date"],
            y=twrr["strategy_twrr"],
            name="Strategy",
            marker_color=STRATEGY_COLOR,
            fill="tozeroy",
            hovertemplate="%{y:+.1%}<extra></extra>",
            hoverlabel=HOVERLABEL,
        )
        benchmark_trace = go.Scatter(
            x=twrr["buy_date"],
            y=twrr["benchmark_twrr"],
            name="Benchmark",
            marker_color="grey",
            fill="tozeroy",
            hovertemplate="%{y:+.1%}<extra></extra>",
            hoverlabel=HOVERLABEL,
        )
        fig.add_traces([strategy_trace, benchmark_trace])

        if window_width < 500:
            annotation_size = U500_ANNO_SIZE
            title_size = U500_TITLE_SIZE
            subtitle_size = U500_SUBTITLE_SIZE
            legend_size = U500_LEGEND_SIZE
            legend_x = U500_LEGEND_X
            legend_y = U500_LEGEND_Y
            tick_size = U500_TICK_SIZE

        elif window_width > 500:
            annotation_size = A500_ANNO_SIZE
            title_size = A500_TITLE_SIZE
            subtitle_size = A500_SUBTITLE_SIZE
            legend_size = A500_LEGEND_SIZE
            legend_x = A500_LEGEND_X
            legend_y = A500_LEGEND_Y
            tick_size = A500_TICK_SIZE

        # 加入最高點
        df = twrr.filter(pl.col("strategy_twrr") == pl.col("strategy_twrr").max())
        x = df["buy_date"][0]
        y = df["strategy_twrr"][0]
        fig.add_annotation(
            x=x,
            y=y,
            text=f"{x} {y:+.1%}",
            xanchor="right",
            font=dict(
                size=annotation_size,
            ),
            arrowcolor=TEXT_COLOR,
            arrowwidth=2,
        )

        dtick = "M24" if year is None else "M2"
        fig.update_layout(
            title=dict(
                text="歷史績效<br>"
                f"<span style='font-size: {subtitle_size}px;'>"
                "Time-Weighted Rate of Return</span>",
                font_size=title_size,
            ),
            legend=dict(
                orientation="h",
                font_size=legend_size,
                xanchor="center",
                yanchor="bottom",
                x=legend_x,
                y=legend_y,
            ),
            hovermode="x",
            **UPDATE_LAYOUT,
        )

        fig.update_xaxes(
            showgrid=False,
            dtick=dtick,
            tickformat="%Y-%m",
            tickfont=dict(size=tick_size),
        )

        fig.update_yaxes(
            showgrid=False,
            tickformat=".0%",
            tickfont=dict(size=tick_size),
        )
        return fig

Hi @RyanLin , are you sure the codesnippet above works as it should (besides leaving out screenwidth 500, I would change the elif into else)?

Hi @marieanne
It worked good.
But only show on iphone has this bug.