flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
10.73k stars 416 forks source link

MatplotlibChart messing up the layout #3642

Closed fccoelho closed 1 month ago

fccoelho commented 1 month ago

Duplicate Check

Describe the bug

I am inserting a MatplotibChart into a Card and I am getting the error below:

[ERROR:flutter/flow/layers/transform_layer.cc(23)] TransformLayer is constructed with an invalid matrix.
[ERROR:flutter/flow/layers/transform_layer.cc(23)] TransformLayer is constructed with an invalid matrix.
[ERROR:flutter/flow/layers/transform_layer.cc(23)] TransformLayer is constructed with an invalid matrix.
[ERROR:flutter/flow/layers/transform_layer.cc(23)] TransformLayer is constructed with an invalid matrix.

Code sample

Logs In the code below, `fig` is a matplotlib figure object created as described in flet docs. ```python page.plot_panel.content = MatplotlibChart(fig, isolated=True , expand=True) page.update() ``` `page.plot_panel` is a flet.Card() control.

To reproduce

  1. add the chart
  2. update the page

Expected behavior

I expected the chart to simply be rendered without screwing the layout

Screenshots / Videos

Screenshots / Video demonstration When the chart is added, it completely messes up the view layout: All widgets get moved into the top left corner, as can be seen in the screenshot below. ![image](https://github.com/user-attachments/assets/e5a289c7-cb10-408e-a8da-38a1904503d4)

Operating System

Linux

Operating system details

Ubuntu 24.04

Flet version

0.22.1

Regression

No, it isn't

Suggestions

No response

Logs

Logs ```console [Paste your logs here] ```

Additional details

No response

ndonkoHenri commented 1 month ago

Can you build some simple reproducible code, so we can test the issue?

fccoelho commented 1 month ago

I have instead switched to showing charts on a Bottom Sheet, thus avoiding figuring out the layout bug.