series: [
{
data: [120, 200, 150, 80, 70, 110, 130, 230, 30],
name: '',
type: 'bar',
barWidth: '14',
barGap: '0.5',
label: {
// 柱图头部显示值
show: true,
position: 'top',
fontSize: '12px',
formatter: params => {
console.log(23456)
console.log(params)
return '{' + params.dataIndex + '|' + params.value + '' + '}'
},
rich: {
0: {
color: '#3ECC7D'
},
1: {
color: '#488BFF'
},
2: {
color: '#FD5050'
},
3: {
color: '#FAA837'
},
4: {
color: '#488BFF'
},
5: {
color: '#FAA837'
},
6: {
color: '#FD5050'
}
}
},
itemStyle: {
normal: {
color: function(params) {
const colorArray = [
{
top: '#3ECC7D',
bottom: '#3EA6CC'
},
{
top: '#488BFF',
bottom: '#7248FF'
},
{
top: '#FD5050',
bottom: '#FDBA50'
},
{
top: '#FAA837',
bottom: '#FFEE69'
},
{
top: '#488BFF',
bottom: '#7248FF'
},
{
top: '#FAA837',
bottom: '#FFEE69'
},
{
top: '#FD5050',
bottom: '#FDBA50'
},
{
top: '#B5BFCC',
bottom: '#5B6066'
},
{
top: '#008000',
bottom: '#98FB98'
},
{
top: '#008000',
bottom: '#98FB98'
}
]
const num = colorArray.length
return {
type: 'linear',
colorStops: [
{
offset: 0,
color: colorArray[params.dataIndex % num].bottom
},
{
offset: 1,
color: colorArray[params.dataIndex % num].top
}
]
}
},
// 这里设置柱形图圆角 [左上角,右上角,右下角,左下角]
borderRadius: [7, 7, 0, 0]
}
}
}
]