Merge pull request #5302 from dataease/pr@dev@fix_bidirectional_bar

fix(视图-对称条形图): 修复对称条形图类别轴字段类型为时间时排序异常
This commit is contained in:
wisonic-s 2023-05-24 18:15:39 +08:00 committed by GitHub
commit cfbd7722ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 8 deletions

View File

@ -9,7 +9,8 @@ import {
getPadding,
getSlider,
getAnalyse,
setGradientColor
setGradientColor,
getMeta
} from '@/views/chart/chart/common/common_antv'
import { antVCustomColor, handleEmptyDataStrategy } from '@/views/chart/chart/util'
import _ from 'lodash'
@ -319,6 +320,11 @@ export function baseBidirectionalBarOptionAntV(plot, container, chart, action, i
handleEmptyDataStrategy(emptyDataStrategy, chart, data, options)
}
// meta处理类别轴数据类型为时间时排序失效
const meta = getMeta(chart)
if (meta) {
options.meta = meta
}
// 开始渲染
if (plot) {
plot.destroy()

View File

@ -966,3 +966,20 @@ export function setGradientColor(rawColor, show = false, angle = 0) {
item.splice(3, 1, '0.3)')
return show ? `l(${angle}) 0:${item.join(',')} 1:${rawColor}` : rawColor
}
export function getMeta(chart) {
let meta
if (chart.type === 'bidirectional-bar') {
const xAxis = JSON.parse(chart.xaxis)
if (xAxis?.length === 1 && xAxis[0].deType === 1) {
const values = chart.data.data.map(item => item.field)
meta = {
field: {
type: 'cat',
values: values.reverse()
}
}
}
}
return meta
}

View File

@ -1582,7 +1582,6 @@ export const TYPE_CONFIGS = [
'x-axis-selector-ant-v': [
'show',
'position',
'name',
'nameTextStyle',
'splitLine',
'axisForm',

View File

@ -983,12 +983,7 @@
</div>
</el-row>
<el-row
v-if="view.type
&& !(view.type.includes('table') && view.render === 'echarts')
&& !view.type.includes('text') && !view.type.includes('gauge')
&& view.type !== 'liquid' && view.type !== 'word-cloud'
&& view.type !== 'table-pivot' && view.type !=='label'
&& view.type !=='richTextView' && view.type !== 'flow-map'"
v-if="showDrill"
class="padding-lr"
style="margin-top: 6px;"
>
@ -1990,6 +1985,13 @@ export default {
equalsAny(this.view.type, 'text', 'label') ||
(this.view.render === 'antv' && this.view.type.includes('table'))
},
showDrill() {
return this.view.type &&
!(this.view.type.includes('table') && this.view.render === 'echarts') &&
!includesAny(this.view.type, 'text', 'gauge') &&
!equalsAny(this.view.type, 'liquid', 'bidirectional-bar',
'word-cloud', 'table-pivot', 'label', 'richTextView', 'flow-map')
},
...mapState([
'curComponent',
'panelViewEditInfo',