You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.4 KiB

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