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.

69 lines
1.7 KiB

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)
}
const option = {
legend: {
icon: 'rectangle', //data图标样式
left:15,
// data:[{name:'正面'},{name:'中性'},{name:'负面'},]
textStyle: { //图例文字的样式
color: 'black',
fontSize: 8
},
itemWidth: 10,
itemHeight: 10,
},
tooltip: {
trigger: 'axis',
backgroundColor: "#08182F",
color: "#fff",
borderColor: "#3373CC",
textStyle: {
color: "#fff", //设置文字颜色
fontSize: 9
},
extraCssText: "box-shadow: 0px 0px 10px 0px #3373CC;",
confine: true
},
grid: {
top: '13%',
left:50,
},
xAxis: {
type: 'value',
axisLabel: {
textStyle:{
fontSize:8
}
},
},
yAxis: {
type: 'category',
data: yName,
axisLabel: {
textStyle:{
fontSize:8
}
},
},
//数据
series:msgData
}
return option
}