echarts 立体柱图
2022-06-08 本文已影响0人
陈桑
转载:链接地址
复制到echarts里面直接使用
var rocket = 'image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAAAeCAYAAACPOlitAAAAAXNSR0IArs4c6QAADOdJREFUaEPFmttvXNd1xn9r7TNnOBzeRIkSRetiW7Lk0q5tWXIcSS2qFrENFMlLADtNAyc24tZAC/ShL+1b1H+hQAuoqKvIjlvAfstLYSNFpCRO4tiMGsryTfcLZZOWeBvOcOZc9ir2GdKmZF1oKao3MDjDOZe993fW5VvfonA7x17T4WGiyhQRKyglKRq1iOKYMkKllVAlolN88Yk8qBm5OnLzZB7yCNJwBFJ1tMSoJxG1+Us0tg2SvfqUhHO3bcjv7clmMvwqpe6EjmZOt4OV3rPGKUMGdwBrUfrM6AU6xIgNqghlMUrAZWsJQGE0gXmEeRGaAk0PdSdMmTHuPWMScdopY02YiudozbTI40Fs9bv4gz8gR8RuZY+3BpCZ7Pkh5ZmcNcTcibARYUh9AUo/RrcZPSp0G/QA3UAXEAORGRoWL1dZhYVttX+3AJQICRSf8L1mMGPGNDAtcEk8Ex4+Qbloxrwas5ZztjbEx8f/XFo3C9LyAdpr+uRwe8lv1Sl1lemNE9aZMazKMMZGEwYRBswzIEKnQQSoUADhwvebXeiS+wJ0nrbbhWMarMxg2mBCYEzgEzEuePgwjTmWdTDWnKF++gwJP8C+iFUtC6Dt+6wUddOfZvRnQkWhx3LuUmGLGptNGMJYjbCStqUEMFi07WVNcovILRhcDZiEwoouiHAyV46jHNOcS5ozl2bMZQnT7/6tzC1nymuvfa/p9rV0uA4qaUSXZPTmxqAYG0VYhzKgMGSeTVCAUw2xZRGc5Ux+W64xEoM6MC7CWYTzAhfMOI9w2udMhkDvHTMdjlpWZ37keQlWeNVxdYD2mu4cpi9rsNYLK0yIEdIso0/gEadsQUhMqIjnfmAjUFmc4Ytazhe9fulOrnFvcL8xE97FGHfgvHEB400Pk6p0ecNEmIwd57I649cC6XMA7X7BupMOBjBW4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xLWXJCw/KMkJ+lyB1Xm+EWLF4PooIub7424fyyNDAwIPLJzk+NBiCRWtOy5RGYN2aMve/Z5i92Rh5cwAVuzZ58lX05BQa3vTAIDo7SyWr0lGBOMoo59ARMlegDFG7/14yh4baT9qdkdiH9B4AXNj4Qp4v1iWhahfS4B7F70aWC63cSMI/NUg4uqImbLZCVotohP58d4yfqOJXD+ALl75CwrmRWy09/3+RuEhFeIi0mAAAAABJRU5ErkJggg==';
option = {
backgroundColor:'black',
tooltip: {
trigger: 'axis',
confine: true,
axisPointer: {
type: 'none'
},
textStyle: {
fontSize: 12,
fontWeight: 500
},
formatter(params) {
// 只展示柱子对应的内容,把顶部底部的 tooltip 过滤掉
return params.reduce((pre, i) => {
if (i.componentSubType === 'bar') {
i.marker = i.marker.replace(/\[object Object\]/, i.color.colorStops[1].color);
i.value = `<span style="flex: 1; text-align: right; margin-left: 16px;">${i.value}</span>`;
const current = `<div>${i.seriesName}</div>` + `<div style="display: flex; align-items: center; height: 26px;">${i.marker}${i.name} ${i.value}</div>`;
return `${pre}${current}`;
}
return pre;
}, '');
},
},
// legend: {
// right: 10,
// top: 12,
// type: 'scroll',
// icon: 'circle',
// itemWidth: 10,
// itemHeight: 10,
// itemGap: 16,
// selectedMode: false,
// },
grid: {
left: '3%',
right: '4%',
bottom: '5%',
containLabel: true
},
xAxis: {
type: 'category',
show: true,
data: ['处理厂1', '处理厂2', '处理厂3', '处理厂4', '处理厂5'],
axisLine: {
show:false,
lineStyle: {
color: '#F2F4F7',
}
},
axisTick: {
show: false
},
axisLabel: {
margin: 30,
color: 'rgb(55,177,255)'
},
},
yAxis: {
boundaryGap: [0, 0.01],
axisLine: {
show:false,
lineStyle: {
color: '#F2F4F7'
}
},
axisTick: {
show: false
},
axisLabel: {
show: true,
fontWeight:700,
color:'rgb(55,177,255)',
},
splitLine: {
show: false,
lineStyle: {
color: '#F2F4F7'
}
},
},
series: [
{
name: '餐厨处理厂分析',
type: 'bar',
barWidth: 36,
barCategoryGap: 12,
data: [11, 10, 9, 8, 7],
itemStyle: { // 柱体渐变色
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: 'rgba(50, 161, 255, 0.7)',
},
{
offset: 1,
color: 'rgba(50, 161, 255, 0.15)',
},
])
},
},
{
name: '',
type: 'pictorialBar',
symbolSize: [36, 18],
// 这个属性很重要,直接决定了顶部跟柱子是否契合
symbolOffset: [0, -8],
itemStyle: {
color: 'rgb(50, 161, 255)',
// color:'red',
},
symbolPosition: 'end',
// 要给成武汉这两个柱子的值,这是圆柱顶部,值不给对高度会对不上
data: [11, 10, 9, 8, 7],
},
{
name: '',
type: 'pictorialBar',
symbolSize: [70, 30],
symbolOffset: [0, 20],
symbol: rocket,
symbolPosition: 'start',
data: [1, 1, 1, 1, 1],
},
],
}