mirror of
https://github.com/dataease/dataease.git
synced 2026-06-16 20:42:07 +08:00
fix(图表): 优化柱条图提示的显示隐藏问题
This commit is contained in:
@@ -83,6 +83,7 @@ export class Bar extends G2ChartView<ViewSpec, G2Column> {
|
||||
background: true
|
||||
}
|
||||
},
|
||||
tooltip: false,
|
||||
transform: [{ type: 'dodgeX' } as Transform]
|
||||
} as ViewSpec
|
||||
|
||||
@@ -188,11 +189,11 @@ export class Bar extends G2ChartView<ViewSpec, G2Column> {
|
||||
}
|
||||
|
||||
protected configTooltip(chart: Chart, options: ViewSpec): ViewSpec {
|
||||
const { children } = options
|
||||
const customAttr: DeepPartial<ChartAttr> = parseJson(chart.customAttr)
|
||||
const tooltipAttr = customAttr.tooltip
|
||||
const yAxis = chart.yAxis
|
||||
if (!tooltipAttr.show) {
|
||||
options.children[0].tooltip = false
|
||||
return options
|
||||
}
|
||||
const formatterMap = tooltipAttr.seriesTooltipFormatter
|
||||
@@ -258,13 +259,7 @@ export class Bar extends G2ChartView<ViewSpec, G2Column> {
|
||||
}
|
||||
return {
|
||||
...options,
|
||||
children: [
|
||||
{
|
||||
...options.children[0],
|
||||
...tooltipOptions
|
||||
},
|
||||
...options.children.slice(1)
|
||||
]
|
||||
children: [{ ...children[0], ...tooltipOptions }, ...children.slice(1)]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ export class BulletGraph extends G2ChartView<RuntimeOptions, G2Bullet> {
|
||||
}
|
||||
|
||||
protected configMisc(chart: Chart, options: RuntimeOptions): RuntimeOptions {
|
||||
const { basicStyle } = parseJson(chart.customAttr)
|
||||
const { basicStyle, tooltip } = parseJson(chart.customAttr)
|
||||
const { bullet } = parseJson(chart.customAttr).misc
|
||||
const isDynamic = bullet.bar.ranges.showType === 'dynamic'
|
||||
// 背景颜色,固定区间背景时,按大小降序
|
||||
@@ -228,10 +228,12 @@ export class BulletGraph extends G2ChartView<RuntimeOptions, G2Bullet> {
|
||||
style: {
|
||||
maxWidth: bullet.bar.measures.size
|
||||
},
|
||||
tooltip: {
|
||||
title: d => d.title,
|
||||
items: [{ channel: 'y' }]
|
||||
}
|
||||
tooltip: tooltip.show
|
||||
? {
|
||||
title: d => d.title,
|
||||
items: [{ channel: 'y' }]
|
||||
}
|
||||
: false
|
||||
}
|
||||
const targetName =
|
||||
chart.yAxisExt[0]?.chartShowName || bullet.bar.target.name || chart.yAxisExt[0]?.name
|
||||
@@ -247,10 +249,12 @@ export class BulletGraph extends G2ChartView<RuntimeOptions, G2Bullet> {
|
||||
interaction: {
|
||||
legendFilter: false
|
||||
},
|
||||
tooltip: {
|
||||
title: false,
|
||||
items: [{ channel: 'y' }]
|
||||
}
|
||||
tooltip: tooltip.show
|
||||
? {
|
||||
title: false,
|
||||
items: [{ channel: 'y' }]
|
||||
}
|
||||
: false
|
||||
}
|
||||
childrens.push(target)
|
||||
childrens.push(measures)
|
||||
|
||||
@@ -63,12 +63,10 @@ export class GroupStackBar extends StackBar {
|
||||
}
|
||||
}
|
||||
protected configTooltip(chart: Chart, options: ViewSpec): ViewSpec {
|
||||
const { children } = options
|
||||
const { tooltip } = parseJson(chart.customAttr)
|
||||
if (!tooltip.show) {
|
||||
return {
|
||||
...options,
|
||||
tooltip: false
|
||||
}
|
||||
return options
|
||||
}
|
||||
const tooltipMap = function (a) {
|
||||
return a
|
||||
@@ -117,13 +115,7 @@ export class GroupStackBar extends StackBar {
|
||||
}
|
||||
return {
|
||||
...options,
|
||||
children: [
|
||||
{
|
||||
...options.children[0],
|
||||
...tooltipOptions
|
||||
},
|
||||
...options.children.slice(1)
|
||||
]
|
||||
children: [{ ...children[0], ...tooltipOptions }, ...children.slice(1)]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,12 +69,10 @@ export class PercentageStackBar extends GroupStackBar {
|
||||
}
|
||||
|
||||
protected configTooltip(chart: Chart, options: ViewSpec): ViewSpec {
|
||||
const { children } = options
|
||||
const { tooltip } = parseJson(chart.customAttr)
|
||||
if (!tooltip.show) {
|
||||
return {
|
||||
...options,
|
||||
tooltip: false
|
||||
}
|
||||
return options
|
||||
}
|
||||
const tooltipMap = function (a) {
|
||||
return a
|
||||
@@ -130,13 +128,7 @@ export class PercentageStackBar extends GroupStackBar {
|
||||
}
|
||||
return {
|
||||
...options,
|
||||
children: [
|
||||
{
|
||||
...options.children[0],
|
||||
...tooltipOptions
|
||||
},
|
||||
...options.children.slice(1)
|
||||
]
|
||||
children: [{ ...children[0], ...tooltipOptions }, ...children.slice(1)]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,6 @@ export class PercentageStackBar extends HorizontalStackBar {
|
||||
const { tooltip } = parseJson(chart.customAttr)
|
||||
const { children } = options
|
||||
if (!tooltip.show) {
|
||||
children[0].tooltip = false
|
||||
return options
|
||||
}
|
||||
const tooltipMap = function (a) {
|
||||
@@ -121,13 +120,7 @@ export class PercentageStackBar extends HorizontalStackBar {
|
||||
}
|
||||
return {
|
||||
...options,
|
||||
children: [
|
||||
{
|
||||
...options.children[0],
|
||||
...tooltipOptions
|
||||
},
|
||||
...options.children.slice(1)
|
||||
]
|
||||
children: [{ ...children[0], ...tooltipOptions }, ...children.slice(1)]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,8 @@ export class ProgressBar extends HorizontalStackBar {
|
||||
scale: {
|
||||
color: { range: [] },
|
||||
y: { nice: true }
|
||||
}
|
||||
},
|
||||
tooltip: false
|
||||
},
|
||||
{
|
||||
type: 'interval',
|
||||
@@ -179,7 +180,8 @@ export class ProgressBar extends HorizontalStackBar {
|
||||
scale: {
|
||||
color: { type: 'identity' }
|
||||
},
|
||||
animate: false
|
||||
animate: false,
|
||||
tooltip: false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -253,7 +255,6 @@ export class ProgressBar extends HorizontalStackBar {
|
||||
const { children } = options
|
||||
const { tooltip } = parseJson(chart.customAttr)
|
||||
if (!tooltip.show) {
|
||||
children[0].tooltip = false
|
||||
return options
|
||||
}
|
||||
children[0].tooltip = {
|
||||
|
||||
@@ -106,18 +106,15 @@ export class StackBar extends Bar {
|
||||
}
|
||||
|
||||
protected configTooltip(chart: Chart, options: ViewSpec): ViewSpec {
|
||||
const { children } = options
|
||||
const { tooltip } = parseJson(chart.customAttr)
|
||||
if (!tooltip.show) {
|
||||
return {
|
||||
...options,
|
||||
tooltip: false
|
||||
}
|
||||
return options
|
||||
}
|
||||
const tooltipMap = function (a) {
|
||||
return a
|
||||
}
|
||||
tooltipMap.title = undefined
|
||||
|
||||
const tooltipOptions: ViewSpec = {
|
||||
tooltip: tooltipMap,
|
||||
interaction: {
|
||||
@@ -158,13 +155,7 @@ export class StackBar extends Bar {
|
||||
}
|
||||
return {
|
||||
...options,
|
||||
children: [
|
||||
{
|
||||
...options.children[0],
|
||||
...tooltipOptions
|
||||
},
|
||||
...options.children.slice(1)
|
||||
]
|
||||
children: [{ ...children[0], ...tooltipOptions }, ...children.slice(1)]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,6 @@ export class HorizontalStackBar extends HorizontalBar {
|
||||
const { children } = options
|
||||
const { tooltip } = parseJson(chart.customAttr)
|
||||
if (!tooltip.show) {
|
||||
children[0].tooltip = false
|
||||
return options
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user