Merge branch 'dev' of github.com:dataease/dataease into dev

This commit is contained in:
taojinlong 2022-06-25 22:42:41 +08:00
commit aa690ff8cc
3 changed files with 26 additions and 6 deletions

View File

@ -100,7 +100,7 @@
<el-dropdown-item icon="el-icon-files" :command="beforeClickItem('filter')"> <el-dropdown-item icon="el-icon-files" :command="beforeClickItem('filter')">
<span>{{ $t('chart.filter') }}...</span> <span>{{ $t('chart.filter') }}...</span>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item v-if="chart.render === 'antv' && chart.type.includes('table')" icon="el-icon-notebook-2" divided :command="beforeClickItem('formatter')"> <el-dropdown-item v-if="chart.render === 'antv' && (chart.type.includes('table') || chart.type === 'text')" icon="el-icon-notebook-2" divided :command="beforeClickItem('formatter')">
<span>{{ $t('chart.value_formatter') }}...</span> <span>{{ $t('chart.value_formatter') }}...</span>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item icon="el-icon-edit-outline" divided :command="beforeClickItem('rename')"> <el-dropdown-item icon="el-icon-edit-outline" divided :command="beforeClickItem('rename')">
@ -177,7 +177,6 @@ export default {
this.init() this.init()
this.isEnableCompare() this.isEnableCompare()
bus.$on('reset-change-table', () => this.getItemTagType()) bus.$on('reset-change-table', () => this.getItemTagType())
}, },
methods: { methods: {
init() { init() {

View File

@ -100,7 +100,7 @@
<el-dropdown-item icon="el-icon-files" :command="beforeClickItem('filter')"> <el-dropdown-item icon="el-icon-files" :command="beforeClickItem('filter')">
<span>{{ $t('chart.filter') }}...</span> <span>{{ $t('chart.filter') }}...</span>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item v-if="chart.render === 'antv' && chart.type.includes('table')" icon="el-icon-notebook-2" divided :command="beforeClickItem('formatter')"> <el-dropdown-item v-if="chart.render === 'antv' && (chart.type.includes('table') || chart.type === 'text')" icon="el-icon-notebook-2" divided :command="beforeClickItem('formatter')">
<span>{{ $t('chart.value_formatter') }}...</span> <span>{{ $t('chart.value_formatter') }}...</span>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item icon="el-icon-edit-outline" divided :command="beforeClickItem('rename')"> <el-dropdown-item icon="el-icon-edit-outline" divided :command="beforeClickItem('rename')">

View File

@ -7,8 +7,8 @@
:style="content_class" :style="content_class"
> >
<span :style="label_class"> <span :style="label_class">
<p v-for="item in chart.data.series" :key="item.name" :style="label_content_class"> <p :style="label_content_class">
{{ item.data[0] }} {{ result }}
</p> </p>
</span> </span>
<span v-if="dimensionShow" :style="label_space"> <span v-if="dimensionShow" :style="label_space">
@ -23,6 +23,7 @@
<script> <script>
import { hexColorToRGBA } from '../../chart/util' import { hexColorToRGBA } from '../../chart/util'
import eventBus from '@/components/canvas/utils/eventBus' import eventBus from '@/components/canvas/utils/eventBus'
import { formatterItem, valueFormatter } from '@/views/chart/chart/formatter'
export default { export default {
name: 'LabelNormal', name: 'LabelNormal',
@ -76,7 +77,8 @@ export default {
background: hexColorToRGBA('#ffffff', 0) background: hexColorToRGBA('#ffffff', 0)
}, },
title_show: true, title_show: true,
borderRadius: '0px' borderRadius: '0px',
result: ''
} }
}, },
computed: { computed: {
@ -105,6 +107,7 @@ export default {
init() { init() {
const that = this const that = this
this.initStyle() this.initStyle()
this.resultFormat()
window.onresize = function() { window.onresize = function() {
that.calcHeight() that.calcHeight()
} }
@ -220,6 +223,24 @@ export default {
this.label_content_class.color = valueColor this.label_content_class.color = valueColor
} }
} }
},
resultFormat() {
const value = this.chart.data.series[0].data[0]
let yAxis = []
try {
yAxis = JSON.parse(this.chart.yaxis)
} catch (err) {
yAxis = JSON.parse(JSON.stringify(this.chart.yaxis))
}
const f = yAxis[0]
if (f && f.formatterCfg) {
const v = valueFormatter(value, f.formatterCfg)
this.result = v.includes('NaN') ? value : v
} else {
const v = valueFormatter(value, formatterItem)
this.result = v.includes('NaN') ? value : v
}
} }
} }
} }