|
|
/*
|
|
|
* @Author: your name
|
|
|
* @Date: 2021-10-09 09:49:50
|
|
|
* @LastEditTime: 2021-10-28 13:07:24
|
|
|
* @LastEditors: Please set LastEditors
|
|
|
* @Description: In User Settings Edit
|
|
|
* @FilePath: /data-show/src/views/Index/userPortrait/opt.js
|
|
|
*/
|
|
|
import * as echarts from "echarts";
|
|
|
// let colors = ['#3373CC', '#CC9D12', '#54BF93','#f15c80', '#e4d354', '#8085e8', '#8d4653', '#91e8e1','#f7a35c','#90ed7d']
|
|
|
function createData(ds = [], colors) {
|
|
|
let arr = [];
|
|
|
ds.map((ele, index) => {
|
|
|
let obj = {
|
|
|
value: ele.value,
|
|
|
name: ele.key,
|
|
|
itemStyle: {
|
|
|
// color: new echarts.graphic.LinearGradient(0, 1, 1, 0, [{
|
|
|
// //给颜色设置渐变色 前面4个参数,给第一个设置1,第四个设置0 ,就是水平渐变
|
|
|
// //给第一个设置0,第四个设置1,就是垂直渐变
|
|
|
// offset: 0,
|
|
|
// color: 'black'
|
|
|
// }, {
|
|
|
// offset: 1,
|
|
|
// color: colors[index]
|
|
|
// }])
|
|
|
color: colors[index]
|
|
|
}
|
|
|
}
|
|
|
arr.push(obj)
|
|
|
})
|
|
|
return arr;
|
|
|
}
|
|
|
export default function createOpt(ds = [], color = []) {
|
|
|
const data = createData(ds, color);
|
|
|
return {
|
|
|
series: [
|
|
|
{
|
|
|
name: 'Access From0',
|
|
|
type: 'pie',
|
|
|
radius: ['65%', '80%'],
|
|
|
avoidLabelOverlap: false,
|
|
|
label: {
|
|
|
show: false,
|
|
|
position: 'center',
|
|
|
lineHeight: 30
|
|
|
},
|
|
|
emphasis: {
|
|
|
label: {
|
|
|
show: true,
|
|
|
fontSize: '16',
|
|
|
color: "#ffff",
|
|
|
fontWeight: 'bold',
|
|
|
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: ['86%', '94%'],
|
|
|
avoidLabelOverlap: false,
|
|
|
label: {
|
|
|
show: false,
|
|
|
position: 'center'
|
|
|
},
|
|
|
labelLine: {
|
|
|
show: false
|
|
|
},
|
|
|
center: ['50%', '50%'],//边框位置
|
|
|
data: data
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
}
|