Skip to content
Empty file.
3 changes: 2 additions & 1 deletion sdk/python/examples/controls/charts/bar_chart/example_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@ def main(page: ft.Page):
)


ft.run(main)
if __name__ == "__main__":
ft.run(main)
3 changes: 2 additions & 1 deletion sdk/python/examples/controls/charts/bar_chart/example_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ def on_chart_event(e: fch.BarChartEvent):
)


ft.run(main)
if __name__ == "__main__":
ft.run(main)
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,5 @@ def handle_event(e: fch.CandlestickChartEvent):
)


ft.run(main)
if __name__ == "__main__":
ft.run(main)
Empty file.
3 changes: 2 additions & 1 deletion sdk/python/examples/controls/charts/line_chart/example_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,5 @@ def toggle_data(e: ft.Event[ft.IconButton]):
page.add(ft.IconButton(ft.Icons.REFRESH, on_click=toggle_data), chart)


ft.run(main)
if __name__ == "__main__":
ft.run(main)
3 changes: 2 additions & 1 deletion sdk/python/examples/controls/charts/line_chart/example_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,5 @@ def toggle_data(e: ft.Event[ft.ElevatedButton]):
page.add(ft.Button("avg", on_click=toggle_data), chart)


ft.run(main)
if __name__ == "__main__":
ft.run(main)
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ def update_lines(num, walks, lines):
page.add(flet_charts.MatplotlibChartWithToolbar(figure=fig, expand=True))


ft.run(main)
if __name__ == "__main__":
ft.run(main)
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ def main(page: ft.Page):
page.add(fch.MatplotlibChart(figure=fig, expand=True))


ft.run(main)
if __name__ == "__main__":
ft.run(main)
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ def update(self):
page.add(flet_charts.MatplotlibChartWithToolbar(figure=fig, expand=True))


ft.run(main)
if __name__ == "__main__":
ft.run(main)
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ def main(page: ft.Page):
page.add(flet_charts.MatplotlibChartWithToolbar(figure=fig))


ft.run(main)
if __name__ == "__main__":
ft.run(main)
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ def main(page: ft.Page):
page.add(fch.MatplotlibChartWithToolbar(figure=fig, expand=True))


ft.run(main)
if __name__ == "__main__":
ft.run(main)
Empty file.
3 changes: 2 additions & 1 deletion sdk/python/examples/controls/charts/pie_chart/example_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ def on_chart_event(e: fch.PieChartEvent):
page.add(chart)


ft.run(main)
if __name__ == "__main__":
ft.run(main)
3 changes: 2 additions & 1 deletion sdk/python/examples/controls/charts/pie_chart/example_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ def on_chart_event(e: fch.PieChartEvent):
page.add(chart)


ft.run(main)
if __name__ == "__main__":
ft.run(main)
3 changes: 2 additions & 1 deletion sdk/python/examples/controls/charts/pie_chart/example_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,5 @@ def on_chart_event(e: fch.PieChartEvent):
page.add(chart)


ft.run(main)
if __name__ == "__main__":
ft.run(main)
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ def main(page: ft.Page):
page.add(fch.PlotlyChart(figure=fig, expand=True))


ft.run(main)
if __name__ == "__main__":
ft.run(main)
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ def main(page: ft.Page):
page.add(fch.PlotlyChart(figure=fig, expand=True))


ft.run(main)
if __name__ == "__main__":
ft.run(main)
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ def main(page: ft.Page):
page.add(fch.PlotlyChart(figure=fig, expand=True))


ft.run(main)
if __name__ == "__main__":
ft.run(main)
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ def main(page: ft.Page):
page.add(fch.PlotlyChart(figure=fig, expand=True))


ft.run(main)
if __name__ == "__main__":
ft.run(main)
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def main(page: ft.Page):
page.title = "Radar chart"
page.padding = 20
page.vertical_alignment = page.horizontal_alignment = "center"
# page.vertical_alignment = page.horizontal_alignment = "center"
page.theme_mode = ft.ThemeMode.LIGHT

categories = ["macOS", "Linux", "Windows"]
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,5 @@ def handle_event(e: fch.ScatterChartEvent):
)


ft.run(main)
if __name__ == "__main__":
ft.run(main)
32 changes: 32 additions & 0 deletions sdk/python/packages/flet-charts/integration_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from pathlib import Path

import pytest_asyncio

import flet.testing as ftt


def create_flet_app(request):
params = getattr(request, "param", {})
return ftt.FletTestApp(
flutter_app_dir=(Path(__file__).parent / "../../../../../client").resolve(),
test_path=request.fspath,
flet_app_main=params.get("flet_app_main"),
skip_pump_and_settle=params.get("skip_pump_and_settle", False),
assets_dir=Path(__file__).resolve().parent / "assets",
)


@pytest_asyncio.fixture(scope="module")
async def flet_app(request):
flet_app = create_flet_app(request)
await flet_app.start()
yield flet_app
await flet_app.teardown()


@pytest_asyncio.fixture(scope="function")
async def flet_app_function(request):
flet_app = create_flet_app(request)
await flet_app.start()
yield flet_app
await flet_app.teardown()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import pytest

