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.
158 lines
4.2 KiB
158 lines
4.2 KiB
3 years ago
|
// 调性分布
|
||
|
export default function negaposiOption(dName = [], data = {}) {
|
||
|
// let newValue = [];
|
||
|
// dValue.forEach(ele => {
|
||
|
// newValue.push(ele*1-100);
|
||
|
// })
|
||
|
const totalData = []
|
||
|
const msg = []
|
||
|
for (let [index, i] of Object.keys(data).entries()) {
|
||
|
msg.push(i)
|
||
|
let obj = {
|
||
|
name: i,
|
||
|
type: 'bar',
|
||
|
barWidth: 12,
|
||
|
stack: 'Total',
|
||
|
label: {
|
||
|
show: false,
|
||
|
position: 'right',
|
||
|
formatter: function (params) {
|
||
|
return (params.data) + '%';
|
||
|
},
|
||
|
},
|
||
|
itemStyle: {
|
||
|
normal: {
|
||
|
barBorderRadius: '',
|
||
|
color: '#20cd61'
|
||
|
},
|
||
|
},
|
||
|
emphasis: {
|
||
|
focus: 'series'
|
||
|
},
|
||
|
data: data[i]
|
||
|
}
|
||
|
if (index == 0) {
|
||
|
obj.itemStyle.normal.barBorderRadius = [12, 0, 0, 12]
|
||
|
obj.itemStyle.normal.color = '#0283ff'
|
||
|
} else if (index == Object.keys(data).length - 1) {
|
||
|
obj.itemStyle.normal.barBorderRadius = [0, 12, 12, 0]
|
||
|
obj.itemStyle.normal.color = '#fec000'
|
||
|
}
|
||
|
totalData.push(obj)
|
||
|
}
|
||
|
return {
|
||
|
tooltip: {
|
||
|
trigger: 'axis',
|
||
|
axisPointer: {
|
||
|
type: 'shadow'
|
||
|
}
|
||
|
},
|
||
|
legend: {
|
||
|
data: msg,
|
||
|
left: 10,
|
||
|
// data:[{name:'正面'},{name:'中性'},{name:'负面'},]
|
||
|
textStyle: { //图例文字的样式
|
||
|
color: 'black',
|
||
|
fontSize: 8
|
||
|
},
|
||
|
itemWidth: 12,
|
||
|
itemHeight: 12,
|
||
|
borderRadius: 1,
|
||
|
},
|
||
|
grid: {
|
||
|
top: 20,
|
||
|
left: 12,
|
||
|
containLabel: true
|
||
|
},
|
||
|
xAxis: [{
|
||
|
type: 'value',
|
||
|
show: false
|
||
|
}],
|
||
|
yAxis: [{
|
||
|
type: 'category',
|
||
|
inverse: true,
|
||
|
axisTick: {
|
||
|
show: false
|
||
|
},
|
||
|
axisLine: {
|
||
|
show: false
|
||
|
},
|
||
|
axisLabel: {
|
||
|
margin: 10,
|
||
|
fontSize: 12
|
||
|
},
|
||
|
data: dName
|
||
|
}],
|
||
|
series: totalData
|
||
|
// [
|
||
|
// {
|
||
|
// name: '男',
|
||
|
// type: 'bar',
|
||
|
// barWidth:12,
|
||
|
// stack: 'Total',
|
||
|
// label: {
|
||
|
// show: false,
|
||
|
// position: 'right',
|
||
|
// formatter: function (params) {
|
||
|
// return (params.data)+'%';
|
||
|
// },
|
||
|
// },
|
||
|
// itemStyle:{
|
||
|
// normal:{
|
||
|
// barBorderRadius:[12,0,0,12],
|
||
|
// color: '#0084FF'
|
||
|
// },
|
||
|
// },
|
||
|
// emphasis: {
|
||
|
// focus: 'series'
|
||
|
// },
|
||
|
// data: dMan
|
||
|
// },
|
||
|
// {
|
||
|
// name: '女',
|
||
|
// type: 'bar',
|
||
|
// barWidth:12,
|
||
|
// stack: 'Total',
|
||
|
// label: {
|
||
|
// show: false,
|
||
|
// position: 'right',
|
||
|
// formatter: function (params) {
|
||
|
// return (params.data)+'%';
|
||
|
// },
|
||
|
// },
|
||
|
// itemStyle:{
|
||
|
// normal:{
|
||
|
// color: '#20cb65'
|
||
|
// },
|
||
|
// },
|
||
|
// emphasis: {
|
||
|
// focus: 'series'
|
||
|
// },
|
||
|
// data: dLady
|
||
|
// },
|
||
|
// {
|
||
|
// name: '未设置性别',
|
||
|
// type: 'bar',
|
||
|
// barWidth:12,
|
||
|
// stack: 'Total',
|
||
|
// label: {
|
||
|
// show: false,
|
||
|
// position: 'left',
|
||
|
// formatter: function (params) {
|
||
|
// return (params.data) +'%';
|
||
|
// },
|
||
|
// },
|
||
|
// itemStyle:{
|
||
|
// normal:{
|
||
|
// barBorderRadius:[0,12,12,0],
|
||
|
// color: '#FFBF00',
|
||
|
// },
|
||
|
// },
|
||
|
// emphasis: {
|
||
|
// focus: 'series'
|
||
|
// },
|
||
|
// data: noGender
|
||
|
// }
|
||
|
// ]
|
||
|
};
|
||
|
}
|