From cb60e5c61f836e175c12f46bd3d0f20de2a5d3a9 Mon Sep 17 00:00:00 2001 From: HuangHai <10402852@qq.com> Date: Wed, 10 Sep 2025 15:03:48 +0800 Subject: [PATCH] 'commit' --- Routes/__init__.py | 0 Start.py | 0 Test/TestEcharts.py | 18 +-- Test/bar_chart_config.json | 268 +++++++++++++++++++++++++++++++++++++ 4 files changed, 277 insertions(+), 9 deletions(-) create mode 100644 Routes/__init__.py create mode 100644 Start.py create mode 100644 Test/bar_chart_config.json diff --git a/Routes/__init__.py b/Routes/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Start.py b/Start.py new file mode 100644 index 0000000..e69de29 diff --git a/Test/TestEcharts.py b/Test/TestEcharts.py index 0beca7d..0d7a8ee 100644 --- a/Test/TestEcharts.py +++ b/Test/TestEcharts.py @@ -25,15 +25,15 @@ c = ( ) ) -# 获取图表的选项配置 -options = c.get_options() +# 获取图表的选项配置,使用 dump_options_with_quotes 方法获取可以直接序列化的选项 +options_str = c.dump_options_with_quotes() -# 将选项转换为 JSON 字符串 -json_str = json.dumps(options, indent=2, ensure_ascii=False) +# 输出选项字符串 +print(options_str) -# 输出 JSON 字符串 -print(json_str) - -# 可选:将 JSON 保存到文件 +# 可选:将选项保存到文件 with open("bar_chart_config.json", "w", encoding="utf-8") as f: - f.write(json_str).render("bar_markline_custom.html")) + f.write(options_str) + +# 如果需要同时生成 HTML 文件,取消下面这行的注释 +# c.render("bar_markline_custom.html") diff --git a/Test/bar_chart_config.json b/Test/bar_chart_config.json new file mode 100644 index 0000000..061fac8 --- /dev/null +++ b/Test/bar_chart_config.json @@ -0,0 +1,268 @@ +{ + "animation": true, + "animationThreshold": 2000, + "animationDuration": 1000, + "animationEasing": "cubicOut", + "animationDelay": 0, + "animationDurationUpdate": 300, + "animationEasingUpdate": "cubicOut", + "animationDelayUpdate": 0, + "aria": { + "enabled": false + }, + "color": [ + "#5470c6", + "#91cc75", + "#fac858", + "#ee6666", + "#73c0de", + "#3ba272", + "#fc8452", + "#9a60b4", + "#ea7ccc" + ], + "series": [ + { + "type": "bar", + "name": "\u5546\u5bb6A", + "legendHoverLink": true, + "data": [ + 122, + 146, + 81, + 104, + 141, + 56, + 117 + ], + "realtimeSort": false, + "showBackground": false, + "stackStrategy": "samesign", + "cursor": "pointer", + "barMinHeight": 0, + "barCategoryGap": "20%", + "barGap": "30%", + "large": false, + "largeThreshold": 400, + "seriesLayoutBy": "column", + "datasetIndex": 0, + "clip": true, + "zlevel": 0, + "z": 2, + "label": { + "show": false, + "margin": 8, + "valueAnimation": false + }, + "markLine": { + "silent": false, + "precision": 2, + "label": { + "show": true, + "margin": 8, + "valueAnimation": false + }, + "data": [ + { + "name": "yAxis=50", + "yAxis": 50 + } + ] + }, + "rippleEffect": { + "show": true, + "brushType": "stroke", + "scale": 2.5, + "period": 4 + } + }, + { + "type": "bar", + "name": "\u5546\u5bb6B", + "legendHoverLink": true, + "data": [ + 147, + 118, + 149, + 81, + 138, + 115, + 94 + ], + "realtimeSort": false, + "showBackground": false, + "stackStrategy": "samesign", + "cursor": "pointer", + "barMinHeight": 0, + "barCategoryGap": "20%", + "barGap": "30%", + "large": false, + "largeThreshold": 400, + "seriesLayoutBy": "column", + "datasetIndex": 0, + "clip": true, + "zlevel": 0, + "z": 2, + "label": { + "show": false, + "margin": 8, + "valueAnimation": false + }, + "markLine": { + "silent": false, + "precision": 2, + "label": { + "show": true, + "margin": 8, + "valueAnimation": false + }, + "data": [ + { + "name": "yAxis=50", + "yAxis": 50 + } + ] + }, + "rippleEffect": { + "show": true, + "brushType": "stroke", + "scale": 2.5, + "period": 4 + } + } + ], + "legend": [ + { + "data": [ + "\u5546\u5bb6A", + "\u5546\u5bb6B" + ], + "selected": {}, + "show": true, + "padding": 5, + "itemGap": 10, + "itemWidth": 25, + "itemHeight": 14, + "backgroundColor": "transparent", + "borderColor": "#ccc", + "borderRadius": 0, + "pageButtonItemGap": 5, + "pageButtonPosition": "end", + "pageFormatter": "{current}/{total}", + "pageIconColor": "#2f4554", + "pageIconInactiveColor": "#aaa", + "pageIconSize": 15, + "animationDurationUpdate": 800, + "selector": false, + "selectorPosition": "auto", + "selectorItemGap": 7, + "selectorButtonGap": 10 + } + ], + "tooltip": { + "show": true, + "trigger": "item", + "triggerOn": "mousemove|click", + "axisPointer": { + "type": "line" + }, + "showContent": true, + "alwaysShowContent": false, + "showDelay": 0, + "hideDelay": 100, + "enterable": false, + "confine": false, + "appendToBody": false, + "transitionDuration": 0.4, + "textStyle": { + "fontSize": 14 + }, + "borderWidth": 0, + "padding": 5, + "order": "seriesAsc" + }, + "xAxis": [ + { + "show": true, + "scale": false, + "nameLocation": "end", + "nameGap": 15, + "gridIndex": 0, + "inverse": false, + "offset": 0, + "splitNumber": 5, + "minInterval": 0, + "splitLine": { + "show": true, + "lineStyle": { + "show": true, + "width": 1, + "opacity": 1, + "curveness": 0, + "type": "solid" + } + }, + "animation": true, + "animationThreshold": 2000, + "animationDuration": 1000, + "animationEasing": "cubicOut", + "animationDelay": 0, + "animationDurationUpdate": 300, + "animationEasingUpdate": "cubicOut", + "animationDelayUpdate": 0, + "data": [ + "\u53ef\u4e50", + "\u96ea\u78a7", + "\u6a59\u6c41", + "\u7eff\u8336", + "\u5976\u8336", + "\u767e\u5a01", + "\u9752\u5c9b" + ] + } + ], + "yAxis": [ + { + "show": true, + "scale": false, + "nameLocation": "end", + "nameGap": 15, + "gridIndex": 0, + "inverse": false, + "offset": 0, + "splitNumber": 5, + "minInterval": 0, + "splitLine": { + "show": true, + "lineStyle": { + "show": true, + "width": 1, + "opacity": 1, + "curveness": 0, + "type": "solid" + } + }, + "animation": true, + "animationThreshold": 2000, + "animationDuration": 1000, + "animationEasing": "cubicOut", + "animationDelay": 0, + "animationDurationUpdate": 300, + "animationEasingUpdate": "cubicOut", + "animationDelayUpdate": 0 + } + ], + "title": [ + { + "show": true, + "text": "Bar-MarkLine\uff08\u81ea\u5b9a\u4e49\uff09", + "target": "blank", + "subtarget": "blank", + "padding": 5, + "itemGap": 10, + "textAlign": "auto", + "textVerticalAlign": "auto", + "triggerEvent": false + } + ] +} \ No newline at end of file