const colorList1 = [ '#0A75D9', '', '#C8882B', '', '#6AA3D9', '', '#0E8E7F', '' ] const colorList = [ '#00B3FF', '', '#FFC633', '', '#A5D4FF', '', '#13FFF1', '' ] let total = 0 let dataList = [] const moduleContent = { 空置: 32, 已租: 16, 已定: 20, 已售: 32 } let sum = 0 const chartdata = [] for (const i in moduleContent) { chartdata.push({ name: i, value: moduleContent[i] || 1 }) sum += Number(moduleContent[i] || 0) } total = sum dataList = chartdata const data1 = [] chartdata.forEach((item) => { const _item = { ...item } if (!_item.value) { _item.value = sum / 100 } data1.push(_item, { name: '', value: sum / 100, labelLine: { show: false, lineStyle: { color: 'transparent' } }, itemStyle: { color: 'transparent' } }) }) option = { backgroundColor: 'rgba(0,0,0, .6)', series: [ { type: 'pie', radius: ['55%', '75%'], center: ['50%', '50%'], hoverAnimation: false, startAngle: 180, minAngle: 5, emphasis: { scale: true, scaleSize: 15, focus: 'series', blurScope: 'coordinateSystem' }, label: { show: false }, itemStyle: { normal: { color: function (params) { return colorList1[params.dataIndex] } } }, data: data1, z: 666 }, { type: 'pie', radius: ['75%', '80%'], center: ['50%', '50%'], hoverAnimation: false, startAngle: 180, minAngle: 5, emphasis: { scale: true, scaleSize: 15, focus: 'series', blurScope: 'coordinateSystem' }, label: { show: false }, itemStyle: { normal: { color: function (params) { return colorList[params.dataIndex] } } }, data: data1, z: 1 } ] }