Skip to content

bug: LineChart left_axis labels display incomplete #6445

@KangZhaoKui

Description

@KangZhaoKui

Duplicate Check

Describe the bug

LineChart customizing left_axis labels with ChartAxisLabel, the left Y-axis labels are not fully displayed.

Image

Code sample

Code
import flet_charts as fch
import flet as ft

def main(page: ft.Page):
    chart = fch.LineChart(
        interactive=True,
        expand=True,
        data_series=fch.LineChartData(
            stroke_width=2,
            color=ft.Colors.RED,
            below_line_gradient= None,
            curved=True,
            curve_smoothness=0.35,
            rounded_stroke_cap=True,
            points=[
                fch.LineChartDataPoint(0, 0.1),
                fch.LineChartDataPoint(1, 0.2),
                fch.LineChartDataPoint(2, 0.3),
                fch.LineChartDataPoint(3, 0.4),
                fch.LineChartDataPoint(4, 0.5),
                fch.LineChartDataPoint(5, 0.6),
                fch.LineChartDataPoint(6, 0.7),
                fch.LineChartDataPoint(7, 0.8),
                fch.LineChartDataPoint(8, 0.9),
                fch.LineChartDataPoint(9, 0.8),
                fch.LineChartDataPoint(10, 0.7),
                fch.LineChartDataPoint(11, 0.6),
            ],
        ),
        min_x=0,
        max_x=11,
        min_y=0.0,
        max_y=1.0,
        border=ft.Border.all(3, ft.Colors.with_opacity(0.2, ft.Colors.ON_SURFACE)),
        horizontal_grid_lines=fch.ChartGridLines(
            interval=0.1, color=ft.Colors.with_opacity(0.2, ft.Colors.ON_SURFACE), width=1
        ),
        vertical_grid_lines=fch.ChartGridLines(
            interval=1, color=ft.Colors.with_opacity(0.2, ft.Colors.ON_SURFACE), width=1
        ),
        tooltip=fch.LineChartTooltip(
            bgcolor=ft.Colors.with_opacity(0.8, ft.Colors.BLUE_GREY)
        ),
        left_axis=fch.ChartAxis(
            label_size=30,
            label_spacing=0.1, #The spacing/interval between labels.If a value is not set, a suitable value will be automatically calculated and used.
            # show_labels=True,
            # show_max=True,
            # show_min=True,
            labels=[
                fch.ChartAxisLabel(value=0.0,label="0%"),
                fch.ChartAxisLabel(value=0.1,label="10%"),
                fch.ChartAxisLabel(value=0.2,label="20%"),
                fch.ChartAxisLabel(value=0.3,label="30%"),
                fch.ChartAxisLabel(value=0.4,label="40%"),
                fch.ChartAxisLabel(value=0.5,label="50%"),
                fch.ChartAxisLabel(value=0.6,label="60%"),
                fch.ChartAxisLabel(value=0.7,label="70%"),
                fch.ChartAxisLabel(value=0.8,label="80%"),
                fch.ChartAxisLabel(value=0.9,label="90%"),
                fch.ChartAxisLabel(value=1.0,label="100%"),
            ],
        ),
        bottom_axis=fch.ChartAxis(
            label_size=30,
            labels=[
                fch.ChartAxisLabel(value=1,label="1"),
                fch.ChartAxisLabel(value=2,label="2"),
                fch.ChartAxisLabel(value=3,label="3"),
                fch.ChartAxisLabel(value=4,label="4"),
                fch.ChartAxisLabel(value=5,label="5"),
                fch.ChartAxisLabel(value=6,label="6"),
                fch.ChartAxisLabel(value=7,label="7"),
                fch.ChartAxisLabel(value=8,label="8"),
                fch.ChartAxisLabel(value=9,label="9"),
                fch.ChartAxisLabel(value=10,label="10"),
                fch.ChartAxisLabel(value=11,label="11"),
            ],
        ),
    )

    page.add(chart)

if __name__ == "__main__":
    ft.run(main)

To reproduce

1.Run the code;
2.Even set show_labels=True, show_max=True, show_min=True, still doesn't work.

Expected behavior

The left axis labels render fully and correctly according to the custom ChartAxisLabel values provided.

Screenshots / Videos

Captures

[Upload media here]

Operating System

Windows

Operating system details

Windows 11

Flet version

v0.84.0

Regression

I'm not sure / I don't know

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    👀 In review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions