fish 1 year ago
parent
commit
469d5db72e
3 changed files with 23 additions and 12 deletions
  1. 9 0
      demo/app/model/user.py
  2. 13 12
      demo/app/pages/plotly_chart.py
  3. 1 0
      demo/app/pages/todo.py

+ 9 - 0
demo/app/model/user.py

@@ -1,3 +1,12 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+'''
+@Contact :   liuyuqi.gov@msn.cn
+@Time    :   2023/12/29 20:40:35
+@License :   Copyright © 2017-2022 liuyuqi. All Rights Reserved.
+@Desc    :   user model
+'''
+
 class UserModel(object):
     
     def __init__(self):

+ 13 - 12
demo/app/pages/plotly_chart.py

@@ -1,36 +1,37 @@
 from flet_core import Column, MainAxisAlignment, Row
-import plotly.express as px
 from flet.plotly_chart import PlotlyChart
-import plotly.graph_objects as go
-import matplotlib
-import matplotlib.pyplot as plt
+import plotly
+import plotly.express
+
+# import matplotlib
+# import matplotlib.pyplot as plt
 from flet.matplotlib_chart import MatplotlibChart
 
-matplotlib.use("svg")
+# matplotlib.use("svg")
 
 class ChartPage():
     '''chart page '''
     
     def DrawChart(self):
-        ''' draw chart '''
+        ''' 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 = go.Figure()
-
-        fig.add_trace(go.Box(
+        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(go.Box(
+        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(go.Box(
+        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',
@@ -44,4 +45,4 @@ class ChartPage():
         return fig
 
     def __init__(self):
-        super().__init__()
+        super().__init__()

+ 1 - 0
demo/app/pages/todo.py

@@ -37,3 +37,4 @@ class TodoPage(Column):
             self.list
         ])
         self.controls.append(content)
+