From 0e5c395b974b187b4227ed86dac746131425052a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 19 十一月 2023 12:21:18 +0800 Subject: [PATCH] 2023-11-19 --- src/tabviews/custom/components/chart/antv-bar-line/index.jsx | 154 ++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 127 insertions(+), 27 deletions(-) diff --git a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx index cfe93bc..16d88bb 100644 --- a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx +++ b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx @@ -134,6 +134,32 @@ if (_config.plot.mutilBar !== 'overlap' && Bar_axis.length > 1) { _config.plot.Bar_axis = Bar_axis } + + if (_config.plot.Bar_axis && _config.plot.Bar_axis.length) { + let label = _config.plot.label + + if (label === 'false') { + _config.plot.customs.forEach(item => { + if (!Bar_axis.includes(item.type)) return + if (item.label === 'true') { + label = 'true' + } + }) + } else { + let reset = true + _config.plot.customs.forEach(item => { + if (!Bar_axis.includes(item.type)) return + if (item.label === 'true') { + reset = false + } + }) + if (reset) { + label = 'false' + } + } + + _config.plot.$label = label + } } else { _config.plot.enabled = 'false' } @@ -1051,9 +1077,17 @@ .position(`${plot.Xaxis}*${_valfield}`) .shape(plot.shape || 'smooth') .tooltip(`${plot.Xaxis}*${_valfield}*${_typefield}`, (name, value, type) => { + let val = value + if (plot.show === 'percent') { + val = value + '%' + } else if (plot.show === 'thdSeparator') { + val = val + '' + val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') + } + return { name: type, - value: plot.show === 'percent' ? value + '%' : value + value: val } }) @@ -1078,11 +1112,15 @@ if (plot.labelValue === 'zero' && value === 0) { return null } + let val = value if (plot.show === 'percent') { - value = value + '%' + val = value + '%' + } else if (plot.show === 'thdSeparator') { + val = val + '' + val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') } return { - content: value, + content: val, style: { fill: plot.color } @@ -1292,12 +1330,16 @@ ]) .shape(plot.shape || 'rect') .tooltip(`${plot.Xaxis}*value*key`, (name, value, key) => { + let val = value if (plot.show === 'percent') { - value = value + '%' + val = value + '%' + } else if (plot.show === 'thdSeparator') { + val = val + '' + val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') } return { name: key, - value: value + value: val } }) @@ -1314,21 +1356,25 @@ } else { _chart.color('key') } - if (plot.label !== 'false') { + if (plot.$label !== 'false') { _chart.label('value*key', (value, key) => { if (plot.labelValue === 'zero' && value === 0) { return null } + let val = value if (plot.show === 'percent') { - value = value + '%' + val = value + '%' + } else if (plot.show === 'thdSeparator') { + val = val + '' + val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') } - if (plot.label === 'true' && plot.labelColor === 'custom' && plot.$colors && plot.$colors.has(key)) { + if (plot.$label === 'true' && plot.labelColor === 'custom' && plot.$colors && plot.$colors.has(key)) { lablecfg.style.fill = plot.$colors.get(key) } return { - content: value, + content: val, ...lablecfg } }) @@ -1347,12 +1393,16 @@ .adjust('stack') .shape(plot.shape || 'rect') .tooltip(`${plot.Xaxis}*value*key`, (name, value, type) => { + let val = value if (plot.show === 'percent') { - value = value + '%' + val = value + '%' + } else if (plot.show === 'thdSeparator') { + val = val + '' + val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') } return { name: type, - value: value + value: val } }) @@ -1369,20 +1419,24 @@ } else { _chart.color('key') } - if (plot.label !== 'false') { + if (plot.$label !== 'false') { _chart.label('value*key', (value, key) => { if (plot.labelValue === 'zero' && value === 0) { return null } + let val = value if (plot.show === 'percent') { - value = value + '%' + val = value + '%' + } else if (plot.show === 'thdSeparator') { + val = val + '' + val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') } - if (plot.label === 'true' && plot.labelColor === 'custom' && plot.$colors && plot.$colors.has(key)) { + if (plot.$label === 'true' && plot.labelColor === 'custom' && plot.$colors && plot.$colors.has(key)) { lablecfg.style.fill = plot.$colors.get(key) } return { - content: value, + content: val, ...lablecfg } }) @@ -1438,9 +1492,16 @@ .color(item.color) .shape(item.shape) .tooltip(`${item.name}`, (value) => { + let val = value + if (item.show === 'percent') { + val = value + '%' + } else if (item.show === 'thdSeparator') { + val = val + '' + val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') + } return { name: item.name, - value: item.show === 'percent' ? value + '%' : value + value: val } }) @@ -1453,14 +1514,18 @@ return null } + let val = value if (item.show === 'percent') { - value = value + '%' + val = value + '%' + } else if (item.show === 'thdSeparator') { + val = val + '' + val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') } if (plot.label === 'true' && plot.labelColor === 'custom' && item.color) { lablecfg.style.fill = item.color } return { - content: value, + content: val, ...lablecfg } }) @@ -1493,9 +1558,17 @@ .color(item.color) .shape(item.shape) .tooltip(`${item.name}`, (value) => { + let val = value + if (item.show === 'percent') { + val = value + '%' + } else if (item.show === 'thdSeparator') { + val = val + '' + val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') + } + return { name: item.name, - value: item.show === 'percent' ? value + '%' : value + value: val } }) @@ -1505,11 +1578,16 @@ return null } + let val = value if (item.show === 'percent') { - value = value + '%' + val = value + '%' + } else if (item.show === 'thdSeparator') { + val = val + '' + val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') } + return { - content: value, + content: val, style: { fill: plot.color } @@ -1700,9 +1778,16 @@ ]) .shape(plot.shape || 'rect') .tooltip(`${plot.Xaxis}*${_valfield}*${_typefield}`, (name, value, type) => { + let val = value + if (plot.show === 'percent') { + val = value + '%' + } else if (plot.show === 'thdSeparator') { + val = val + '' + val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') + } return { name: type, - value: plot.show === 'percent' ? value + '%' : value + value: val } }) @@ -1739,8 +1824,12 @@ return null } + let val = value if (plot.show === 'percent') { - value = value + '%' + val = value + '%' + } else if (plot.show === 'thdSeparator') { + val = val + '' + val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') } if (plot.label === 'true' && plot.labelColor === 'custom' && plot.$colors && plot.$colors.has(key)) { @@ -1748,7 +1837,7 @@ } return { - content: value, + content: val, ...lablecfg } }) @@ -1776,9 +1865,16 @@ .adjust('stack') .shape(plot.shape || 'rect') .tooltip(`${plot.Xaxis}*${_valfield}*${_typefield}`, (name, value, type) => { + let val = value + if (plot.show === 'percent') { + val = value + '%' + } else if (plot.show === 'thdSeparator') { + val = val + '' + val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') + } return { name: type, - value: plot.show === 'percent' ? value + '%' : value + value: val } }) @@ -1814,8 +1910,12 @@ return null } + let val = value if (plot.show === 'percent') { - value = value + '%' + val = value + '%' + } else if (plot.show === 'thdSeparator') { + val = val + '' + val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') } if (plot.label === 'true' && plot.labelColor === 'custom' && plot.$colors && plot.$colors.has(key)) { @@ -1823,7 +1923,7 @@ } return { - content: value, + content: val, ...lablecfg } }) -- Gitblit v1.8.0