forked from github/dataease
style(图表-象限图): 优化象限图的tooltip样式
This commit is contained in:
parent
a721be0dd2
commit
8f881e7d57
@ -123,7 +123,7 @@ export class Quadrant extends G2PlotChartView<ScatterOptions, G2Scatter> {
|
||||
return
|
||||
}
|
||||
const { colorFieldObj, sizeFieldObj, xFieldObj, yFieldObj } = this.getFieldObject(chart)
|
||||
if (!xFieldObj.id || !yFieldObj.id) {
|
||||
if (!xFieldObj.id || !yFieldObj.id || yFieldObj.id === xFieldObj.id) {
|
||||
return
|
||||
}
|
||||
const data: any[] = []
|
||||
@ -316,14 +316,10 @@ export class Quadrant extends G2PlotChartView<ScatterOptions, G2Scatter> {
|
||||
tooltip: false
|
||||
}
|
||||
}
|
||||
xAxisTitle['show'] = true
|
||||
yAxisTitle['show'] = true
|
||||
yAxisExtTitle['show'] = true
|
||||
tooltipAttr.seriesTooltipFormatter?.push(xAxisTitle)
|
||||
const formatterMap = tooltipAttr.seriesTooltipFormatter
|
||||
?.filter(i => i.show)
|
||||
.reduce((pre, next) => {
|
||||
pre[next['originName']] = next
|
||||
pre[next['seriesId']] = next
|
||||
return pre
|
||||
}, {}) as Record<string, SeriesFormatter>
|
||||
const tooltip: ScatterOptions['tooltip'] = {
|
||||
@ -339,7 +335,9 @@ export class Quadrant extends G2PlotChartView<ScatterOptions, G2Scatter> {
|
||||
originalItems
|
||||
?.filter(i => i.name !== xAxisTitle['originName'])
|
||||
.forEach(item => {
|
||||
const formatter = formatterMap[item.name]
|
||||
Object.keys(formatterMap).forEach(key => {
|
||||
if (formatterMap[key]['originName'] === item.name) {
|
||||
const formatter = formatterMap[key]
|
||||
if (formatter) {
|
||||
const value =
|
||||
formatter.groupType === 'q'
|
||||
@ -350,6 +348,8 @@ export class Quadrant extends G2PlotChartView<ScatterOptions, G2Scatter> {
|
||||
: formatter.chartShowName
|
||||
result.push({ color: item.color, name, value })
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user