Skip to content

Commit c5179d7

Browse files
committed
Set matplotlib backend in library, remove from tests
Moved the matplotlib backend configuration to the main library file (matplotlib_chart.py) and removed redundant backend setting from all test files. This centralizes backend setup and simplifies test scripts.
1 parent 395b42b commit c5179d7

File tree

5 files changed

+3
-14
lines changed

5 files changed

+3
-14
lines changed

src/flet_charts/matplotlib_chart.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import flet.canvas as fc
99

1010
try:
11+
import matplotlib
1112
from matplotlib.figure import Figure
1213
except ImportError as e:
1314
raise Exception(
@@ -22,6 +23,8 @@
2223

2324
logger = logging.getLogger("flet-charts.matplotlib")
2425

26+
matplotlib.use("module://flet_charts.matplotlib_backends.backend_flet_agg")
27+
2528
figure_cursors = {
2629
"default": None,
2730
"pointer": ft.MouseCursor.CLICK,

tests/mpl_v2_3d.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import logging
22

33
import flet as ft
4-
import matplotlib
54
import matplotlib.pyplot as plt
65
import numpy as np
76

87
import flet_charts
98

10-
matplotlib.use("module://flet_charts.matplotlib_backends.backend_flet_agg")
11-
129
logging.basicConfig(level=logging.INFO)
1310

1411

tests/mpl_v2_animate.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import logging
22

33
import flet as ft
4-
import matplotlib
54
import matplotlib.pyplot as plt
65
import numpy as np
76

87
import flet_charts
98

10-
matplotlib.use("module://flet_charts.matplotlib_backends.backend_flet_agg")
11-
129
logging.basicConfig(level=logging.INFO)
1310

1411
state = {}

tests/mpl_v2_basic.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import logging
22

33
import flet as ft
4-
import matplotlib
54
import matplotlib.pyplot as plt
65
import numpy as np
76

87
import flet_charts
98

10-
matplotlib.use("module://flet_charts.matplotlib_backends.backend_flet_agg")
11-
129
logging.basicConfig(level=logging.INFO)
1310

1411

tests/mpl_v2_events.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import flet as ft
2-
import matplotlib
32
import matplotlib.pyplot as plt
43
import numpy as np
54

65
import flet_charts
76

8-
matplotlib.use("module://flet_charts.matplotlib_backends.backend_flet_agg")
9-
10-
# logging.basicConfig(level=logging.DEBUG)
11-
127
state = {}
138

149

0 commit comments

Comments
 (0)