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.
88 lines
2.2 KiB
88 lines
2.2 KiB
/*
|
|
* @Author: your name
|
|
* @Date: 2021-10-12 14:33:51
|
|
* @LastEditTime: 2021-11-09 17:56:25
|
|
* @LastEditors: Please set LastEditors
|
|
* @Description: In User Settings Edit
|
|
* @FilePath: /data-show/src/views/BrandInsight/weiboKol/opt.js
|
|
*/
|
|
import * as echarts from "echarts";
|
|
function createData(ds=[]) {
|
|
let arr = [];
|
|
for(let i = 0; i < ds.length; i++) {
|
|
let ele = ds[i];
|
|
let color = "";
|
|
if(ele.key === '正面') {
|
|
color = "#3373CC"
|
|
} else if(ele.key === '负面') {
|
|
color = '#CC9D12'
|
|
} else {
|
|
color = '#54BF93'
|
|
}
|
|
if(ele.value*1 > 0) {
|
|
let obj = { value: ele.value*1, name: ele.key, itemStyle: {
|
|
color: color
|
|
}};
|
|
arr.push(obj)
|
|
}
|
|
}
|
|
return arr;
|
|
}
|
|
export default function createOpt(ds = []) {
|
|
const data = createData(ds)
|
|
return {
|
|
legend: {
|
|
y: 10,
|
|
x: 10,
|
|
icon: 'roundRect',
|
|
textStyle: { //图例文字的样式
|
|
color: '#fff'
|
|
}
|
|
},
|
|
series: [
|
|
{
|
|
name: 'Access From0',
|
|
type: 'pie',
|
|
radius: ['55%', '68%'],
|
|
avoidLabelOverlap: false,
|
|
label: {
|
|
show: false,
|
|
position: 'center',
|
|
lineHeight: 30
|
|
},
|
|
emphasis: {
|
|
label: {
|
|
show: true,
|
|
fontSize: '20',
|
|
color: "#ffff",
|
|
formatter: function (p) {
|
|
return `${p.data.name}\n${p.percent}%\n${p.data.value}`
|
|
}
|
|
}
|
|
},
|
|
labelLine: {
|
|
show: false
|
|
},
|
|
data: data,
|
|
|
|
},
|
|
{
|
|
name: 'Access From1',
|
|
type: 'pie',
|
|
radius: ['70%', '74%'],
|
|
avoidLabelOverlap: false,
|
|
label: {
|
|
show: false,
|
|
position: 'center'
|
|
},
|
|
labelLine: {
|
|
show: false
|
|
},
|
|
center: ['50%', '50%'],//边框位置
|
|
data: data,
|
|
|
|
}
|
|
]
|
|
}
|
|
}
|