今天根据ui的图写了个横向柱状图
![](https://i-blog.csdnimg.cn/blog_migrate/a29a000f9bbf2da82013c53295e28348.png)
const initOption = {
tooltip: {
trigger: 'item',
axisPointer: {
// 坐标轴指示器,坐标轴触发有效
type: 'line' // 默认为直线,可选为:'line' | 'shadow'
}
},
legend: {
left: 'center',
top: '5%',
show: true,
type: 'scroll',
data: ['男', '女'],
itemWidth: 12,
itemHeight: 12,
itemGap: 30
},
grid: [
{
show: false,
left: '5%',
right: '60%',
top: 60,
bottom: '30',
containLabel: true
},
{
show: false,
left: '60%',
right: '5%',
top: 60,
bottom: '30'
},
{
show: false,
left: '50%',
right: '10%',
top: 60,
bottom: '30',
containLabel: true
}
],
xAxis: [
{
type: 'value',
gridIndex: 0,
inverse: true,
axisLine: {
show: false
},
splitLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
show: false
},
data: []
},
{
type: 'value',
gridIndex: 1,
inverse: false,
axisLine: {
show: false
},
splitLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
show: false
},
data: []
},
{
type: 'value',
gridIndex: 2,
inverse: false,
axisLine: {
//只有这个
show: false
},
splitLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
show: false
},
data: []
}
],
yAxis: [
{
type: 'category',
inverse: true,
position: 'right',
gridIndex: 0,
axisLine: {
show: false
},
splitLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
show: false
},
data: [] // 中间的数据
},
{
type: 'category',
position: 'center',
inverse: true,
gridIndex: 1,
axisLine: {
show: false
},
splitLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
show: true,
// fontSize: 14,
// color: '#333',
align: 'center',
interval: 'auto',
margin: 40
},
data: [] // 中间的数据
},
{
type: 'category',
gridIndex: 2,
inverse: true,
position: 'left',
axisLine: {
show: false
},
splitLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
show: false
}
}
],
series: [
{
colId: 'col402utokg',
name: '男',
type: 'bar',
stack: null,
data: [],
barWidth: 10,
color: '#5473e8',
xAxisIndex: 0,
yAxisIndex: 0,
label: {
position: 'left',
show: false,
fontSize: 12,
color: '#333'
}
},
{
colId: 'col3kkgr6h9',
name: '女',
type: 'bar',
// type: 'pictorialBar',
// symbol: 'images', //可以使用自定义图片作为柱状图形
// symbol: 'image://' + BASE_PATH + '/pages/transportation/pages/supply/img/qianlanzz.png',
stack: null,
data: [],
barWidth: 10,
color: '#ff766f',
xAxisIndex: 1,
yAxisIndex: 1,
label: {
position: 'right',
show: false,
fontSize: 12,
color: '#333'
}
}
]
}