Skip to content

An open source alternative to Tableau. Embeddable visual analytic

fix(tooltip): detail channel not aggregated

AntoineYANGc2bb49ecddb7
diff --git a/packages/graphic-walker/src/vis/spec/tooltip.ts b/packages/graphic-walker/src/vis/spec/tooltip.ts
index b707dd09..b6237664 100644
--- a/packages/graphic-walker/src/vis/spec/tooltip.ts
+++ b/packages/graphic-walker/src/vis/spec/tooltip.ts
@@ -1,6 +1,7 @@
import { IViewField } from "../../interfaces";
+import { getMeaAggKey } from "../../utils";
-export function addTooltipEncode (encoding: {[key: string]: any}, details: Readonly<IViewField[]> = []) {
+export function addTooltipEncode (encoding: {[key: string]: any}, details: Readonly<IViewField[]> = [], defaultAggregated = false) {
const encs = Object.keys(encoding).filter(ck => ck !== 'tooltip').map(ck => {
return {
field: encoding[ck].field,
@@ -8,8 +9,8 @@ export function addTooltipEncode (encoding: {[key: string]: any}, details: Reado
title: encoding[ck].title
}
}).concat(details.map(f => ({
- field: f.fid,
- title: f.name,
+ field: defaultAggregated ? getMeaAggKey(f.fid, f.aggName) : f.fid,
+ title: defaultAggregated && f.aggName ? `${f.aggName}(${f.name})` : f.name,
type: f.semanticType
})))
encoding.tooltip = encs
diff --git a/packages/graphic-walker/src/vis/spec/view.ts b/packages/graphic-walker/src/vis/spec/view.ts
index 27bf8066..770cd8e2 100644
--- a/packages/graphic-walker/src/vis/spec/view.ts
+++ b/packages/graphic-walker/src/vis/spec/view.ts
@@ -67,7 +67,7 @@ export function getSingleView(props: SingleViewProps) {
if (defaultAggregated) {
channelAggregate(encoding, fields);
}
- addTooltipEncode(encoding, details);
+ addTooltipEncode(encoding, details, defaultAggregated);
channelStack(encoding, stack);
const mark = {
type: markType,