Merge pull request #9150 from ulleo/dev-v2

fix(图表): 修复双轴图设置右轴辅助线不生效问题
This commit is contained in:
ulleo 2024-04-17 10:35:06 +08:00 committed by GitHub
commit a4817900ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 19 additions and 22 deletions

View File

@ -108,7 +108,7 @@ declare interface AssistLine {
*/
summary: string
axisType: 'left' | 'right'
yAxisType: 'left' | 'right'
}
/**

View File

@ -54,11 +54,6 @@ const state = reactive({
quotaFields: []
})
const axisType = [
{ type: 'left', name: t('chart.drag_block_value_axis_left') },
{ type: 'right', name: t('chart.drag_block_value_axis_right') }
]
watch(
() => props.chart.senior.assistLineCfg,
() => {

View File

@ -26,7 +26,7 @@ const props = defineProps({
}
})
const axisTypes = [
const yAxisTypes = [
{ type: 'left', name: t('chart.drag_block_value_axis_left') },
{ type: 'right', name: t('chart.drag_block_value_axis_right') }
]
@ -39,7 +39,7 @@ const state = reactive({
fieldId: '',
summary: 'avg',
axis: 'y', //
axisType: 'left',
yAxisType: 'left',
value: '0',
lineType: 'solid',
color: '#ff0000',
@ -98,8 +98,8 @@ const removeLine = index => {
changeAssistLine()
}
const changeAxisType = item => {
if (props.useQuotaExt && item.axisType === 'right') {
const changeYAxisType = item => {
if (props.useQuotaExt && item.yAxisType === 'right') {
item.fieldId = props.quotaExtFields ? props.quotaExtFields[0]?.id : null
item.curField = getQuotaExtField(item.fieldId)
} else {
@ -113,7 +113,7 @@ const changeAssistLine = () => {
emit('onAssistLineChange', state.lineArr)
}
const changeAssistLineField = item => {
if (props.useQuotaExt && item.axisType === 'right') {
if (props.useQuotaExt && item.yAxisType === 'right') {
item.curField = getQuotaExtField(item.fieldId)
} else {
item.curField = getQuotaField(item.fieldId)
@ -169,9 +169,9 @@ onMounted(() => {
/>
</el-col>
<el-col v-if="useQuotaExt" :span="3">
<el-select v-model="item.axisType" class="select-item" @change="changeAxisType(item)">
<el-select v-model="item.yAxisType" class="select-item" @change="changeYAxisType(item)">
<el-option
v-for="opt in axisTypes"
v-for="opt in yAxisTypes"
:key="opt.type"
:label="opt.name"
:value="opt.type"
@ -206,7 +206,7 @@ onMounted(() => {
@change="changeAssistLineField(item)"
>
<el-option
v-for="quota in useQuotaExt && item.axisType === 'right'
v-for="quota in useQuotaExt && item.yAxisType === 'right'
? quotaExtFields
: quotaFields"
:key="quota.id"

View File

@ -365,8 +365,8 @@ export class ColumnLineMix extends G2PlotChartView<DualAxesOptions, DualAxes> {
protected configAnalyse(chart: Chart, options: DualAxesOptions): DualAxesOptions {
const list = getAnalyse(chart)
const annotations = {
value: filter(list, l => l.axisType === 'left'),
valueExt: filter(list, l => l.axisType === 'right')
value: filter(list, l => l.yAxisType === 'left'),
valueExt: filter(list, l => l.yAxisType === 'right')
}
return { ...options, annotations }
}

View File

@ -681,10 +681,10 @@ export function getAnalyse(chart: Chart) {
const content =
ele.name +
' : ' +
valueFormatter(value, ele.axisType === 'left' ? axisFormatterCfg : axisExtFormatterCfg)
valueFormatter(value, ele.yAxisType === 'left' ? axisFormatterCfg : axisExtFormatterCfg)
assistLine.push({
type: 'line',
axisType: ele.axisType,
yAxisType: ele.yAxisType,
start: ['start', value],
end: ['end', value],
style: {
@ -694,15 +694,17 @@ export function getAnalyse(chart: Chart) {
})
assistLine.push({
type: 'text',
axisType: ele.axisType,
yAxisType: ele.yAxisType,
position: [
(ele.axisType === 'left' ? yAxisPosition : yAxisExtPosition) === 'left' ? 'start' : 'end',
(ele.yAxisType === 'left' ? yAxisPosition : yAxisExtPosition) === 'left'
? 'start'
: 'end',
value
],
content: content,
offsetY: -2,
offsetX:
(ele.axisType === 'left' ? yAxisPosition : yAxisExtPosition) === 'left'
(ele.yAxisType === 'left' ? yAxisPosition : yAxisExtPosition) === 'left'
? 2
: -10 * (content.length - 2),
style: {

View File

@ -15,7 +15,7 @@ public class ChartSeniorAssistDTO {
private Long fieldId;
private String summary;
private String axis;
private String axisType;
private String yAxisType;
private String value;
private String lineType;
private String color;