function setOption(chart, xdata, ydata) { const option = { title: { text: '出勤状况', textStyle: { fontWeight: '500', fontSize: 15, color: '#fff' //title颜色 }, x: 'center', y: '0' }, legend: { data: ydata, top: 50, x: "center", textStyle: { color: '#fff' // 图例文字颜色 } }, tooltip: { show: true, formatter: '名称:{b}\n人数:{c}\n占比:{d} %', //b=名称 c=数值 d=百分比 \n换行 }, toolbox: { show: true, feature: { mark: { show: true }, dataView: { show: true, readOnly: false }, restore: { show: true }, saveAsImage: { show: true } } }, color: ['#56cbff', '#00fcc9',"#ff0000","#fba035"], calculable: true, series: [{ name: '出勤情况', type: 'pie', center: ['50%', '50%'], radius: 80, itemStyle: { normal: { label: { show: true, position: 'inner', formatter: function(params) { return (params.percent - 0).toFixed(0) + '%' } }, labelLine: { show: false } }, emphasis: { label: { show: true, formatter: "{b}\n{d}%" } } }, data: [{ name: ydata[0], value: xdata[0], }, { name: ydata[1], value: xdata[1], }, { name: ydata[2], value: xdata[2], }, { name: ydata[3], value: xdata[3], }, ] }] }; chart.setOption(option)}
function setOption(chart, xdata, ydata) {
const option = {
};
chart.setOption(option)
}