option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
textStyle: {
color: '#fff',
},
},
},
dataset: {
source: apiData,
dimensions: ["region", "djl"]
},
grid: {
borderWidth: 0,
top: 40,
bottom: 50,
left: 50,
right: 30,
textStyle: {
color: '#fff',
},
lineStyle: {
color: 'rgba(0,30,40,0.4)',
},
},
calculable: true,
xAxis: [{
type: 'category',
axisLine: {
lineStyle: {
color: 'rgba(120,150,150,0.5)',
},
},
splitLine: {
show: false,
},
axisTick: {
show: false,
},
splitArea: {
show: false,
},
axisLabel: {
interval: 0,
color: '#88cbfe',
fontSize: 14,
formatter: function(value) {
if (value.length > 4 && value.length <= 8) {
return value.substr(0, 4) + '\n' + value.substr(4, 4)
} else if (value.length > 8) {
return value.substr(0, 4) + '\n' + value.substr(4, 4) + '...'
} else {
return value
}
}
}
}, ],
yAxis: [{
name: '',
nameTextStyle: {
color: 'rgba(136,203,254,0.5)',
padding: [0, 0, 0, -50],
},
nameGap: 15,
type: 'value',
splitLine: {
show: true,
lineStyle: {
type: 'solid',
color: 'rgba(100,100,120,0.2)',
},
},
min: 0,
axisLine: {
show: false,
},
axisTick: {
show: false,
},
axisLabel: {
show: true,
interval: 0,
color: 'rgba(136,203,254,0.5)',
fontSize: 12,
formatter: '{value}%',
},
splitArea: {
show: false,
},
}],
series: [{
name: '柱顶部',
type: 'pictorialBar',
symbolSize: [15, 9],
symbolOffset: [0, -5],
z: 12,
tooltip: {
show: false
},
itemStyle: {
normal: {
color: function(params) {
let ty = Number(params.data.djl);
if (0 < ty && ty < 90) {
return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: "rgba(213,79,26,1)"
},
{
offset: 1,
color: "rgba(213,79,26,1)"
}
])
} else if (90 < ty && ty < 95) {
return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: "rgba(162,127,22,1)"
},
{
offset: 1,
color: "rgba(162,127,22,1)"
}
])
} else if (95 <= ty && ty < 100) {
return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: "rgba(47,136,229,1)"
},
{
offset: 1,
color: "rgba(47,136,229,1)"
}
])
}
}
},
},
label: {
show: false,
position: 'top',
fontSize: 16,
},
symbolPosition: 'end',
data: apiData.djl,
},
{
name: '柱底部',
type: 'pictorialBar',
symbolSize: [15, 9],
symbolOffset: [0, 0],
z: 12,
tooltip: {
show: false
},
itemStyle: {
normal: {
color: function(params) {
let ty = Number(params.data.djl);
if (0 < ty && ty < 90) {
return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: "rgba(213, 79, 26, 0.15)"
},
{
offset: 1,
color: "rgba(213, 79, 26, 0.15)"
}
])
} else if (90 < ty && ty < 95) {
return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: "rgba(162, 127, 22, 0.2)"
},
{
offset: 1,
color: "rgba(162, 127, 22, 0.2)"
}
])
} else if (95 <= ty && ty < 100) {
return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: "rgba(47, 136, 229, 0.2)"
},
{
offset: 1,
color: "rgba(47, 136, 229, 0.2)"
}
])
}
}
},
},
data: apiData.djl,
},
{
name: '设备登记率(%)',
type: 'bar',
barMaxWidth: 15,
barGap: '10%',
itemStyle: {
normal: {
color: function(params) {
let ty = Number(params.data.djl);
if (0 < ty && ty < 90) {
return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: "rgba(213,79,26,0.8)"
},
{
offset: 1,
color: "rgba(213, 79, 26, 0.15)"
}
])
} else if (90 < ty && ty < 95) {
return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: "rgba(162,127,22,0.8)"
},
{
offset: 1,
color: "rgba(162, 127, 22, 0.2)"
}
])
} else if (95 <= ty && ty < 100) {
return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: "rgba(47,136,229,0.8)"
},
{
offset: 1,
color: "rgba(47, 136, 229, 0.2)"
}
])
}
}
}
},
label: {
normal: {
show: false,
position: 'top',
fontSize: 14,
color: '#ffffff',
offset: [0, -10],
fontFamily: 'MicrosoftYaHei'
},
},
encode: {
x: "tupe",
y: "djl"
}
},
],
}
在这里插入图片描述