Merge pull request #11926 from dataease/pr@dev-v2@chart-world-cloud-style

style(图表-词云图): 优化大小配置中的最大最小值,当清空输入框时,补全默认的最大最小值
This commit is contained in:
jianneng-fit2cloud 2024-09-02 22:01:30 +08:00 committed by GitHub
commit f2cd14b1db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -630,13 +630,19 @@ export const getMaxAndMinValueByData = (
minValue: number, minValue: number,
callback: (max: number, min: number) => void callback: (max: number, min: number) => void
) => { ) => {
if (minValue === 0 && maxValue === 0) { if ((minValue === 0 && maxValue === 0) || minValue === null || maxValue === null) {
const maxResult = data.reduce((max, current) => { let maxResult = maxValue
let minResult = minValue
if (maxResult === null) {
maxResult = data.reduce((max, current) => {
return current[field] > max ? current[field] : max return current[field] > max ? current[field] : max
}, Number.MIN_SAFE_INTEGER) }, Number.MIN_SAFE_INTEGER)
const minResult = data.reduce((min, current) => { }
if (minResult === null) {
minResult = data.reduce((min, current) => {
return current[field] < min ? current[field] : min return current[field] < min ? current[field] : min
}, Number.MAX_SAFE_INTEGER) }, Number.MAX_SAFE_INTEGER)
}
callback(maxResult, minResult) callback(maxResult, minResult)
} }
} }