Merge pull request #12486 from dataease/pr@dev-v2@refactor_stack_bar_split_label

refactor(图表): 堆叠柱状图总计标签和主标签分开控制
This commit is contained in:
wisonic-s 2024-09-26 11:29:56 +08:00 committed by GitHub
commit cdc4607677
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 17 deletions

View File

@ -432,12 +432,9 @@ watch(
@onChangeMiscStyleForm="onChangeMiscStyleForm"
/>
</el-collapse-item>
<collapse-switch-item
<el-collapse-item
:themes="themes"
v-if="showProperties('label-selector')"
v-model="chart.customAttr.label.show"
:change-model="chart.customAttr.label"
@modelChange="val => onLabelChange({ data: val }, 'show')"
:title="t('chart.label')"
name="label"
>
@ -449,7 +446,7 @@ watch(
:all-fields="props.allFields"
@onLabelChange="onLabelChange"
/>
</collapse-switch-item>
</el-collapse-item>
<collapse-switch-item
v-if="showProperties('tooltip-selector')"
v-model="chart.customAttr.tooltip.show"

View File

@ -396,6 +396,15 @@ const conversionPrecision = [
</script>
<template>
<el-form-item class="form-item" :class="'form-item-' + themes">
<el-checkbox
size="small"
:effect="themes"
v-model="state.labelForm.show"
@change="changeLabelAttr('show')"
:label="t('chart.show')"
/>
</el-form-item>
<el-form
ref="labelForm"
:disabled="!state.labelForm.show"
@ -665,15 +674,6 @@ const conversionPrecision = [
/>
</el-form-item>
</template>
<el-form-item v-if="showProperty('showTotal')" class="form-item" :class="'form-item-' + themes">
<el-checkbox
size="small"
:effect="themes"
v-model="state.labelForm.showTotal"
@change="changeLabelAttr('showTotal')"
:label="t('chart.total_show')"
/>
</el-form-item>
<template v-if="false && showProperty('totalFormatter')">
<el-divider class="m-divider" :class="{ 'divider-dark': themes === 'dark' }" />
<div v-show="state.labelForm.showTotal">
@ -1470,6 +1470,16 @@ const conversionPrecision = [
</el-row>
</div>
</el-form>
<el-form-item v-if="showProperty('showTotal')" class="form-item" :class="'form-item-' + themes">
<el-checkbox
size="small"
:effect="themes"
:disabled="false"
v-model="state.labelForm.showTotal"
@change="changeLabelAttr('showTotal')"
:label="t('chart.total_show')"
/>
</el-form-item>
</template>
<style lang="less" scoped>

View File

@ -348,9 +348,6 @@ export class StackBar extends Bar {
}
protected configTotalLabel(chart: Chart, options: ColumnOptions): ColumnOptions {
if (!options.label) {
return options
}
const { label } = parseJson(chart.customAttr)
if (label.showTotal) {
const formatterCfg = label.labelFormatter ?? formatterItem