plotly_chart.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. from flet_core import Column, MainAxisAlignment, Row
  2. import plotly.express as px
  3. from flet.plotly_chart import PlotlyChart
  4. import plotly.graph_objects as go
  5. import matplotlib
  6. import matplotlib.pyplot as plt
  7. from flet.matplotlib_chart import MatplotlibChart
  8. matplotlib.use("svg")
  9. class ChartPage():
  10. ''''''
  11. def DrawChart(self):
  12. ''''''
  13. x = ['day 1', 'day 1', 'day 1', 'day 1', 'day 1', 'day 1',
  14. 'day 2', 'day 2', 'day 2', 'day 2', 'day 2', 'day 2']
  15. fig = go.Figure()
  16. fig.add_trace(go.Box(
  17. y=[0.2, 0.2, 0.6, 1.0, 0.5, 0.4, 0.2, 0.7, 0.9, 0.1, 0.5, 0.3],
  18. x=x,
  19. name='kale',
  20. marker_color='#3D9970'
  21. ))
  22. fig.add_trace(go.Box(
  23. y=[0.6, 0.7, 0.3, 0.6, 0.0, 0.5, 0.7, 0.9, 0.5, 0.8, 0.7, 0.2],
  24. x=x,
  25. name='radishes',
  26. marker_color='#FF4136'
  27. ))
  28. fig.add_trace(go.Box(
  29. y=[0.1, 0.3, 0.1, 0.9, 0.6, 0.6, 0.9, 1.0, 0.3, 0.6, 0.8, 0.5],
  30. x=x,
  31. name='carrots',
  32. marker_color='#FF851B'
  33. ))
  34. fig.update_layout(
  35. yaxis_title='normalized moisture',
  36. boxmode='group' # group together boxes of the different traces for each value of x
  37. )
  38. return fig
  39. def __init__(self):
  40. super().__init__()