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.

146 lines
4.1 KiB

3 years ago
// 调性分布
3 years ago
export default function negaposiOption(dName = [], dPositive = [], dNegative = []) {
3 years ago
// let newValue = [];
// dValue.forEach(ele => {
// newValue.push(ele*1-100);
// })
3 years ago
console.log(
3 years ago
dNegative
3 years ago
);
console.log(
3 years ago
dPositive
3 years ago
);
3 years ago
const dns = []; // 负面
const dps = []; // 正面
3 years ago
for (let i = 0; i <= dNegative.length - 1; i++) {
if (dNegative[i] == 0 && dPositive[i] != 0) {
dps[i] = {
value: dPositive[i],
itemStyle: {
normal: {
// barBorderRadius:[9,9,9,9],
color: '#0084FF',
}
},
3 years ago
}
3 years ago
} else if (dNegative[i] != 0 && dPositive[i] == 0) {
dns[i] = {
value: dNegative[i],
itemStyle: {
normal: {
// barBorderRadius:[9,9,9,9],
color: '#FFBF00',
}
}
3 years ago
}
3 years ago
} else {
dns[i] = dNegative[i];
dps[i] = dPositive[i];
3 years ago
}
}
3 years ago
return {
3 years ago
tooltip: {
3 years ago
trigger: 'axis',
backgroundColor: "#08182F",
color: "#fff",
borderColor: "#3373CC",
textStyle: {
color: "#fff", //设置文字颜色
fontSize: 9
},
formatter: function (params) {
const arr = [];
arr.push(params[0].name)
for (let item of params) {
arr.push(item.seriesName + '' + item.value + '%')
}
var str = arr.join('\n');
return str;
},
extraCssText: "box-shadow: 0px 0px 10px 0px #3373CC;",
confine: true
3 years ago
},
legend: {
3 years ago
icon: 'rectangle', //data图标样式
itemWidth: 10, //data图标大小
itemHeight: 10,
left: 6,
textStyle: {
fontSize: 9,
fontWeight: 400
},
data: ['正面调性', '负面调性']
3 years ago
},
grid: {
3 years ago
top: 20,
left: 20,
containLabel: true
3 years ago
},
3 years ago
xAxis: [{
3 years ago
type: 'value',
show: false
3 years ago
}],
yAxis: [{
3 years ago
type: 'category',
inverse: true,
axisTick: {
3 years ago
show: false
},
axisLine: {
show: false
3 years ago
},
axisLabel: {
3 years ago
margin: 10,
fontSize: 9
3 years ago
},
data: dName
3 years ago
}],
series: [{
name: '正面调性',
type: 'bar',
barWidth: 12,
stack: 'Total',
label: {
show: false,
position: 'right',
formatter: function (params) {
return (params.data) + '%';
},
},
itemStyle: {
normal: {
// barBorderRadius:[9,0,0,9],
color: '#0084FF'
},
},
emphasis: {
focus: 'series'
},
data: dps
3 years ago
},
3 years ago
{
name: '负面调性',
type: 'bar',
barWidth: 9,
stack: 'Total',
label: {
show: false,
position: 'left',
formatter: function (params) {
return (params.data) + '%';
},
},
itemStyle: {
normal: {
// barBorderRadius:[0,9,9,0],
color: '#FFBF00',
},
},
emphasis: {
focus: 'series'
},
data: dns
}
3 years ago
]
3 years ago
};
3 years ago
}