forked from github/dataease
Merge pull request #11289 from dataease/pr@dev-v2@fix_extreme_label
fix(图表): 相同的最值只隐藏一个标签
This commit is contained in:
commit
49e4c31c9b
@ -105,6 +105,13 @@ const noChildrenFieldChart = chart => {
|
|||||||
export const extremumEvt = (newChart, chart, _options, container) => {
|
export const extremumEvt = (newChart, chart, _options, container) => {
|
||||||
chart.container = container
|
chart.container = container
|
||||||
newChart.on('beforerender', ev => {
|
newChart.on('beforerender', ev => {
|
||||||
|
ev.view.on('beforepaint', () => {
|
||||||
|
newChart.chart.geometries[0]?.beforeMappingData.forEach(i => {
|
||||||
|
const { minItem, maxItem } = findMinMax(i)
|
||||||
|
minItem._origin.EXTREME = true
|
||||||
|
maxItem._origin.EXTREME = true
|
||||||
|
})
|
||||||
|
})
|
||||||
newChart.chart.geometries[0].on('beforerenderlabel', () => {
|
newChart.chart.geometries[0].on('beforerenderlabel', () => {
|
||||||
createExtremumPoint(chart, ev)
|
createExtremumPoint(chart, ev)
|
||||||
})
|
})
|
||||||
@ -120,6 +127,8 @@ const findMinMax = (data): { minItem; maxItem } => {
|
|||||||
if (maxItem === undefined || currentItem._origin.value > maxItem._origin.value) {
|
if (maxItem === undefined || currentItem._origin.value > maxItem._origin.value) {
|
||||||
maxItem = currentItem
|
maxItem = currentItem
|
||||||
}
|
}
|
||||||
|
delete minItem?._origin.EXTREME
|
||||||
|
delete maxItem?._origin.EXTREME
|
||||||
return { minItem, maxItem }
|
return { minItem, maxItem }
|
||||||
},
|
},
|
||||||
{ minItem: undefined, maxItem: undefined }
|
{ minItem: undefined, maxItem: undefined }
|
||||||
@ -159,9 +168,7 @@ export const createExtremumPoint = (chart, ev) => {
|
|||||||
geometriesDataArray?.forEach(pointObjList => {
|
geometriesDataArray?.forEach(pointObjList => {
|
||||||
if (pointObjList && pointObjList.length > 0) {
|
if (pointObjList && pointObjList.length > 0) {
|
||||||
const pointObj = pointObjList[0]
|
const pointObj = pointObjList[0]
|
||||||
const { minItem, maxItem } = findMinMax(pointObjList.reverse())
|
const [minItem, maxItem] = pointObjList.filter(i => i._origin.EXTREME)
|
||||||
minItem._origin.EXTREME = true
|
|
||||||
maxItem._origin.EXTREME = true
|
|
||||||
let attr
|
let attr
|
||||||
let showExtremum = false
|
let showExtremum = false
|
||||||
if (noChildrenFieldChart(chart) || yAxis.length > 1) {
|
if (noChildrenFieldChart(chart) || yAxis.length > 1) {
|
||||||
@ -195,7 +202,7 @@ export const createExtremumPoint = (chart, ev) => {
|
|||||||
const pointElement = document.getElementById(
|
const pointElement = document.getElementById(
|
||||||
'point_' + point._origin.category + '-' + point._origin.value
|
'point_' + point._origin.category + '-' + point._origin.value
|
||||||
)
|
)
|
||||||
if (pointElement) {
|
if (pointElement && point._origin.EXTREME) {
|
||||||
pointElement.style.position = 'absolute'
|
pointElement.style.position = 'absolute'
|
||||||
pointElement.style.position = 'absolute'
|
pointElement.style.position = 'absolute'
|
||||||
pointElement.style.top =
|
pointElement.style.top =
|
||||||
|
Loading…
Reference in New Issue
Block a user