主函数:执行数据查询、图表生成和HTML渲染的完整流程
()
| 232 | f.write(html_content) |
| 233 | |
| 234 | def main(): |
| 235 | """ |
| 236 | 主函数:执行数据查询、图表生成和HTML渲染的完整流程 |
| 237 | """ |
| 238 | # 查询数据库获取统计数据 |
| 239 | data = query_data() |
| 240 | |
| 241 | # 创建三个标签页容器 |
| 242 | bar_tab = Tab() |
| 243 | pie_tab = Tab() |
| 244 | wc_tab = Tab() |
| 245 | |
| 246 | # 生成第一季度的图表(1-30期) |
| 247 | create_echarts_tab(data, 0, 30, bar_tab, pie_tab, wc_tab, '第1季') |
| 248 | # 生成第二季度的图表(31-60期) |
| 249 | create_echarts_tab(data, 30, 60, bar_tab, pie_tab, wc_tab, '第2季') |
| 250 | # 生成第三季度的图表(61-90期) |
| 251 | create_echarts_tab(data, 60, 90, bar_tab, pie_tab, wc_tab, '第3季') |
| 252 | # 生成第三季度的图表(91-120期) |
| 253 | create_echarts_tab(data, 90, 120, bar_tab, pie_tab, wc_tab, '第4季') |
| 254 | |
| 255 | # 定义输出文件名 |
| 256 | bar_tab_html = 'bar_tab.html' |
| 257 | pie_tab_html = 'pie_tab.html' |
| 258 | wc_tab_html = 'wc_tab.html' |
| 259 | |
| 260 | # 渲染各个图表 |
| 261 | bar_tab.render(bar_tab_html) |
| 262 | pie_tab.render(pie_tab_html) |
| 263 | wc_tab.render(wc_tab_html) |
| 264 | |
| 265 | # 添加自定义样式 |
| 266 | create_tabs_with_style(bar_tab_html) |
| 267 | create_tabs_with_style(pie_tab_html) |
| 268 | create_tabs_with_style(wc_tab_html) |
| 269 | |
| 270 | # 生成最终的HTML页面 |
| 271 | render_html(bar_tab_html, pie_tab_html, wc_tab_html) |
| 272 | |
| 273 | |
| 274 | if __name__ == "__main__": |
no test coverage detected