'commit'
This commit is contained in:
@@ -1,39 +0,0 @@
|
|||||||
# pip install pyecharts
|
|
||||||
import pyecharts
|
|
||||||
import json
|
|
||||||
|
|
||||||
#print(pyecharts.__version__)
|
|
||||||
from pyecharts import options as opts
|
|
||||||
from pyecharts.charts import Bar
|
|
||||||
from pyecharts.faker import Faker
|
|
||||||
from pyecharts.globals import CurrentConfig
|
|
||||||
|
|
||||||
# 配置使用自定义的 ECharts 路径
|
|
||||||
CurrentConfig.ONLINE_HOST = "https://gcore.jsdelivr.net/npm/echarts@6.0.0/dist/"
|
|
||||||
|
|
||||||
c = (
|
|
||||||
Bar()
|
|
||||||
.add_xaxis(Faker.choose())
|
|
||||||
.add_yaxis("商家A", Faker.values())
|
|
||||||
.add_yaxis("商家B", Faker.values())
|
|
||||||
.set_global_opts(title_opts=opts.TitleOpts(title="Bar-MarkLine(自定义)"))
|
|
||||||
.set_series_opts(
|
|
||||||
label_opts=opts.LabelOpts(is_show=False),
|
|
||||||
markline_opts=opts.MarkLineOpts(
|
|
||||||
data=[opts.MarkLineItem(y=50, name="yAxis=50")]
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
# 获取图表的选项配置,使用 dump_options_with_quotes 方法获取可以直接序列化的选项
|
|
||||||
options_str = c.dump_options_with_quotes()
|
|
||||||
|
|
||||||
# 输出选项字符串
|
|
||||||
print(options_str)
|
|
||||||
|
|
||||||
# 可选:将选项保存到文件
|
|
||||||
with open("bar_chart_config.json", "w", encoding="utf-8") as f:
|
|
||||||
f.write(options_str)
|
|
||||||
|
|
||||||
# 如果需要同时生成 HTML 文件,取消下面这行的注释
|
|
||||||
# c.render("bar_markline_custom.html")
|
|
@@ -1,268 +0,0 @@
|
|||||||
{
|
|
||||||
"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
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@@ -1,286 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Awesome-pyecharts</title>
|
|
||||||
<script type="text/javascript" src="https://gcore.jsdelivr.net/npm/echarts@6.0.0/dist/echarts.min.js"></script>
|
|
||||||
|
|
||||||
|
|
||||||
</head>
|
|
||||||
<body >
|
|
||||||
<div id="c0285272d60b4a42ae1f1408018c9af0" class="chart-container" style="width:900px; height:500px; "></div>
|
|
||||||
<script>
|
|
||||||
var chart_c0285272d60b4a42ae1f1408018c9af0 = echarts.init(
|
|
||||||
document.getElementById('c0285272d60b4a42ae1f1408018c9af0'), 'white', {renderer: 'canvas'});
|
|
||||||
var option_c0285272d60b4a42ae1f1408018c9af0 = {
|
|
||||||
"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,
|
|
||||||
108,
|
|
||||||
81,
|
|
||||||
140,
|
|
||||||
29,
|
|
||||||
44,
|
|
||||||
123
|
|
||||||
],
|
|
||||||
"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": [
|
|
||||||
115,
|
|
||||||
50,
|
|
||||||
20,
|
|
||||||
27,
|
|
||||||
117,
|
|
||||||
86,
|
|
||||||
136
|
|
||||||
],
|
|
||||||
"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": [
|
|
||||||
"\u5c0f\u7c73",
|
|
||||||
"\u4e09\u661f",
|
|
||||||
"\u534e\u4e3a",
|
|
||||||
"\u82f9\u679c",
|
|
||||||
"\u9b45\u65cf",
|
|
||||||
"VIVO",
|
|
||||||
"OPPO"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"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
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
chart_c0285272d60b4a42ae1f1408018c9af0.setOption(option_c0285272d60b4a42ae1f1408018c9af0);
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Reference in New Issue
Block a user