Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LineChart.bottom_axis custom labels not showing unless value is the same as the first or last data_point. #5087

Open
1 task done
NathanCummings opened this issue Mar 16, 2025 · 1 comment

Comments

@NathanCummings
Copy link

Duplicate Check

Describe the bug

I'm trying to use POSIX timestamps (from datetime.datime.timestamp) as values fro my x-axis, but when I do, my labels stop appearing correctly.

I have prepared a minimal example with 2 datasets, one that works and one that doesn't.

Code sample

Code
import flet as ft

data_points_1 = [
    ft.LineChartDataPoint(1, 1),
    ft.LineChartDataPoint(3, 1.5),
    ft.LineChartDataPoint(5, 1.4),
    ft.LineChartDataPoint(7, 3.4),
    ft.LineChartDataPoint(10, 2),
    ft.LineChartDataPoint(12, 2.2),
    ft.LineChartDataPoint(13, 1.8),
]
labels_1 = [
    ft.ChartAxisLabel(value=2, label=ft.Text("SEP")),
    ft.ChartAxisLabel(value=7, label=ft.Text("OCT")),
    ft.ChartAxisLabel(value=12, label=ft.Text("DEC")),
]

data_points_2 = [
    ft.LineChartDataPoint(1735430400, 1),
    ft.LineChartDataPoint(1735948800, 1.5),
    ft.LineChartDataPoint(1736467200, 1.4),
    ft.LineChartDataPoint(1736812800, 3.4),
    ft.LineChartDataPoint(1737676800, 2),
    ft.LineChartDataPoint(1738800000, 2.2),
    ft.LineChartDataPoint(1741996800, 1.8),
]
labels_2 = [
    ft.ChartAxisLabel(value=1735430400, label=ft.Text("SEP")),
    ft.ChartAxisLabel(value=1736812800, label=ft.Text("OCT")),
    ft.ChartAxisLabel(value=1738800000, label=ft.Text("NOV")),
    ft.ChartAxisLabel(value=1741996800, label=ft.Text("DEC")),
]


def main(page: ft.Page):
    chart_1 = ft.LineChart(
        data_series=[ft.LineChartData(data_points_1)],
        top_axis=ft.ChartAxis(title=ft.Text("Working"), show_labels=False),
        bottom_axis=ft.ChartAxis(labels=labels_1),
    )
    chart_2 = ft.LineChart(
        data_series=[ft.LineChartData(data_points_2)],
        top_axis=ft.ChartAxis(title=ft.Text("Not Working"), show_labels=False),
        bottom_axis=ft.ChartAxis(labels=labels_2),
    )
    page.add(chart_1, chart_2)


ft.app(main)

To reproduce

To reproduce, run the supplied code.

Expected behavior

All labels to show along the bottom

Screenshots / Videos

Captures Image

Operating System

macOS

Operating system details

Sequoia 15.3.2

Flet version

0.26.0

Regression

No, it isn't

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

@NathanCummings NathanCummings changed the title LineChart.bottom_axis custom labels not showing unless value is the sam was the first or last data_point. LineChart.bottom_axis custom labels not showing unless value is the same as the first or last data_point. Mar 16, 2025
@NathanCummings
Copy link
Author

UPDATE:
Tried it in desktop mode and I get one more label, so there is some spacing-related reason for this behaviour. I'll keep investigating, but I still propose this is a bug as the behaviour is different if for default labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant