
let name = [
'测试一',
'测试二',
'测试三',
'测试四',
'测试五',
'测试六',
'测试七',
'测试八',
'测试九'
];
let value = [1, 5, 4, 6, 7, 2, 45, 67, 9];
let toolTims = null;
const offsetX = 16;
const offsetY = 8;
const CubeLeft = echarts.graphic.extendShape({
shape: {
x: 0,
y: 0
},
buildPath: function (ctx, shape) {
const xAxisPoint = shape.xAxisPoint;
const c0 = [shape.x, shape.y - offsetX * 0.2];
const c1 = [shape.x - offsetX, shape.y - offsetY];
const c2 = [xAxisPoint[0] - offsetX, xAxisPoint[1] - offsetY];
const c3 = [xAxisPoint[0], xAxisPoint[1]];
ctx
.moveTo(c0[0], c0[1])
.lineTo(c1[0], c1[1])
.lineTo(c2[0], c2[1])
.lineTo(c3[0], c3[1])
.closePath();
}
});
const CubeRight = echarts.graphic.extendShape({
shape: {
x: 0,
y: 0
},
buildPath: function (ctx, shape) {
const xAxisPoint = shape.xAxisPoint;
const c1 = [shape.x, shape.y - offsetX * 0.2];
const c2 = [xAxisPoint[0], xAxisPoint[1]];
const c3 = [xAxisPoint[0] + offsetX, xAxisPoint[1] - offsetY];
const c4 = [shape.x + offsetX, shape.y - offsetY];
ctx
.moveTo(c1[0], c1[1])
.lineTo(c2[0], c2[1])
.lineTo(c3[0], c3[1])
.lineTo(c4[0], c4[1])
.closePath();
}
});
const CubeTop = echarts.graphic.extendShape({
shape: {
x: 0,
y: 0
},
buildPath: function (ctx, shape) {
const c1 = [shape.x, shape.y - offsetX * 0.2];
const c2 = [shape.x + offsetX, shape.y - offsetY];
const c3 = [shape.x, shape.y - offsetX * 0.8];
const c4 = [shape.x - offsetX, shape.y - offsetY];
ctx
.moveTo(c1[0], c1[1])
.lineTo(c2[0], c2[1])
.lineTo(c3[0], c3[1])
.lineTo(c4[0], c4[1])
.closePath();
}
});
echarts.graphic.registerShape('CubeLeft', CubeLeft);
echarts.graphic.registerShape('CubeRight', CubeRight);
echarts.graphic.registerShape('CubeTop', CubeTop);
option = {
backgroundColor: '#010d3a',
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'none'
},
formatter: function (params) {
const item = params[1];
return `${item.name}:${item.value}%`;
}
},
grid: {
top: '8%',
left: '5%',
right: '5%',
bottom: '5%',
containLabel: true
},
xAxis: {
type: 'category',
data: name,
axisLine: {
lineStyle: {
color: '#475D72'
}
},
axisTick: {
show: false
},
splitLine: {
show: false
},
axisLabel: {
interval: 0,
textStyle: {
color: '#fff'
}
}
},
yAxis: {
name: '(处理率)',
nameTextStyle: {
fontSize: 18
},
type: 'value',
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
fontSize: 18
},
splitLine: {
show: true,
lineStyle: {
type: [10, 5],
dashOffset: 10,
color: '#2E3A45'
}
}
},
series: [
{
name: '',
type: 'custom',
renderItem: (params, api) => {
const location = api.coord([api.value(0), api.value(1)]);
return {
type: 'group',
children: [
{
type: 'CubeLeft',
shape: {
api,
xValue: api.value(0),
yValue: api.value(1),
x: location[0],
y: location[1],
xAxisPoint: api.coord([api.value(0), 0])
},
style: {
fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: '#088bff'
},
{
offset: 1,
color: '#088bff00'
}
])
}
},
{
type: 'CubeRight',
shape: {
api,
xValue: api.value(0),
yValue: api.value(1),
x: location[0],
y: location[1],
xAxisPoint: api.coord([api.value(0), 0])
},
style: {
fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: '#088bff'
},
{
offset: 1,
color: '#088bff00'
}
])
}
},
{
type: 'CubeTop',
shape: {
api,
xValue: api.value(0),
yValue: api.value(1),
x: location[0],
y: location[1],
xAxisPoint: api.coord([api.value(0), 0])
},
style: {
fill: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: '#61b5ff'
},
{
offset: 1,
color: '#61b5ff'
}
])
}
}
]
};
},
data: value
},
{
name: '',
type: 'bar',
label: {
normal: {
show: true,
position: 'top',
formatter: (e) => {
return `${e.value}%`;
},
fontSize: 16,
color: '#43C4F1',
offset: [0, -15]
}
},
itemStyle: {
color: 'transparent'
},
tooltip: {},
data: value
}
]
};