fix(视图-雷达图): 雷达图最小值取实际最小值

This commit is contained in:
wisonic-s 2023-11-24 16:34:19 +08:00
parent 88b47ca368
commit 8e4d32b8c9
7 changed files with 13 additions and 9 deletions

View File

@ -1482,7 +1482,7 @@ export default {
dimension_letter_space: 'Name Letter Space',
font_family: 'Font Family',
font_family_tip: 'The font will only take effect if it is installed on the operating system',
radar_max_tip: 'If the maximum value of the actual data is greater than the custom maximum value, the maximum value of the actual data will prevail.',
radar_min_max_tip: 'If the minimum value of the actual data is less than the custom minimum value, or the maximum value is greater than the custom maximum value, the actual data will prevail.',
letter_space: 'Letter Space',
font_shadow: 'Font Shadow',
chart_area: 'Area',

View File

@ -1479,7 +1479,7 @@ export default {
dimension_letter_space: '名稱字間距',
font_family: '字體',
font_family_tip: '只有操作系統上已安裝該字體才能生效',
radar_max_tip: '如果實際數據的最大值大於自定義的最大值,將以實際數據的最大值為準。',
radar_min_max_tip: '如果實際數據的最小值小於自定義的最小值,或者最大值大於自定義的最大值,將以實際數據為準。',
letter_space: '字間距',
font_shadow: '字體陰影',
chart_area: '面積圖',

View File

@ -1479,7 +1479,7 @@ export default {
dimension_letter_space: '名称字间距',
font_family: '字体',
font_family_tip: '只有操作系统上已安装该字体才能生效',
radar_max_tip: '如果实际数据的最大值大于自定义的最大值,将以实际数据的最大值为准。',
radar_min_max_tip: '如果实际数据的最小值小于自定义的最小值,或者最大值大于自定义的最大值,将以实际数据为准。',
letter_space: '字间距',
font_shadow: '字体阴影',
chart_area: '面积图',

View File

@ -31,6 +31,7 @@ export function baseRadarOption(chart_option, chart) {
if (chart.data) {
chart_option.title.text = chart.title
const maxValues = []
const minValues = []
for (let i = 0; i < chart.data.series.length; i++) {
const y = chart.data.series[i]
if (y.data.length === 0) {
@ -63,12 +64,13 @@ export function baseRadarOption(chart_option, chart) {
chart_option.series.push(d)
maxValues.push(Math.max.apply(null, y.value))
minValues.push(Math.min.apply(null, y.value))
}
let max = Math.max.apply(null, maxValues)
let min
let min = Math.min.apply(null, minValues)
const customStyle = JSON.parse(chart.customStyle)
if (customStyle?.split?.axisValue?.auto === false) {
min = customStyle.split.axisValue.min
min = Math.min(customStyle.split.axisValue.min, min)
max = Math.max(customStyle.split.axisValue.max, max)
}
chart.data.x.forEach(function(ele) {

View File

@ -1,6 +1,7 @@
import { getLabel, getLegend, getPadding, getTheme, getTooltip } from '@/views/chart/chart/common/common_antv'
import { Radar } from '@antv/g2plot'
import { antVCustomColor } from '@/views/chart/chart/util'
import { minBy, maxBy } from 'lodash'
export function baseRadarOptionAntV(plot, container, chart, action) {
// theme
@ -124,8 +125,9 @@ export function baseRadarOptionAntV(plot, container, chart, action) {
}
}
if (s.axisValue?.auto === false) {
yAxis.min = yAxis.minLimit = s.axisValue.min
const dataMax = _.maxBy(data, 'value')
const dataMin = minBy(data, 'value')
yAxis.min = yAxis.minLimit = Math.min(s.axisValue.min, dataMin.value)
const dataMax = maxBy(data, 'value')
yAxis.max = yAxis.maxLimit = Math.max(s.axisValue.max, dataMax.value)
}
}

View File

@ -161,7 +161,7 @@
>
<div
slot="content"
v-html="$t('chart.radar_max_tip')"
v-html="$t('chart.radar_min_max_tip')"
/>
<i
class="el-icon-info"

View File

@ -80,7 +80,7 @@
>
<div
slot="content"
v-html="$t('chart.radar_max_tip')"
v-html="$t('chart.radar_min_max_tip')"
/>
<i
class="el-icon-info"