import flet as ft
import flet_charts as fch
import flet.testing as ftt
from examples.controls.charts.bar_chart import example_1, example_2


@pytest.mark.asyncio(loop_scope="function")
async def test_image_for_docs(flet_app_function: ftt.FletTestApp, request):
flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT
await flet_app_function.assert_control_screenshot(
request.node.name,
fch.BarChart(
border=ft.Border.all(1, ft.Colors.GREY_400),
groups=[
fch.BarChartGroup(
x=0,
rods=[
fch.BarChartRod(
from_y=0,
to_y=40,
color=ft.Colors.BLUE_GREY_200,
),
],
),
fch.BarChartGroup(
x=1,
rods=[
fch.BarChartRod(
from_y=0,
to_y=60,
color=ft.Colors.BLUE_GREY_600,
),
],
),
],
),
)


@pytest.mark.parametrize(
"flet_app_function",
[{"flet_app_main": example_1.main}],
indirect=True,
)
@pytest.mark.asyncio(loop_scope="function")
async def test_example_1(flet_app_function: ftt.FletTestApp):
flet_app_function.page.enable_screenshots = True
flet_app_function.page.update()
await flet_app_function.tester.pump_and_settle()
flet_app_function.assert_screenshot(
"example_1",
await flet_app_function.page.take_screenshot(),
)


@pytest.mark.parametrize(
"flet_app_function",
[{"flet_app_main": example_2.main}],
indirect=True,
)
@pytest.mark.asyncio(loop_scope="function")
async def test_example_2(flet_app_function: ftt.FletTestApp):
flet_app_function.page.enable_screenshots = True
flet_app_function.page.update()
await flet_app_function.tester.pump_and_settle()
flet_app_function.assert_screenshot(
"example_2",
await flet_app_function.page.take_screenshot(),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import pytest

import flet as ft
import flet_charts as fch
import flet.testing as ftt
from examples.controls.charts.candlestick_chart import example_1


@pytest.mark.asyncio(loop_scope="function")
async def test_image_for_docs(flet_app_function: ftt.FletTestApp, request):
flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT
await flet_app_function.assert_control_screenshot(
request.node.name,
fch.CandlestickChart(
min_x=-1,
max_x=2,
min_y=20,
max_y=30,
bgcolor=ft.Colors.AMBER_200,
spots=[
fch.CandlestickChartSpot(
x=0,
open=22.6,
high=28.3,
low=21.4,
close=24.1,
),
fch.CandlestickChartSpot(
x=1,
open=25.4,
high=27.6,
low=22.3,
close=23.9,
),
],
),
)


@pytest.mark.parametrize(
"flet_app_function",
[{"flet_app_main": example_1.main}],
indirect=True,
)
@pytest.mark.asyncio(loop_scope="function")
async def test_example_1(flet_app_function: ftt.FletTestApp):
flet_app_function.page.enable_screenshots = True
flet_app_function.page.update()
await flet_app_function.tester.pump_and_settle()
flet_app_function.assert_screenshot(
"example_1",
await flet_app_function.page.take_screenshot(),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import pytest

import flet as ft
import flet_charts as fch
import flet.testing as ftt
from examples.controls.charts.line_chart import example_1, example_2


@pytest.mark.asyncio(loop_scope="function")
async def test_image_for_docs(flet_app_function: ftt.FletTestApp, request):
flet_app_function.page.theme_mode = ft.ThemeMode.LIGHT
await flet_app_function.assert_control_screenshot(
request.node.name,
fch.LineChart(
data_series=[
fch.LineChartData(
color=ft.Colors.BLUE_GREY_500,
curved=True,
points=[
fch.LineChartDataPoint(1, 0.5),
fch.LineChartDataPoint(2, 1.5),
fch.LineChartDataPoint(3, 1),
],
),
fch.LineChartData(
color=ft.Colors.AMBER_400,
curved=True,
points=[
fch.LineChartDataPoint(1, 2),
fch.LineChartDataPoint(2, 0.5),
fch.LineChartDataPoint(3, 1.5),
],
),
],
min_y=0,
max_y=3,
min_x=0,
max_x=5,
),
)


@pytest.mark.parametrize(
"flet_app_function",
[{"flet_app_main": example_1.main}],
indirect=True,
)
@pytest.mark.asyncio(loop_scope="function")
async def test_example_1(flet_app_function: ftt.FletTestApp):
flet_app_function.page.enable_screenshots = True
flet_app_function.page.update()
await flet_app_function.tester.pump_and_settle()
flet_app_function.assert_screenshot(
"example_1",
await flet_app_function.page.take_screenshot(),
)


@pytest.mark.parametrize(
"flet_app_function",
[{"flet_app_main": example_2.main}],
indirect=True,
)
@pytest.mark.asyncio(loop_scope="function")
async def test_example_2(flet_app_function: ftt.FletTestApp):
flet_app_function.page.enable_screenshots = True
flet_app_function.page.update()
await flet_app_function.tester.pump_and_settle()
flet_app_function.assert_screenshot(
"example_2",
await flet_app_function.page.take_screenshot(),
)
Loading
Loading