每个例子不一定是唯一解法, 只是恰好用到而已, 可随意发挥
颜色: 渐变, 其他效果等
{
"series": [
{
"data": [
{
"label": {
"show": false,
"position": "center"
},
"labelLine": {
"show": false
},
"itemStyle": {
"color": "#0A76BA"
}
},
{
"label": {
"show": true,
"position": "center",
"color": "#ffffff",
"fontSize": 36,
"formatter": "{d}%"
},
"itemStyle": {
"color": {
"x": 0,
"y": 0,
"x2": 1,
"y2": 0,
"type": "linear",
"global": false,
"colorStops": [
{
"offset": 0,
"color": "#FD42B9"
},
{
"offset": 1,
"color": "#F91F83"
}
]
}
}
}
]
}
],
"tooltip": {
"show": false
}
}
roundCap: 两端显示成圆形
{
"series": [
{
"axisLine": {
"roundCap": true,
"lineStyle": {
"width": 18
}
},
"detail": {
"formatter": "{value}%"
}
}
]
}
处理千分位并且拼接单位
{
"label": {
"show": true,
"formatter": "function (params) {\n\t\t return ( params.value + '').replace(/(\\d{1,3})(?=(\\d{3})+(?:$|\\.))/g,'$1,') + '万';\n\t\t}"
}
}
颜色渐变
{
"series": [
{
"data": [
{
"itemStyle": {
"color": {
"x": 0,
"y": 0,
"x2": 1,
"y2": 0,
"type": "linear",
"global": false,
"colorStops": [
{
"offset": 0,
"color": "#f3ea51"
},
{
"offset": 1,
"color": "#e2d058"
}
]
}
}
},
{
"itemStyle": {
"color": {
"x": 0,
"y": 0,
"x2": 1,
"y2": 0,
"type": "linear",
"global": false,
"colorStops": [
{
"offset": 0,
"color": "#05b2fd"
},
{
"offset": 1,
"color": "#027afb"
}
]
}
}
},
{
"itemStyle": {
"color": {
"x": 0,
"y": 0,
"x2": 1,
"y2": 0,
"type": "linear",
"global": false,
"colorStops": [
{
"offset": 0,
"color": "#565afb"
},
{
"offset": 1,
"color": "#8f93fd"
}
]
}
}
}
]
}
]
}
显示标签处理, 堆积图每个柱子颜色渐变
{
"label": {
"show": true,
"formatter": "{a}\n{@[1]}"
},
"series": [
{
"itemStyle": {
"color": {
"x": 0,
"y": 0,
"x2": 0,
"y2": 1,
"type": "linear",
"global": false,
"colorStops": [
{
"offset": 0,
"color": "#029EFD"
},
{
"offset": 1,
"color": "#0BD5D7"
}
]
}
}
},
{
"itemStyle": {
"color": {
"x": 0,
"y": 0,
"x2": 0,
"y2": 1,
"type": "linear",
"global": false,
"colorStops": [
{
"offset": 0,
"color": "#F49931"
},
{
"offset": 1,
"color": "#F8CD39"
}
]
}
}
},
{
"itemStyle": {
"color": {
"x": 0,
"y": 0,
"x2": 0,
"y2": 1,
"type": "linear",
"global": false,
"colorStops": [
{
"offset": 0,
"color": "green"
},
{
"offset": 1,
"color": "red"
}
]
}
}
}
]
}
每个柱子间隔变色, 加入足量的 data 数据来支撑每个柱子的颜色需要
{
"series": [
{
"data": [
{
"itemStyle": {
"normal": {
"color": "#027AFB"
}
}
},
{
"itemStyle": {
"normal": {
"color": "#00AEFF"
}
}
},
{
"itemStyle": {
"normal": {
"color": "#027AFB"
}
}
},
{
"itemStyle": {
"normal": {
"color": "#00AEFF"
}
}
},
{
"itemStyle": {
"normal": {
"color": "#027AFB"
}
}
},
{
"itemStyle": {
"normal": {
"color": "#00AEFF"
}
}
},
{
"itemStyle": {
"normal": {
"color": "#027AFB"
}
}
},
{
"itemStyle": {
"normal": {
"color": "#00AEFF"
}
}
},
{
"itemStyle": {
"normal": {
"color": "#027AFB"
}
}
},
{
"itemStyle": {
"normal": {
"color": "#00AEFF"
}
}
},
{
"itemStyle": {
"normal": {
"color": "#027AFB"
}
}
},
{
"itemStyle": {
"normal": {
"color": "#00AEFF"
}
}
},
{
"itemStyle": {
"normal": {
"color": "#027AFB"
}
}
},
{
"itemStyle": {
"normal": {
"color": "#00AEFF"
}
}
},
{
"itemStyle": {
"normal": {
"color": "#027AFB"
}
}
},
{
"itemStyle": {
"normal": {
"color": "#00AEFF"
}
}
}
]
}
]
}
自定义 tooltip 提示效果
{
"tooltip": {
"trigger": "item",
"backgroundColor": "transparent",
"padding": 0,
"formatter": "function (params){\n\t\t\tlet src=\"data:image/png;base64,iVBORw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