From 33e93682aa7e0a129cc73808eb2001b61e48e5ec Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 28 十二月 2023 18:23:12 +0800 Subject: [PATCH] 2023-12-28 --- src/menu/components/chart/antv-pie/index.jsx | 177 ++++++++++++++++++++++------------------------------------ 1 files changed, 67 insertions(+), 110 deletions(-) diff --git a/src/menu/components/chart/antv-pie/index.jsx b/src/menu/components/chart/antv-pie/index.jsx index f5a70b1..1d531fd 100644 --- a/src/menu/components/chart/antv-pie/index.jsx +++ b/src/menu/components/chart/antv-pie/index.jsx @@ -417,7 +417,7 @@ height: getHeight(plot.height) }) - if (plot.shape !== 'nightingale' && plot.show !== 'value') { + if (plot.show !== 'value') { dv.transform({ type: 'percent', field: Y_axis, @@ -436,29 +436,13 @@ } chart.data(dv.rows) - if (plot.shape === 'nightingale') { - chart.coordinate('polar', { - innerRadius: plot.innerRadius ? (plot.innerRadius / 100) : 0, - radius: plot.radius ? (plot.radius / 100) : 0.85, - }) - } else { - chart.coordinate('theta', { - innerRadius: plot.shape !== 'pie' && plot.innerRadius ? (plot.innerRadius / 100) : 0, - radius: plot.radius ? (plot.radius / 100) : 0.85, - }) - } + chart.coordinate('theta', { + innerRadius: plot.shape !== 'pie' && plot.innerRadius ? (plot.innerRadius / 100) : 0, + radius: plot.radius ? (plot.radius / 100) : 0.85, + }) if (!plot.legend || plot.legend === 'hidden') { chart.legend(false) - } else if (plot.shape === 'nightingale') { - chart.legend(X_axis, { - position: plot.legend, - itemName: { - style: { - fill: color, - } - } - }) } else { chart.legend({ position: plot.legend, @@ -480,100 +464,73 @@ } // 楗煎浘鎴栫幆鍥� - if (plot.shape !== 'nightingale') { - let _chart = chart - .interval() - .adjust('stack') - .position(Y_axis) - .color(X_axis) - .tooltip(`${X_axis}*${Y_axis}`, (name, value) => { - if (plot.show !== 'value') { - value = (value * 100).toFixed(2) + '%' - } - return { - name: name, - value: value + let _chart = chart + .interval() + .adjust('stack') + .position(Y_axis) + .color(X_axis) + .tooltip(`${X_axis}*${Y_axis}`, (name, value) => { + if (plot.show !== 'value') { + value = (value * 100).toFixed(2) + '%' + } + return { + name: name, + value: value + } + }) + + if (plot.splitLine) { + _chart.style({ + lineWidth: plot.splitLine, + stroke: plot.splitColor, + }) + } + + if (plot.label !== 'false') { + if (plot.label === 'inner') { + _chart.label(Y_axis, { + offset: -30, + content: (data) => { + let _val = '' + if (plot.show !== 'value') { + _val = `${(data[Y_axis] * 100).toFixed(2)}%` + } else { + _val = `${data[Y_axis]}` + } + return _val + }, + style: { + textAlign: 'center', + fontSize: 16, + shadowBlur: 2, + shadowColor: 'rgba(0, 0, 0, .45)', + fill: '#fff', } }) + } else { + _chart.label(Y_axis, { + layout: { type: plot.label === 'outer' ? 'pie-spider' : 'fixed-overlap' }, + labelHeight: 20, + content: (data) => { + let _val = '' + if (plot.show !== 'value') { + _val = `${(data[Y_axis] * 100).toFixed(2)}%` + } else { + _val = `${data[Y_axis]}` + } - if (plot.splitLine) { - _chart.style({ - lineWidth: plot.splitLine, - stroke: plot.splitColor, + return `${data[X_axis]}: ${_val}` + }, + labelLine: { + style: { + lineWidth: 0.5, + }, + }, + style: { + fill: color + } }) } - - if (plot.label !== 'false') { - if (plot.label === 'inner') { - _chart.label(Y_axis, { - offset: -30, - content: (data) => { - let _val = '' - if (plot.show !== 'value') { - _val = `${(data[Y_axis] * 100).toFixed(2)}%` - } else { - _val = `${data[Y_axis]}` - } - return _val - }, - style: { - textAlign: 'center', - fontSize: 16, - shadowBlur: 2, - shadowColor: 'rgba(0, 0, 0, .45)', - fill: '#fff', - } - }) - } else { - _chart.label(Y_axis, { - layout: { type: plot.label === 'outer' ? 'pie-spider' : 'fixed-overlap' }, - labelHeight: 20, - content: (data) => { - let _val = '' - if (plot.show !== 'value') { - _val = `${(data[Y_axis] * 100).toFixed(2)}%` - } else { - _val = `${data[Y_axis]}` - } - - return `${data[X_axis]}: ${_val}` - }, - labelLine: { - style: { - lineWidth: 0.5, - }, - }, - style: { - fill: color - } - }) - } - } - } else { - chart.axis(false) - let _chart = chart - .interval() - .position(`${X_axis}*${Y_axis}`) - .color(X_axis) - - if (plot.label !== 'false') { - let _label = {} - if (plot.label === 'inner') { - _label.offset = -15 - } else { - _label.style = { - fill: color - } - } - - _chart.label(X_axis, _label) - } - if (plot.splitLine) { - _chart.style({ - lineWidth: plot.splitLine, - stroke: plot.splitColor, - }) - } } if (plot.interaction && plot.interaction.length) { -- Gitblit v1.8.0