diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index 84bd044f92..9edbd7716b 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -849,7 +849,12 @@ export default { custom_case: 'Custom', last_layer: 'This Is The Last Layer', radar_size: 'Size', - chart_mix: 'Mix' + chart_mix: 'Mix', + axis_value: 'Axis Value', + axis_value_min: 'Min', + axis_value_max: 'Max', + axis_value_split: 'Split', + axis_auto: 'Auto' }, dataset: { sheet_warn: 'There are multiple sheet pages, and the first one is extracted by default', diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index 53387d65b8..064e9415dd 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -848,7 +848,12 @@ export default { custom_case: '自定義', last_layer: '當前已經是最後一級', radar_size: '大小', - chart_mix: '組合圖' + chart_mix: '組合圖', + axis_value: '軸值', + axis_value_min: '最小值', + axis_value_max: '最大值', + axis_value_split: '間隔', + axis_auto: '自動' }, dataset: { sheet_warn: '有多個sheet頁面,默認抽取第一個', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index 804bf19ee3..b0be043f8a 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -848,7 +848,12 @@ export default { custom_case: '自定义', last_layer: '当前已经是最后一级', radar_size: '大小', - chart_mix: '组合图' + chart_mix: '组合图', + axis_value: '轴值', + axis_value_min: '最小值', + axis_value_max: '最大值', + axis_value_split: '间隔', + axis_auto: '自动' }, dataset: { sheet_warn: '有多个 Sheet 页,默认抽取第一个', diff --git a/frontend/src/views/chart/chart/chart.js b/frontend/src/views/chart/chart/chart.js index 1dfd989b5d..f7b06e566c 100644 --- a/frontend/src/views/chart/chart/chart.js +++ b/frontend/src/views/chart/chart/chart.js @@ -107,6 +107,12 @@ export const DEFAULT_XAXIS_STYLE = { width: 1, style: 'solid' } + }, + axisValue: { + auto: true, + min: null, + max: null, + split: null } } export const DEFAULT_YAXIS_STYLE = { @@ -131,6 +137,12 @@ export const DEFAULT_YAXIS_STYLE = { width: 1, style: 'solid' } + }, + axisValue: { + auto: true, + min: null, + max: null, + split: null } } export const DEFAULT_BACKGROUND_COLOR = { diff --git a/frontend/src/views/chart/chart/common/common.js b/frontend/src/views/chart/chart/common/common.js index 44a942b3a9..806310913d 100644 --- a/frontend/src/views/chart/chart/common/common.js +++ b/frontend/src/views/chart/chart/common/common.js @@ -65,6 +65,18 @@ export function componentStyle(chart_option, chart) { if (!customStyle.xAxis.show) { chart_option.xAxis.axisLabel.show = false } + + // 轴值设置 + delete chart_option.xAxis.min + delete chart_option.xAxis.max + delete chart_option.xAxis.split + if (chart.type.includes('horizontal')) { + if (customStyle.xAxis.axisValue && !customStyle.xAxis.axisValue.auto) { + customStyle.xAxis.axisValue.min && (chart_option.xAxis.min = parseFloat(customStyle.xAxis.axisValue.min)) + customStyle.xAxis.axisValue.max && (chart_option.xAxis.max = parseFloat(customStyle.xAxis.axisValue.max)) + customStyle.xAxis.axisValue.split && (chart_option.xAxis.interval = parseFloat(customStyle.xAxis.axisValue.split)) + } + } } if (customStyle.yAxis && (chart.type.includes('bar') || chart.type.includes('line') || chart.type.includes('scatter') || chart.type === 'chart-mix')) { chart_option.yAxis.show = customStyle.yAxis.show @@ -80,6 +92,18 @@ export function componentStyle(chart_option, chart) { if (!customStyle.yAxis.show) { chart_option.yAxis.axisLabel.show = false } + + // 轴值设置 + delete chart_option.yAxis.min + delete chart_option.yAxis.max + delete chart_option.yAxis.split + if (!chart.type.includes('horizontal')) { + if (customStyle.yAxis.axisValue && !customStyle.yAxis.axisValue.auto) { + customStyle.yAxis.axisValue.min && (chart_option.yAxis.min = parseFloat(customStyle.yAxis.axisValue.min)) + customStyle.yAxis.axisValue.max && (chart_option.yAxis.max = parseFloat(customStyle.yAxis.axisValue.max)) + customStyle.yAxis.axisValue.split && (chart_option.yAxis.interval = parseFloat(customStyle.yAxis.axisValue.split)) + } + } } if (customStyle.split && chart.type.includes('radar')) { chart_option.radar.name = customStyle.split.name diff --git a/frontend/src/views/chart/components/ChartComponent.vue b/frontend/src/views/chart/components/ChartComponent.vue index 507d02f5c8..5cf336e0fe 100644 --- a/frontend/src/views/chart/components/ChartComponent.vue +++ b/frontend/src/views/chart/components/ChartComponent.vue @@ -155,7 +155,7 @@ export default { } else if (chart.type === 'chart-mix') { chart_option = baseMixOption(JSON.parse(JSON.stringify(BASE_MIX)), chart) } - console.log(JSON.stringify(chart_option)) + // console.log(JSON.stringify(chart_option)) if (chart.type === 'map') { const customAttr = JSON.parse(chart.customAttr) diff --git a/frontend/src/views/chart/components/component-style/XAxisSelector.vue b/frontend/src/views/chart/components/component-style/XAxisSelector.vue index c42e732e4c..9a962076ad 100644 --- a/frontend/src/views/chart/components/component-style/XAxisSelector.vue +++ b/frontend/src/views/chart/components/component-style/XAxisSelector.vue @@ -23,6 +23,36 @@ + + + + + + {{ $t('chart.axis_value') }} + + + 最小值、最大值、间隔均为数值类型;若不填,则该项视为自动。 + + 请确保填写数值能正确计算,否则将无法正常显示轴值。 + + + + + + {{ $t('chart.axis_auto') }} + + + + + + + + + + + + + {{ $t('chart.axis_show') }} @@ -120,6 +150,9 @@ export default { if (!this.axisForm.nameTextStyle) { this.axisForm.nameTextStyle = JSON.parse(JSON.stringify(DEFAULT_XAXIS_STYLE.nameTextStyle)) } + if (!this.axisForm.axisValue) { + this.axisForm.axisValue = JSON.parse(JSON.stringify(DEFAULT_XAXIS_STYLE.axisValue)) + } } } }, diff --git a/frontend/src/views/chart/components/component-style/YAxisSelector.vue b/frontend/src/views/chart/components/component-style/YAxisSelector.vue index ca6ef455d4..87cac4d88a 100644 --- a/frontend/src/views/chart/components/component-style/YAxisSelector.vue +++ b/frontend/src/views/chart/components/component-style/YAxisSelector.vue @@ -23,6 +23,36 @@ + + + + + + {{ $t('chart.axis_value') }} + + + 最小值、最大值、间隔均为数值类型;若不填,则该项视为自动。 + + 请确保填写数值能正确计算,否则将无法正常显示轴值。 + + + + + + {{ $t('chart.axis_auto') }} + + + + + + + + + + + + + {{ $t('chart.axis_show') }} @@ -120,6 +150,9 @@ export default { if (!this.axisForm.nameTextStyle) { this.axisForm.nameTextStyle = JSON.parse(JSON.stringify(DEFAULT_YAXIS_STYLE.nameTextStyle)) } + if (!this.axisForm.axisValue) { + this.axisForm.axisValue = JSON.parse(JSON.stringify(DEFAULT_YAXIS_STYLE.axisValue)) + } } } },