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.

66 lines
1.7 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
},
3 years ago
itemWidth: 10,
itemHeight: 10,
3 years ago
},
3 years ago
tooltip: {
trigger: 'axis',
3 years ago
backgroundColor: "#08182F",
color: "#fff",
borderColor: "#3373CC",
textStyle: {
color: "#fff", //设置文字颜色
fontSize: 9
},
extraCssText: "box-shadow: 0px 0px 10px 0px #3373CC;",
confine: true
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
}