export default function stack(yName=[],data=[],color=[]){ let msgData = [] let arr = ['正面','中性','负面',] for(let [index,i] of data.entries()){ console.log(i); let obj = { type: 'bar', stack: 'total', // barWidth:40, name:arr[index], emphasis: { focus: 'series' }, itemStyle:{ color:color[index] }, data:i } msgData.push(obj) } const option = { legend: { left:10, // data:[{name:'正面'},{name:'中性'},{name:'负面'},] textStyle: { //图例文字的样式 color: 'black', fontSize: 8 }, itemWidth: 12, itemHeight: 12, borderRadius: 1, }, tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, grid: { }, xAxis: { type: 'value', axisLabel: { textStyle:{ fontSize:8 } }, }, yAxis: { type: 'category', data: yName, axisLabel: { textStyle:{ fontSize:8 } }, }, //数据 series:msgData } return option }