/* * @Author: your name * @Date: 2021-10-12 15:14:58 * @LastEditTime: 2021-10-14 10:43:47 * @LastEditors: Please set LastEditors * @Description: In User Settings Edit * @FilePath: /data-show/src/views/BrandInsight/weiboPortraits/opt.js */ 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] }]) } } arr.push(obj) }) return arr; } import * as echarts from "echarts"; export default function createOpt1(ds = [], color = []) { const data = createData(ds, color); return { series: [ { name: 'Access From0', type: 'pie', radius: ['63%', '77%'], avoidLabelOverlap: false, label: { show: false, position: 'center', fontSize: '40', color: "#ffff", }, emphasis: { label: { show: true, fontSize: '22', color: "#ffff", fontWeight: 'bold', formatter: (p)=>{ return p.data.name + '\n' + p.percent + '%' + '\n' + p.data.value; }, } }, labelLine: { show: false }, data: data, }, { name: 'Access From1', type: 'pie', radius: ['80%', '84%'], avoidLabelOverlap: false, label: { show: false, position: 'center' }, labelLine: { show: false }, center: ['50%', '50%'],//边框位置 data: data, } ] } }