|
11 | 11 |
|
12 | 12 | app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
|
13 | 13 |
|
14 |
| -game = Game() |
15 |
| -df = game.get_data() |
16 |
| -tags = game.get_tags() |
17 |
| -labels = game.get_labels() |
| 14 | +game = None |
| 15 | +df = None |
| 16 | +tags = None |
| 17 | +labels = None |
18 | 18 |
|
19 | 19 |
|
20 | 20 | def draw_num_of_game_per_tag():
|
| 21 | + print (game.get_data_pth()) |
21 | 22 | data = {'tag': [], 'num': []}
|
22 | 23 | for key in labels.keys():
|
23 | 24 | data['tag'].append(key)
|
@@ -93,40 +94,46 @@ def draw_viewer_channel():
|
93 | 94 | return fig
|
94 | 95 |
|
95 | 96 |
|
96 |
| -## HTML layout for the web page |
97 |
| -app.layout = html.Div(children=[ |
98 |
| - html.H1(children='Twitch Analysis', style={'textAlign': 'center'}), |
99 |
| - |
100 |
| - # draw 2 plots in one row |
101 |
| - dbc.Row([ |
102 |
| - dbc.Col( |
103 |
| - html.Div([ |
104 |
| - dcc.Graph(id='num_of_game_per_tag_graph', figure=draw_num_of_game_per_tag()), |
105 |
| - ]) |
106 |
| - ), |
107 |
| - dbc.Col( |
108 |
| - html.Div([ |
109 |
| - dcc.Graph(id='total_viewers_graph', figure=draw_total_viewers()), |
110 |
| - ]) |
111 |
| - ) |
112 |
| - ]), |
113 |
| - |
114 |
| - dbc.Row([ |
115 |
| - dbc.Col( |
116 |
| - html.Div([ |
117 |
| - dcc.Graph(id='aver_viewers_graph', figure=draw_average_viewers()), |
118 |
| - ]) |
119 |
| - ), |
120 |
| - dbc.Col( |
121 |
| - html.Div([ |
122 |
| - dcc.Graph(id='peak_viewers_graph', figure=draw_peak_viewers()), |
123 |
| - ]) |
124 |
| - ), |
125 |
| - ]), |
126 |
| - |
127 |
| - dcc.Graph(id='viewer_channel_graph', figure=draw_viewer_channel()) |
128 |
| -]) |
129 |
| - |
130 |
| - |
131 |
| -def show(debug: bool): |
| 97 | +def show(debug: bool, dir, timestamp): |
| 98 | + # update global variables with input parameters |
| 99 | + global game, df, tags, labels |
| 100 | + game = Game(dir, timestamp) |
| 101 | + df = game.get_data() |
| 102 | + tags = game.get_tags() |
| 103 | + labels = game.get_labels() |
| 104 | + |
| 105 | + ## HTML layout for the web page |
| 106 | + app.layout = html.Div(children=[ |
| 107 | + html.H1(children='Twitch Analysis', style={'textAlign': 'center'}), |
| 108 | + |
| 109 | + # draw 2 plots in one row |
| 110 | + dbc.Row([ |
| 111 | + dbc.Col( |
| 112 | + html.Div([ |
| 113 | + dcc.Graph(id='num_of_game_per_tag_graph', figure=draw_num_of_game_per_tag()), |
| 114 | + ]) |
| 115 | + ), |
| 116 | + dbc.Col( |
| 117 | + html.Div([ |
| 118 | + dcc.Graph(id='total_viewers_graph', figure=draw_total_viewers()), |
| 119 | + ]) |
| 120 | + ) |
| 121 | + ]), |
| 122 | + |
| 123 | + dbc.Row([ |
| 124 | + dbc.Col( |
| 125 | + html.Div([ |
| 126 | + dcc.Graph(id='aver_viewers_graph', figure=draw_average_viewers()), |
| 127 | + ]) |
| 128 | + ), |
| 129 | + dbc.Col( |
| 130 | + html.Div([ |
| 131 | + dcc.Graph(id='peak_viewers_graph', figure=draw_peak_viewers()), |
| 132 | + ]) |
| 133 | + ), |
| 134 | + ]), |
| 135 | + |
| 136 | + dcc.Graph(id='viewer_channel_graph', figure=draw_viewer_channel()) |
| 137 | + ]) |
| 138 | + |
132 | 139 | app.run_server(debug=debug)
|
0 commit comments