/* * @Author: your name * @Date: 2021-10-12 14:33:51 * @LastEditTime: 2021-10-19 10:42:22 * @LastEditors: Please set LastEditors * @Description: In User Settings Edit * @FilePath: /data-show/src/views/BrandInsight/weiboKol/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] // }]) color: colors[index] } } arr.push(obj) }) return arr; } import * as echarts from "echarts"; export default function createOpt(ds = [], color = []) { const data = createData(ds, color); return { legend: { textStyle: { //图例文字的样式 color: '#fff' }, y: 10, x: 16 }, series: [ { name: 'Access From0', type: 'pie', radius: ['50%', '61%'], avoidLabelOverlap: false, label: { show: false, position: 'center', lineHeight: 32 }, emphasis: { label: { show: true, fontSize: '20', 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: ['64%', '67%'], avoidLabelOverlap: false, label: { show: false, position: 'center' }, labelLine: { show: false }, center: ['50%', '50%'],//边框位置 data: data } ] } }