123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- from flet_core import Column, MainAxisAlignment, Row
- from flet.plotly_chart import PlotlyChart
- import plotly
- import plotly.express
- # import matplotlib
- # import matplotlib.pyplot as plt
- from flet.matplotlib_chart import MatplotlibChart
- # matplotlib.use("svg")
- class ChartPage():
- '''chart page '''
-
- def DrawChart(self):
- ''' draw chart '''
- x = ['day 1', 'day 1', 'day 1', 'day 1', 'day 1', 'day 1',
- 'day 2', 'day 2', 'day 2', 'day 2', 'day 2', 'day 2']
- fig = plotly.graph_objects.Figure()
- # 箱线图
- fig.add_trace(plotly.graph_objects.Box(
- 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],
- x=x,
- name='kale',
- marker_color='#3D9970'
- ))
- fig.add_trace(plotly.graph_objects.Box(
- 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],
- x=x,
- name='radishes',
- marker_color='#FF4136'
- ))
- fig.add_trace(plotly.graph_objects.Box(
- 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],
- x=x,
- name='carrots',
- marker_color='#FF851B'
- ))
- fig.update_layout(
- yaxis_title='normalized moisture',
- boxmode='group' # group together boxes of the different traces for each value of x
- )
- return fig
- def __init__(self):
- super().__init__()
|