@visactor/vgrammar-core 0.13.0-alpha.9 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/graph/animation/animation/update.js +5 -1
- package/cjs/graph/animation/animation/update.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/interactions/element-select.d.ts +1 -1
- package/cjs/interactions/element-select.js +17 -16
- package/cjs/interactions/element-select.js.map +1 -1
- package/cjs/interactions/utils.d.ts +5 -1
- package/cjs/interactions/utils.js +15 -2
- package/cjs/interactions/utils.js.map +1 -1
- package/cjs/types/interaction.d.ts +2 -1
- package/cjs/types/interaction.js.map +1 -1
- package/cjs/view/View.js +2 -2
- package/cjs/view/View.js.map +1 -1
- package/es/graph/animation/animation/update.js +8 -4
- package/es/graph/animation/animation/update.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/interactions/brush-filter.js +2 -1
- package/es/interactions/element-highlight-by-group.js +1 -2
- package/es/interactions/element-select.d.ts +1 -1
- package/es/interactions/element-select.js +19 -17
- package/es/interactions/element-select.js.map +1 -1
- package/es/interactions/index.js +2 -1
- package/es/interactions/legend-filter.js +1 -1
- package/es/interactions/player-filter.js +1 -1
- package/es/interactions/roll-up.js +1 -1
- package/es/interactions/scrollbar-filter.js +1 -1
- package/es/interactions/slider-filter.js +1 -1
- package/es/interactions/toggle-state-mixin.js +1 -1
- package/es/interactions/tooltip.js +1 -1
- package/es/interactions/utils.d.ts +5 -1
- package/es/interactions/utils.js +13 -0
- package/es/interactions/utils.js.map +1 -1
- package/es/parse/coordinate.js +1 -1
- package/es/parse/event.js +1 -1
- package/es/parse/mark.js +1 -1
- package/es/parse/option.js +1 -1
- package/es/parse/scale.js +1 -2
- package/es/parse/transform.js +1 -1
- package/es/parse/util.js +1 -1
- package/es/parse/view.js +1 -1
- package/es/types/interaction.d.ts +2 -1
- package/es/types/interaction.js.map +1 -1
- package/es/view/View.js +2 -2
- package/es/view/View.js.map +1 -1
- package/package.json +11 -11
|
@@ -9,12 +9,16 @@ const vutils_1 = require("@visactor/vutils"), vgrammar_util_1 = require("@visact
|
|
|
9
9
|
}, update = (element, options, animationParameters) => {
|
|
10
10
|
const from = Object.assign({}, element.getPrevGraphicAttributes()), to = Object.assign({}, element.getNextGraphicAttributes());
|
|
11
11
|
let excludeChannels;
|
|
12
|
-
|
|
12
|
+
options && (0, vutils_1.array)(options.excludeChannels).forEach((key => {
|
|
13
13
|
delete from[key], delete to[key];
|
|
14
14
|
})), element.mark && element.mark.markType && (excludeChannels = BUILT_IN_EXCLUDE_CHANNELS[element.mark.markType]) && excludeChannels.forEach((key => {
|
|
15
15
|
delete from[key], delete to[key];
|
|
16
16
|
})), Object.keys(to).forEach((key => {
|
|
17
17
|
(0, vgrammar_util_1.isEqual)(key, from, to) && (delete from[key], delete to[key]);
|
|
18
|
+
}));
|
|
19
|
+
const final = element.getFinalGraphicAttributes();
|
|
20
|
+
return Object.keys(from).forEach((key => {
|
|
21
|
+
(0, vutils_1.isNil)(to[key]) && ((0, vutils_1.isNil)(final[key]) || (0, vutils_1.isEqual)(from[key], final[key]) ? delete from[key] : to[key] = final[key]);
|
|
18
22
|
})), {
|
|
19
23
|
from: from,
|
|
20
24
|
to: to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/animation/animation/update.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/graph/animation/animation/update.ts"],"names":[],"mappings":";;;AAAA,6CAAyD;AACzD,2DAAkE;AAQlE,MAAM,yBAAyB,GAAG;IAChC,MAAM,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC;CACjC,CAAC;AAEK,MAAM,MAAM,GAA4B,CAC7C,OAAiB,EACjB,OAAgC,EAChC,mBAAyC,EACzC,EAAE;IACF,MAAM,IAAI,GAAG,MAAM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,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,IAAA,gBAAO,EAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE;gBACvD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;aAClB;iBAAM;gBACL,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;aACtB;SACF;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AACtB,CAAC,CAAC;AAzCW,QAAA,MAAM,UAyCjB","file":"update.js","sourcesContent":["import { array, isNil, isEqual } from '@visactor/vutils';\nimport { isEqual as isEmptyByKey } from '@visactor/vgrammar-util';\nimport type { IElement } from '../../../types';\nimport type { IAnimationParameters, TypeAnimation } from '../../../types/animate';\n\nexport interface IUpdateAnimationOptions {\n excludeChannels: string[];\n}\n\nconst BUILT_IN_EXCLUDE_CHANNELS = {\n symbol: ['_mo_hide_', 'visible']\n};\n\nexport const update: TypeAnimation<IElement> = (\n element: IElement,\n options: IUpdateAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const from = Object.assign({}, element.getPrevGraphicAttributes());\n const to = Object.assign({}, element.getNextGraphicAttributes());\n if (options) {\n array(options.excludeChannels).forEach(key => {\n delete from[key];\n delete to[key];\n });\n }\n let excludeChannels: string[];\n if (element.mark && element.mark.markType && (excludeChannels = BUILT_IN_EXCLUDE_CHANNELS[element.mark.markType])) {\n excludeChannels.forEach(key => {\n delete from[key];\n delete to[key];\n });\n }\n\n Object.keys(to).forEach(key => {\n if (isEmptyByKey(key, from, to)) {\n delete from[key];\n delete to[key];\n }\n });\n\n const final = element.getFinalGraphicAttributes();\n\n Object.keys(from).forEach(key => {\n if (isNil(to[key])) {\n if (isNil(final[key]) || isEqual(from[key], final[key])) {\n delete from[key];\n } else {\n to[key] = final[key];\n }\n }\n });\n\n return { from, to };\n};\n"]}
|
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", {
|
|
19
19
|
value: !0
|
|
20
20
|
}), exports.vglobal = exports.ThemeManager = exports.SIGNAL_VIEW_BOX = exports.SIGNAL_WIDTH = exports.SIGNAL_VIEW_WIDTH = exports.SIGNAL_VIEW_HEIGHT = exports.SIGNAL_PADDING = exports.SIGNAL_HEIGHT = exports.SIGNAL_AUTOFIT = exports.Factory = exports.GrammarBase = exports.invokeFunctionType = exports.parseFunctionType = exports.registerCoordinate = exports.Coordinate = exports.registerScale = exports.Scale = exports.View = exports.version = void 0,
|
|
21
|
-
exports.version = "0.13.0
|
|
21
|
+
exports.version = "0.13.0", __exportStar(require("./graph"), exports), __exportStar(require("./interactions"), exports);
|
|
22
22
|
|
|
23
23
|
var view_1 = require("./view");
|
|
24
24
|
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,0CAAwB;AAExB,iDAA+B;AAE/B,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,sCAAoD;AAA3C,8FAAA,KAAK,OAAA;AAAE,sGAAA,aAAa,OAAA;AAC7B,gDAAmE;AAA1D,wGAAA,UAAU,OAAA;AAAE,gHAAA,kBAAkB,OAAA;AACvC,qCAAqE;AAA5D,yGAAA,iBAAiB,OAAA;AAAE,0GAAA,kBAAkB,OAAA;AAC9C,oDAAkD;AAAzC,2GAAA,WAAW,OAAA;AACpB,8CAA4B;AAC5B,0CAAwB;AACxB,0CAAyC;AAAhC,kGAAA,OAAO,OAAA;AAChB,8CAQ0B;AAPxB,2GAAA,cAAc,OAAA;AACd,0GAAA,aAAa,OAAA;AACb,2GAAA,cAAc,OAAA;AACd,+GAAA,kBAAkB,OAAA;AAClB,8GAAA,iBAAiB,OAAA;AACjB,yGAAA,YAAY,OAAA;AACZ,4GAAA,eAAe,OAAA;AAGjB,uDAAqD;AAA5C,6GAAA,YAAY,OAAA;AAErB,0CAAwB;AACxB,8CAA4B;AAC5B,+CAA6B;AAC7B,8DAA4C;AAE5C,uDAAiD;AAAxC,uGAAA,OAAO,OAAA;AAChB,wCAAsB;AACtB,iDAA+B;AAC/B,wDAAsC;AACtC,4DAA0C;AAC1C,uDAAqC","file":"index.js","sourcesContent":["// -- Exports -----\nexport const version = \"0.13.0\";\n\nexport * from './graph';\n\nexport * from './interactions';\n\nexport { View } from './view';\nexport { Scale, registerScale } from './view/scale';\nexport { Coordinate, registerCoordinate } from './view/coordinate';\nexport { parseFunctionType, invokeFunctionType } from './parse/util';\nexport { GrammarBase } from './view/grammar-base';\nexport * from './util/text';\nexport * from './types';\nexport { Factory } from './core/factory';\nexport {\n SIGNAL_AUTOFIT,\n SIGNAL_HEIGHT,\n SIGNAL_PADDING,\n SIGNAL_VIEW_HEIGHT,\n SIGNAL_VIEW_WIDTH,\n SIGNAL_WIDTH,\n SIGNAL_VIEW_BOX\n} from './view/constants';\n\nexport { ThemeManager } from './theme/theme-manager';\n\nexport * from './glyph';\nexport * from './component';\nexport * from './transforms';\nexport * from './graph/animation/animation';\n\nexport { vglobal } from '@visactor/vrender-core';\nexport * from './env';\nexport * from './interactions';\nexport * from './semantic-marks/cell';\nexport * from './semantic-marks/interval';\nexport * from './graph/mark/graphic';\n"]}
|
|
@@ -6,7 +6,7 @@ export declare class ElementSelect extends BaseInteraction<ElementSelectOptions>
|
|
|
6
6
|
static type: string;
|
|
7
7
|
type: string;
|
|
8
8
|
static defaultOptions: ElementSelectOptions;
|
|
9
|
-
protected _resetType
|
|
9
|
+
protected _resetType: ('view' | 'self' | 'timeout')[];
|
|
10
10
|
protected _marks?: IMark[];
|
|
11
11
|
protected _stateMarks: Record<string, IMark[]>;
|
|
12
12
|
private _timer?;
|
|
@@ -8,7 +8,7 @@ const vutils_1 = require("@visactor/vutils"), enums_1 = require("../graph/enums"
|
|
|
8
8
|
|
|
9
9
|
class ElementSelect extends base_1.BaseInteraction {
|
|
10
10
|
constructor(view, options) {
|
|
11
|
-
super(view, options), this.type = ElementSelect.type, this.clearPrevElements = () => {
|
|
11
|
+
super(view, options), this.type = ElementSelect.type, this._resetType = [], this.clearPrevElements = () => {
|
|
12
12
|
const {state: state, reverseState: reverseState} = this.options;
|
|
13
13
|
this._statedElements && this._statedElements.length && (this.clearAllStates(state, reverseState),
|
|
14
14
|
this.dispatchEvent("reset", {
|
|
@@ -29,32 +29,33 @@ class ElementSelect extends base_1.BaseInteraction {
|
|
|
29
29
|
const triggerOff = this.options.triggerOff, trigger = this.options.trigger, events = [ {
|
|
30
30
|
type: trigger,
|
|
31
31
|
handler: this.handleStart
|
|
32
|
-
} ];
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
type: eventName,
|
|
40
|
-
handler: this.handleReset
|
|
41
|
-
}), events;
|
|
32
|
+
} ], {eventNames: eventNames, resetType: resetType} = (0, utils_1.parseTriggerOffOfSelect)(triggerOff);
|
|
33
|
+
return eventNames.forEach((evt => {
|
|
34
|
+
evt && ((0, vutils_1.isArray)(trigger) ? !trigger.includes(evt) : evt !== trigger) && events.push({
|
|
35
|
+
type: evt,
|
|
36
|
+
handler: this.handleReset
|
|
37
|
+
});
|
|
38
|
+
})), this._resetType = resetType, events;
|
|
42
39
|
}
|
|
43
40
|
start(element) {
|
|
44
41
|
const {state: state, reverseState: reverseState, isMultiple: isMultiple} = this.options;
|
|
45
|
-
element && this._marks && this._marks.includes(element.mark)
|
|
46
|
-
|
|
42
|
+
if (element && this._marks && this._marks.includes(element.mark)) if (element.hasState(state)) {
|
|
43
|
+
if (this._resetType.includes("self")) {
|
|
44
|
+
const newStatedElements = this._statedElements && this._statedElements.filter((el => el !== element));
|
|
45
|
+
newStatedElements && newStatedElements.length ? this._statedElements = this.updateStates(newStatedElements, this._statedElements, state, reverseState) : this.clearPrevElements();
|
|
46
|
+
}
|
|
47
|
+
} else this._timer && clearTimeout(this._timer), element.addState(state), this._statedElements = this.updateStates(isMultiple && this._statedElements ? [ ...this._statedElements, element ] : [ element ], this._statedElements, state, reverseState),
|
|
47
48
|
this.dispatchEvent("start", {
|
|
48
49
|
elements: this._statedElements,
|
|
49
50
|
options: this.options
|
|
50
|
-
}), "timeout"
|
|
51
|
+
}), this._resetType.includes("timeout") && (this._timer = setTimeout((() => {
|
|
51
52
|
this.clearPrevElements();
|
|
52
|
-
}), this.options.triggerOff))
|
|
53
|
+
}), this.options.triggerOff)); else this._resetType.includes("view") && this._statedElements && this._statedElements.length && this.clearPrevElements();
|
|
53
54
|
}
|
|
54
55
|
reset(element) {
|
|
55
56
|
if (!this._statedElements || !this._statedElements.length) return;
|
|
56
57
|
const hasActiveElement = element && this._marks && this._marks.includes(element.mark);
|
|
57
|
-
"view"
|
|
58
|
+
(this._resetType.includes("view") && !hasActiveElement || this._resetType.includes("self") && hasActiveElement) && this.clearPrevElements();
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interactions/element-select.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/interactions/element-select.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAC3C,0CAAsD;AAWtD,mCAAqE;AACrE,iCAAyC;AAIzC,MAAa,aAAc,SAAQ,sBAAqC;IActE,YAAY,IAAW,EAAE,OAA8B;QACrD,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAbvB,SAAI,GAAW,aAAa,CAAC,IAAI,CAAC;QAMxB,eAAU,GAAoC,EAAE,CAAC;QA0C3D,sBAAiB,GAAG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AAM,EAAE;YACzD,OAAO;SACR;QAED,MAAM,gBAAgB,GAAG,OAAO,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEtF,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE;YACzD,IAAI,CAAC,iBAAiB,EAAE,CAAC;SAC1B;aAAM,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,gBAAgB,EAAE;YAC/D,IAAI,CAAC,iBAAiB,EAAE,CAAC;SAC1B;IACH,CAAC;;AAvHH,sCAwHC;AAvHQ,kBAAI,GAAW,gBAAgB,CAAC;AAGhC,4BAAc,GAAyB;IAC5C,KAAK,EAAE,4BAAoB,CAAC,QAAQ;IACpC,OAAO,EAAE,OAAO;CACjB,CAAC","file":"element-select.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { InteractionStateEnum } from '../graph/enums';\nimport type {\n ElementSelectOptions,\n EventType,\n IElement,\n IGlyphElement,\n IMark,\n IToggleStateMixin,\n IView,\n InteractionEvent\n} from '../types';\nimport { groupMarksByState, parseTriggerOffOfSelect } from './utils';\nimport { BaseInteraction } from './base';\n\nexport interface ElementSelect extends IToggleStateMixin, BaseInteraction<ElementSelectOptions> {}\n\nexport class ElementSelect extends BaseInteraction<ElementSelectOptions> {\n static type: string = 'element-select';\n type: string = ElementSelect.type;\n\n static defaultOptions: ElementSelectOptions = {\n state: InteractionStateEnum.selected,\n trigger: 'click'\n };\n protected _resetType: ('view' | 'self' | 'timeout')[] = [];\n protected _marks?: IMark[];\n protected _stateMarks: Record<string, IMark[]>;\n private _timer?: number;\n protected _statedElements?: (IElement | IGlyphElement)[];\n\n constructor(view: IView, options?: ElementSelectOptions) {\n super(view, options);\n this.options = Object.assign({}, ElementSelect.defaultOptions, options);\n\n this._marks = view.getMarksBySelector(this.options.selector);\n this._stateMarks = groupMarksByState(this._marks, [this.options.state, this.options.reverseState]);\n }\n\n getStartState(): string {\n return this.options.state;\n }\n\n protected getEvents() {\n const triggerOff = this.options.triggerOff;\n const trigger = this.options.trigger;\n\n const events = [\n {\n type: trigger,\n handler: this.handleStart\n }\n ];\n\n const { eventNames, resetType } = parseTriggerOffOfSelect(triggerOff);\n\n eventNames.forEach(evt => {\n if (evt && (isArray(trigger) ? !trigger.includes(evt) : evt !== trigger)) {\n events.push({ type: evt as EventType, handler: this.handleReset });\n }\n });\n\n this._resetType = resetType;\n\n return events;\n }\n\n clearPrevElements = () => {\n const { state, reverseState } = this.options;\n\n if (this._statedElements && this._statedElements.length) {\n this.clearAllStates(state, reverseState);\n this.dispatchEvent('reset', { elements: this._statedElements, options: this.options });\n\n this._statedElements = [];\n }\n };\n\n handleStart = (e: InteractionEvent) => {\n this.start(e.element);\n };\n\n handleReset = (e: InteractionEvent) => {\n this.reset(e.element);\n };\n\n start(element: InteractionEvent['element']) {\n const { state, reverseState, isMultiple } = this.options;\n if (element && this._marks && this._marks.includes(element.mark)) {\n if (element.hasState(state)) {\n if (this._resetType.includes('self')) {\n const newStatedElements = this._statedElements && this._statedElements.filter(el => el !== element);\n\n if (newStatedElements && newStatedElements.length) {\n this._statedElements = this.updateStates(newStatedElements, this._statedElements, state, reverseState);\n } else {\n this.clearPrevElements();\n }\n }\n } else {\n if (this._timer) {\n clearTimeout(this._timer);\n }\n element.addState(state);\n\n this._statedElements = this.updateStates(\n isMultiple && this._statedElements ? [...this._statedElements, element] : [element],\n this._statedElements,\n state,\n reverseState\n );\n this.dispatchEvent('start', { elements: this._statedElements, options: this.options });\n\n if (this._resetType.includes('timeout')) {\n this._timer = setTimeout(() => {\n this.clearPrevElements();\n }, this.options.triggerOff as number) as unknown as number;\n }\n }\n } else if (this._resetType.includes('view') && this._statedElements && this._statedElements.length) {\n this.clearPrevElements();\n }\n }\n\n reset(element: InteractionEvent['element']) {\n if (!this._statedElements || !this._statedElements.length) {\n return;\n }\n\n const hasActiveElement = element && this._marks && this._marks.includes(element.mark);\n\n if (this._resetType.includes('view') && !hasActiveElement) {\n this.clearPrevElements();\n } else if (this._resetType.includes('self') && hasActiveElement) {\n this.clearPrevElements();\n }\n }\n}\n"]}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import type { ElementFilterOptions, IElement, IMark } from '../types';
|
|
1
|
+
import type { ElementFilterOptions, ElementSelectTriggerOff, EventType, IElement, IMark } from '../types';
|
|
2
2
|
export declare const generateFilterValue: (options: ElementFilterOptions) => (el: IElement) => any;
|
|
3
3
|
export declare const groupMarksByState: (marks: IMark[], states: string[]) => Record<string, IMark[]>;
|
|
4
|
+
export declare const parseTriggerOffOfSelect: (triggerOff: ElementSelectTriggerOff | ElementSelectTriggerOff[]) => {
|
|
5
|
+
eventNames: EventType[];
|
|
6
|
+
resetType: ("view" | "self" | "timeout")[];
|
|
7
|
+
};
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.groupMarksByState = exports.generateFilterValue = void 0;
|
|
5
|
+
}), exports.parseTriggerOffOfSelect = exports.groupMarksByState = exports.generateFilterValue = void 0;
|
|
6
6
|
|
|
7
|
-
const generateFilterValue = options => options.filterField ? el => {
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), generateFilterValue = options => options.filterField ? el => {
|
|
8
8
|
var _a;
|
|
9
9
|
return null === (_a = el.getDatum()) || void 0 === _a ? void 0 : _a[options.filterField];
|
|
10
10
|
} : el => el[options.filterType];
|
|
@@ -23,4 +23,17 @@ const groupMarksByState = (marks, states) => {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
exports.groupMarksByState = groupMarksByState;
|
|
26
|
+
|
|
27
|
+
const parseTriggerOffOfSelect = triggerOff => {
|
|
28
|
+
const triggerOffArray = (0, vutils_1.array)(triggerOff), resetType = [], eventNames = [];
|
|
29
|
+
return triggerOffArray.forEach((off => {
|
|
30
|
+
"empty" === off ? resetType.push("view") : (0, vutils_1.isString)(off) && "none" !== off ? off.includes("view:") ? (eventNames.push(off.replace("view:", "")),
|
|
31
|
+
resetType.push("view")) : (eventNames.push(off), resetType.push("self")) : (0, vutils_1.isNumber)(off) && resetType.push("timeout");
|
|
32
|
+
})), {
|
|
33
|
+
eventNames: eventNames,
|
|
34
|
+
resetType: resetType
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.parseTriggerOffOfSelect = parseTriggerOffOfSelect;
|
|
26
39
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interactions/utils.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/interactions/utils.ts"],"names":[],"mappings":";;;AAAA,6CAA6D;AAGtD,MAAM,mBAAmB,GAAG,CAAC,OAA6B,EAAE,EAAE;IACnE,IAAI,OAAO,CAAC,WAAW,EAAE;QACvB,OAAO,CAAC,EAAY,EAAE,EAAE;;YACtB,OAAO,MAAA,EAAE,CAAC,QAAQ,EAAE,0CAAG,OAAO,CAAC,WAAW,CAAC,CAAC;QAC9C,CAAC,CAAC;KACH;IAED,OAAO,CAAC,EAAY,EAAE,EAAE;QACtB,OAAO,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,mBAAmB,uBAU9B;AAEK,MAAM,iBAAiB,GAAG,CAAC,KAAc,EAAE,MAAgB,EAA2B,EAAE;IAC7F,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE;QACrB,OAAO,IAAI,CAAC;KACb;IAED,MAAM,GAAG,GAAG,EAAE,CAAC;IAEf,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACnB,MAAM,QAAQ,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAA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B;SACF;aAAM,IAAI,IAAA,iBAAQ,EAAC,GAAG,CAAC,EAAE;YACxB,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAC3B;IACH,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,UAAU;QACV,SAAS;KACV,CAAC;AACJ,CAAC,CAAC;AA3BW,QAAA,uBAAuB,2BA2BlC","file":"utils.js","sourcesContent":["import { array, isNumber, isString } from '@visactor/vutils';\nimport type { ElementFilterOptions, ElementSelectTriggerOff, EventType, IElement, IMark, MarkSpec } from '../types';\n\nexport const generateFilterValue = (options: ElementFilterOptions) => {\n if (options.filterField) {\n return (el: IElement) => {\n return el.getDatum()?.[options.filterField];\n };\n }\n\n return (el: IElement) => {\n return el[options.filterType];\n };\n};\n\nexport const groupMarksByState = (marks: IMark[], states: string[]): Record<string, IMark[]> => {\n if (!states || !marks) {\n return null;\n }\n\n const res = {};\n\n marks.forEach(mark => {\n const markSpec = (mark && mark.getSpec()) as MarkSpec;\n const encode = markSpec && markSpec.encode;\n\n if (!encode) {\n return;\n }\n\n states.forEach(state => {\n if (state && encode[state]) {\n if (!res[state]) {\n res[state] = [];\n }\n\n res[state].push(mark);\n }\n });\n });\n\n return res;\n};\n\nexport const parseTriggerOffOfSelect = (triggerOff: ElementSelectTriggerOff | ElementSelectTriggerOff[]) => {\n const triggerOffArray = array(triggerOff);\n const resetType: ('view' | 'self' | 'timeout')[] = [];\n const eventNames: EventType[] = [];\n\n triggerOffArray.forEach(off => {\n if (off === 'empty') {\n resetType.push('view');\n } else if (isString(off) && off !== 'none') {\n if ((off as string).includes('view:')) {\n eventNames.push((off as string).replace('view:', '') as EventType);\n\n resetType.push('view');\n } else {\n eventNames.push(off as EventType);\n\n resetType.push('self');\n }\n } else if (isNumber(off)) {\n resetType.push('timeout');\n }\n });\n\n return {\n eventNames,\n resetType\n };\n};\n"]}
|
|
@@ -45,12 +45,13 @@ export interface ElementActiveOptions extends IBaseInteractionOptions {
|
|
|
45
45
|
triggerOff?: EventType | EventType[] | 'none';
|
|
46
46
|
state?: string;
|
|
47
47
|
}
|
|
48
|
+
export type ElementSelectTriggerOff = EventType | ViewEventType | 'empty' | 'none' | number;
|
|
48
49
|
export interface ElementSelectOptions extends IBaseInteractionOptions {
|
|
49
50
|
selector?: string | string[] | IMark | IMark[];
|
|
50
51
|
trigger?: EventType | EventType[];
|
|
51
52
|
state?: string;
|
|
52
53
|
reverseState?: string;
|
|
53
|
-
triggerOff?:
|
|
54
|
+
triggerOff?: ElementSelectTriggerOff | ElementSelectTriggerOff[];
|
|
54
55
|
isMultiple?: boolean;
|
|
55
56
|
}
|
|
56
57
|
export interface ElementHighlightOptions extends IBaseInteractionOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/interaction.ts"],"names":[],"mappings":"","file":"interaction.js","sourcesContent":["import type { IView } from './view';\nimport type { EventType, InteractionEvent, ViewEventType } from './event';\nimport type {\n BaseCrosshairAttrs,\n BrushAttributes,\n TooltipAttributes,\n TooltipRowAttrs\n} from '@visactor/vrender-components';\nimport type { IPolygon, ISymbolGraphicAttribute, ITextGraphicAttribute } from '@visactor/vrender-core';\nimport type { IElement, IGlyphElement } from './element';\nimport type { IData, IGrammarBase, IMark, IScale } from './grammar';\nimport type { IPointLike } from '@visactor/vutils';\nimport type { IBaseScale } from '@visactor/vscale';\nimport type { IDatazoom, IScrollbar } from './component';\nimport type { FieldEncodeType, MarkFunctionType } from './mark';\n\nexport interface FilterDataTarget {\n data: string | IData;\n filter: string | ((datum: any, filterValues: any[]) => boolean);\n transform?: (data: any[], filterValues: any[]) => any[];\n}\n\nexport interface IBaseInteractionOptions {\n id?: string;\n\n dependency?: string | string[] | IGrammarBase | IGrammarBase[];\n\n shouldStart?: (e: any) => boolean;\n\n shouldUpdate?: (e: any) => boolean;\n\n shouldEnd?: (e: any) => boolean;\n\n shouldReset?: (e: any) => boolean;\n\n onStart?: (e: any) => boolean;\n\n onUpdate?: (e: any) => boolean;\n\n onEnd?: (e: any) => boolean;\n\n onReset?: (e: any) => boolean;\n}\n\nexport interface IInteraction<T = any> {\n readonly options: T;\n readonly type: string;\n depend: (grammar: IGrammarBase[] | IGrammarBase | string[] | string) => void;\n bind: () => void;\n unbind: () => void;\n start: (element: IElement | IGlyphElement | string | any) => void;\n reset: (element?: IElement | IGlyphElement) => void;\n getStartState: () => string;\n}\n\nexport interface IInteractionConstructor<T = any> {\n readonly type: string;\n\n new (view: IView, options?: T): IInteraction<T>;\n}\n\n/**\n * the interaction to set the active state of specified marks\n */\nexport interface ElementActiveOptions extends IBaseInteractionOptions {\n /**\n * the selector of marks\n */\n selector?: string | string[] | IMark | IMark[];\n /**\n * the trigger event name\n */\n trigger?: EventType | EventType[];\n /**\n * the reset trigger event name\n */\n triggerOff?: EventType | EventType[] | 'none';\n /**\n * the active state name\n */\n state?: string;\n}\n\n/**\n * the interaction to set the seleted state of specified marks\n */\nexport interface ElementSelectOptions extends IBaseInteractionOptions {\n /**\n * the selector of marks\n */\n selector?: string | string[] | IMark | IMark[];\n /**\n * the trigger event name\n */\n trigger?: EventType | EventType[];\n /**\n * the selected state name\n */\n state?: string;\n /**\n * the non-selected state name\n */\n reverseState?: string;\n /**\n * the reset trigger event name\n */\n triggerOff?: EventType | EventType[] | ViewEventType | 'empty' | 'none' | number;\n /**\n * whether or not support multiple selected\n */\n isMultiple?: boolean;\n}\n\n/**\n * the interaction to set the highlight state of specified marks\n */\nexport interface ElementHighlightOptions extends IBaseInteractionOptions {\n /**\n * the selector of marks\n */\n selector?: string | string[] | IMark | IMark[];\n /**\n * the trigger event name\n */\n trigger?: EventType;\n /**\n * the reset trigger event name\n */\n triggerOff?: EventType | 'none';\n /**\n * the highlight state name\n */\n highlightState?: string;\n /**\n * the blur state name\n */\n blurState?: string;\n}\n\nexport interface ElementFilterOptions {\n /**\n * the filter type of element\n */\n filterType?: 'key' | 'groupKey';\n /**\n * the field to be filtered\n */\n filterField?: string;\n}\n\n/**\n * the interaction to set the active state of specified marks trigger by legend\n */\nexport interface ElementActiveByLegendOptions extends IBaseInteractionOptions, ElementFilterOptions {\n /**\n * the selector of marks\n */\n selector?: string | string[] | IMark | IMark[];\n /**\n * the active state name\n */\n state?: string;\n}\n\n/**\n * the interaction to set the active state of specified marks trigger by legend\n */\nexport interface ElementHighlightByLegendOptions extends IBaseInteractionOptions, ElementFilterOptions {\n /**\n * the selector of marks\n */\n selector?: string | string[] | IMark | IMark[];\n /**\n * the highlight state name\n */\n highlightState?: string;\n /**\n * the blur state name\n */\n blurState?: string;\n}\n\nexport interface ElementHighlightByNameOptions extends ElementHighlightByLegendOptions {\n graphicName?: string | string[];\n /**\n * the trigger event name\n */\n trigger?: EventType;\n /**\n * the reset trigger event name\n */\n triggerOff?: EventType | 'none';\n\n parseData?: (e: InteractionEvent) => any;\n}\n\nexport interface BrushEventParams {\n operateType: string;\n operateMask: IPolygon;\n activeElements?: (IElement | IGlyphElement)[];\n}\n\nexport interface BrushOptions extends IBaseInteractionOptions, BrushAttributes {\n /**\n * the selector of marks\n */\n selector?: string | string[] | IMark | IMark[];\n\n onStart?: (params: BrushEventParams) => boolean;\n\n onUpdate?: (params: BrushEventParams) => boolean;\n\n onEnd?: (params: BrushEventParams) => boolean;\n\n onReset?: (params: BrushEventParams) => boolean;\n}\n\nexport interface BrushHighlightOptions extends BrushOptions {\n /**\n * the highlight state name\n */\n highlightState?: string;\n /**\n * the blur state name\n */\n blurState?: string;\n}\n\nexport interface BrushActiveOptions extends BrushOptions {\n /**\n * the active state name\n */\n state?: string;\n}\n\nexport interface BrushFilterOptions extends BrushOptions {\n target: {\n data: IData | string;\n transform?: (data: any[], filterValue: any) => any[];\n };\n}\n\nexport interface DataFilterOptions extends IBaseInteractionOptions {\n /**\n * the selector of marks\n */\n source?: string | string[] | IMark | IMark[];\n\n /**\n * data target\n */\n target: {\n data: IData | string;\n filter?: string | ((datum: any, filterValue: any) => boolean);\n transform?: (data: any[], filterValue: any) => any[];\n };\n}\n\nexport interface DrillDownOptions extends BrushOptions {\n /**\n * enable brush\n */\n brush?: boolean;\n // trigger attribute is included in brush attributes\n target: {\n data: IData | string;\n transform?: (data: any[], filterValue: any) => any[];\n };\n}\n\nexport interface RollUpOptions extends DataFilterOptions {\n /**\n * the trigger event name\n */\n trigger?: EventType;\n /**\n * the reset trigger event name\n */\n triggerOff?: EventType | ViewEventType | 'empty';\n}\n\nexport type CustomTooltipCallback = (\n datum: any,\n element: IElement,\n parameters: any\n) => TooltipRowAttrs | TooltipRowAttrs[];\n\nexport interface ITooltipRow {\n visible?: boolean;\n key?: MarkFunctionType<string | Partial<ITextGraphicAttribute>> | FieldEncodeType;\n value?: MarkFunctionType<string | Partial<ITextGraphicAttribute>> | FieldEncodeType;\n symbol?: MarkFunctionType<string | Partial<ISymbolGraphicAttribute>> | FieldEncodeType;\n}\n\nexport type TooltipType = 'x' | 'y' | 'angle' | 'radius';\n\nexport interface TooltipOptions extends IBaseInteractionOptions {\n /**\n * the selector of marks\n */\n selector?: string | string[] | IMark | IMark[];\n /**\n * the trigger event name\n */\n trigger?: EventType;\n /**\n * the reset trigger event name\n */\n triggerOff?: EventType | 'none';\n\n title?: ITooltipRow | string | CustomTooltipCallback;\n content?: ITooltipRow | ITooltipRow[] | CustomTooltipCallback;\n attributes?: MarkFunctionType<TooltipAttributes>;\n}\n\nexport interface DimensionTooltipOptions extends TooltipOptions {\n scale?: IScale | string;\n tooltipType?: TooltipType;\n target?: {\n data: IData | string;\n filter: string | ((datum: any, tooltipValue: any) => boolean);\n };\n avoidMark?: string | string[];\n container?: string | IMark;\n center?: IPointLike;\n}\n\nexport type CrosshairType = 'x' | 'y' | 'angle' | 'radius' | 'radius-polygon';\n\nexport type CrosshairShape = 'line' | 'rect';\n\nexport interface CrosshairOptions extends IBaseInteractionOptions {\n /**\n * the trigger event name\n */\n trigger?: EventType;\n /**\n * the reset trigger event name\n */\n triggerOff?: EventType | 'none';\n scale?: IScale | string;\n crosshairType?: CrosshairType;\n crosshairShape?: CrosshairShape;\n container?: string | IMark;\n radius?: number;\n center?: IPointLike;\n attributes?: MarkFunctionType<BaseCrosshairAttrs>;\n}\nexport interface ViewNavigationBaseOptions {\n enableX?: boolean;\n enableY?: boolean;\n scaleX?: string | IScale;\n scaleY?: string | IScale;\n dataTargetX?: FilterDataTarget;\n dataTargetY?: FilterDataTarget;\n throttle?: number;\n linkedComponentX?: string | IDatazoom | IScrollbar;\n linkedComponentY?: string | IDatazoom | IScrollbar;\n rangeX?: [number, number] | (() => [number, number]);\n rangeY?: [number, number] | (() => [number, number]);\n}\n\nexport interface ViewZoomSimpleOptions {\n realtime?: boolean;\n rate?: number;\n focus?: boolean;\n trigger?: EventType;\n endTrigger?: EventType;\n triggerOff?: EventType | 'none';\n}\n\nexport type ViewZoomOptions = ViewZoomSimpleOptions & IBaseInteractionOptions & ViewNavigationBaseOptions;\n\nexport interface ViewScrollSimpleOptions {\n realtime?: boolean;\n reversed?: boolean;\n trigger?: EventType;\n endTrigger?: EventType;\n}\nexport type ViewScrollOptions = ViewScrollSimpleOptions & IBaseInteractionOptions & ViewNavigationBaseOptions;\n\nexport interface ViewDragSimpleOptions {\n realtime?: boolean;\n reversed?: boolean;\n trigger?: EventType;\n endTrigger?: EventType;\n updateTrigger?: EventType;\n}\n\nexport type ViewDragOptions = ViewDragSimpleOptions & IBaseInteractionOptions & ViewNavigationBaseOptions;\n\nexport interface ViewRoamOptions extends IBaseInteractionOptions, ViewNavigationBaseOptions {\n zoom?: ViewZoomSimpleOptions & { enable?: boolean };\n scroll?: ViewScrollSimpleOptions & { enable?: boolean };\n drag?: ViewDragSimpleOptions & { enable?: boolean };\n}\n\n/**\n * the interaction to set the highlight state of specified marks\n */\nexport interface SankeyHighlightOptions extends IBaseInteractionOptions {\n /**\n * the selector of node mark\n */\n nodeSelector?: string | IMark;\n /**\n * the selector of link mark\n */\n linkSelector?: string | IMark;\n /**\n * the trigger event name\n */\n trigger?: EventType;\n /**\n * the reset trigger event name\n */\n triggerOff?: EventType | 'none';\n /**\n * the highlight state name\n */\n highlightState?: string;\n /**\n * the blur state name\n */\n blurState?: string;\n /** set highlight state to different type of nodes */\n effect?: 'adjacency' | 'related';\n}\n\nexport interface FishEyeOptions extends IBaseInteractionOptions {\n selector?: string | string[] | IMark | IMark[];\n /** the radius of x-direction */\n radiusX?: number;\n /** the radius of y-direction */\n radiusY?: number;\n /** the radiusRatio of x-direction */\n radiusRatioX?: number;\n /** the radiusRatio of y-direction */\n radiusRatioY?: number;\n /** x方向的扰动 */\n distortionX?: number;\n /** y方向的扰动 */\n distortionY?: number;\n /** 禁用 x方向的变形 */\n enableX?: boolean;\n /** 禁用y方向的变形 */\n enableY?: boolean;\n /** x方向的scale */\n scaleX?: string | IScale;\n /** y方向的scale */\n scaleY?: string | IScale;\n /** 节流的时长,单位为ms */\n throttle?: number;\n /**\n * the trigger event name\n */\n trigger?: EventType;\n /**\n * the trigger event of end\n */\n endTrigger?: EventType;\n /**\n * the trigger event of updating\n */\n updateTrigger?: EventType;\n /**\n * the trigger event of reset\n */\n triggerOff?: string | 'none';\n}\n\nexport interface ElementActiveSpec extends ElementActiveOptions {\n type: 'element-active';\n}\nexport interface ElementSelectSpec extends ElementSelectOptions {\n type: 'element-select';\n}\nexport interface ElementHighlightSpec extends ElementHighlightOptions {\n type: 'element-highlight';\n}\nexport interface ElementHighlightByKeySpec extends ElementHighlightOptions {\n type: 'element-highlight-by-key';\n}\nexport interface ElementHighlightByGroupSpec extends ElementHighlightOptions {\n type: 'element-highlight-by-group';\n}\nexport interface ElementActiveByLegendSpec extends ElementActiveByLegendOptions {\n type: 'element-active-by-legend';\n}\n\nexport interface ElementHighlightByLegendSpec extends ElementHighlightByLegendOptions {\n type: 'element-highlight-by-legend';\n}\n\nexport interface ElementHighlightByNameSpec extends ElementHighlightByNameOptions {\n type: 'element-highlight-by-name';\n}\n\nexport interface BrushHighlightSpec extends BrushHighlightOptions {\n type: 'brush-highlight';\n}\n\nexport interface BrushActiveSpec extends BrushActiveOptions {\n type: 'brush-active';\n}\n\nexport interface BrushFilterSpec extends BrushFilterOptions {\n type: 'brush-filter';\n}\n\nexport interface LegendFilterSpec extends DataFilterOptions {\n type: 'legend-filter';\n}\n\nexport interface DatazoomFilterSpec extends DataFilterOptions {\n type: 'datazoom-filter';\n}\n\nexport interface SliderFilterSpec extends DataFilterOptions {\n type: 'slider-filter';\n}\n\nexport interface PlayerFilterSpec extends DataFilterOptions {\n type: 'player-filter';\n}\n\nexport interface ScrollbarFilterSpec extends DataFilterOptions {\n type: 'scrollbar-filter';\n}\n\nexport interface DrillDownSpec extends DrillDownOptions {\n type: 'drill-down';\n}\n\nexport interface RollUpSpec extends RollUpOptions {\n type: 'roll-up';\n}\n\nexport interface TooltipSpec extends TooltipOptions {\n type: 'tooltip';\n}\n\nexport interface DimensionTooltipSpec extends DimensionTooltipOptions {\n type: 'dimension-tooltip';\n}\n\nexport interface CrosshairSpec extends CrosshairOptions {\n type: 'crosshair';\n}\nexport interface ViewRoamSpec extends ViewRoamOptions {\n type: 'view-roam';\n}\n\nexport interface ViewZoomSpec extends ViewZoomOptions {\n type: 'view-zoom';\n}\n\nexport interface ViewScrollSpec extends ViewScrollOptions {\n type: 'view-scroll';\n}\n\nexport interface ViewDragSpec extends ViewDragOptions {\n type: 'view-drag';\n}\n\nexport interface SankeyHighlightSpec extends SankeyHighlightOptions {\n type: 'sankey-highlight';\n}\n\nexport interface FishEyeSpec extends FishEyeOptions {\n type: 'fish-eye';\n}\n\nexport interface CustomizedInteractionSpec extends IBaseInteractionOptions {\n type: string;\n}\n\nexport type InteractionSpec =\n | ElementActiveSpec\n | ElementSelectSpec\n | ElementHighlightSpec\n | ElementHighlightByKeySpec\n | ElementHighlightByGroupSpec\n | ElementActiveByLegendSpec\n | ElementHighlightByLegendSpec\n | ElementHighlightByNameSpec\n | BrushHighlightSpec\n | BrushActiveSpec\n | BrushFilterSpec\n | LegendFilterSpec\n | DatazoomFilterSpec\n | SliderFilterSpec\n | PlayerFilterSpec\n | ScrollbarFilterSpec\n | DrillDownSpec\n | RollUpSpec\n | TooltipSpec\n | DimensionTooltipSpec\n | CrosshairSpec\n | ViewRoamSpec\n | ViewZoomSpec\n | ViewScrollSpec\n | ViewDragSpec\n | SankeyHighlightSpec\n | FishEyeSpec\n | CustomizedInteractionSpec;\n\nexport interface ViewNavigationRange {\n needUpdate?: boolean;\n x?: [number, number];\n y?: [number, number];\n}\n\nexport interface IViewZoomMixin {\n updateZoomRange: (\n rangeFactor: [number, number],\n range: [number, number],\n zoomEvent: { zoomDelta: number; zoomX: number; zoomY: number },\n zoomOptions?: ViewZoomSimpleOptions\n ) => [number, number];\n formatZoomEvent: (e: InteractionEvent) => InteractionEvent & { zoomDelta?: number; zoomX?: number; zoomY?: number };\n handleZoomStart: (\n e: InteractionEvent,\n navState: Partial<Record<'x' | 'y', ViewStateByDim>>,\n zoomOptions?: ViewZoomSimpleOptions\n ) => ViewNavigationRange;\n handleZoomEnd: (\n e: InteractionEvent,\n navState: Partial<Record<'x' | 'y', ViewStateByDim>>,\n zoomOptions?: ViewZoomSimpleOptions\n ) => ViewNavigationRange;\n handleZoomReset: (\n e: InteractionEvent,\n navState: Partial<Record<'x' | 'y', ViewStateByDim>>,\n zoomOptions?: ViewZoomSimpleOptions\n ) => ViewNavigationRange;\n}\n\nexport interface IViewScrollMixin {\n formatScrollEvent: (e: InteractionEvent) => InteractionEvent & { scrollX?: number; scrollY?: number };\n handleScrollStart: (\n e: InteractionEvent,\n navState: Partial<Record<'x' | 'y', ViewStateByDim>>,\n scrollOptions?: ViewScrollSimpleOptions\n ) => ViewNavigationRange;\n handleScrollEnd: (\n e: InteractionEvent,\n navState: Partial<Record<'x' | 'y', ViewStateByDim>>,\n scrollOptions?: ViewScrollSimpleOptions\n ) => ViewNavigationRange;\n}\n\nexport interface IViewDragMixin {\n handleDragStart: (\n e: InteractionEvent,\n navState: Partial<Record<'x' | 'y', ViewStateByDim>>,\n dragOptions?: ViewDragSimpleOptions\n ) => ViewNavigationRange;\n handleDragUpdate: (\n e: InteractionEvent,\n navState: Partial<Record<'x' | 'y', ViewStateByDim>>,\n dragOptions?: ViewDragSimpleOptions\n ) => ViewNavigationRange;\n handleDragEnd: (\n e: InteractionEvent,\n navState: Partial<Record<'x' | 'y', ViewStateByDim>>,\n dragOptions?: ViewDragSimpleOptions\n ) => ViewNavigationRange;\n}\n\nexport interface IToggleStateMixin {\n updateStates: (\n newStatedElements: (IElement | IGlyphElement)[],\n prevStatedElements?: (IElement | IGlyphElement)[],\n state?: string,\n reverseState?: string\n ) => (IElement | IGlyphElement)[];\n clearAllStates: (state?: string, reverseState?: string) => void;\n}\n\nexport interface ViewStateByDim {\n scale?: IScale;\n data?: IData;\n linkedComponent?: IDatazoom | IScrollbar;\n filterValue?: any[];\n wholeScale?: IBaseScale;\n initRangeFactor?: [number, number];\n getCurrentRange?: () => [number, number];\n rangeFactor?: [number, number];\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/types/interaction.ts"],"names":[],"mappings":"","file":"interaction.js","sourcesContent":["import type { IView } from './view';\nimport type { EventType, InteractionEvent, ViewEventType } from './event';\nimport type {\n BaseCrosshairAttrs,\n BrushAttributes,\n TooltipAttributes,\n TooltipRowAttrs\n} from '@visactor/vrender-components';\nimport type { IPolygon, ISymbolGraphicAttribute, ITextGraphicAttribute } from '@visactor/vrender-core';\nimport type { IElement, IGlyphElement } from './element';\nimport type { IData, IGrammarBase, IMark, IScale } from './grammar';\nimport type { IPointLike } from '@visactor/vutils';\nimport type { IBaseScale } from '@visactor/vscale';\nimport type { IDatazoom, IScrollbar } from './component';\nimport type { FieldEncodeType, MarkFunctionType } from './mark';\n\nexport interface FilterDataTarget {\n data: string | IData;\n filter: string | ((datum: any, filterValues: any[]) => boolean);\n transform?: (data: any[], filterValues: any[]) => any[];\n}\n\nexport interface IBaseInteractionOptions {\n id?: string;\n\n dependency?: string | string[] | IGrammarBase | IGrammarBase[];\n\n shouldStart?: (e: any) => boolean;\n\n shouldUpdate?: (e: any) => boolean;\n\n shouldEnd?: (e: any) => boolean;\n\n shouldReset?: (e: any) => boolean;\n\n onStart?: (e: any) => boolean;\n\n onUpdate?: (e: any) => boolean;\n\n onEnd?: (e: any) => boolean;\n\n onReset?: (e: any) => boolean;\n}\n\nexport interface IInteraction<T = any> {\n readonly options: T;\n readonly type: string;\n depend: (grammar: IGrammarBase[] | IGrammarBase | string[] | string) => void;\n bind: () => void;\n unbind: () => void;\n start: (element: IElement | IGlyphElement | string | any) => void;\n reset: (element?: IElement | IGlyphElement) => void;\n getStartState: () => string;\n}\n\nexport interface IInteractionConstructor<T = any> {\n readonly type: string;\n\n new (view: IView, options?: T): IInteraction<T>;\n}\n\n/**\n * the interaction to set the active state of specified marks\n */\nexport interface ElementActiveOptions extends IBaseInteractionOptions {\n /**\n * the selector of marks\n */\n selector?: string | string[] | IMark | IMark[];\n /**\n * the trigger event name\n */\n trigger?: EventType | EventType[];\n /**\n * the reset trigger event name\n */\n triggerOff?: EventType | EventType[] | 'none';\n /**\n * the active state name\n */\n state?: string;\n}\n\nexport type ElementSelectTriggerOff = EventType | ViewEventType | 'empty' | 'none' | number;\n\n/**\n * the interaction to set the seleted state of specified marks\n */\nexport interface ElementSelectOptions extends IBaseInteractionOptions {\n /**\n * the selector of marks\n */\n selector?: string | string[] | IMark | IMark[];\n /**\n * the trigger event name\n */\n trigger?: EventType | EventType[];\n /**\n * the selected state name\n */\n state?: string;\n /**\n * the non-selected state name\n */\n reverseState?: string;\n /**\n * the reset trigger event name\n */\n triggerOff?: ElementSelectTriggerOff | ElementSelectTriggerOff[];\n /**\n * whether or not support multiple selected\n */\n isMultiple?: boolean;\n}\n\n/**\n * the interaction to set the highlight state of specified marks\n */\nexport interface ElementHighlightOptions extends IBaseInteractionOptions {\n /**\n * the selector of marks\n */\n selector?: string | string[] | IMark | IMark[];\n /**\n * the trigger event name\n */\n trigger?: EventType;\n /**\n * the reset trigger event name\n */\n triggerOff?: EventType | 'none';\n /**\n * the highlight state name\n */\n highlightState?: string;\n /**\n * the blur state name\n */\n blurState?: string;\n}\n\nexport interface ElementFilterOptions {\n /**\n * the filter type of element\n */\n filterType?: 'key' | 'groupKey';\n /**\n * the field to be filtered\n */\n filterField?: string;\n}\n\n/**\n * the interaction to set the active state of specified marks trigger by legend\n */\nexport interface ElementActiveByLegendOptions extends IBaseInteractionOptions, ElementFilterOptions {\n /**\n * the selector of marks\n */\n selector?: string | string[] | IMark | IMark[];\n /**\n * the active state name\n */\n state?: string;\n}\n\n/**\n * the interaction to set the active state of specified marks trigger by legend\n */\nexport interface ElementHighlightByLegendOptions extends IBaseInteractionOptions, ElementFilterOptions {\n /**\n * the selector of marks\n */\n selector?: string | string[] | IMark | IMark[];\n /**\n * the highlight state name\n */\n highlightState?: string;\n /**\n * the blur state name\n */\n blurState?: string;\n}\n\nexport interface ElementHighlightByNameOptions extends ElementHighlightByLegendOptions {\n graphicName?: string | string[];\n /**\n * the trigger event name\n */\n trigger?: EventType;\n /**\n * the reset trigger event name\n */\n triggerOff?: EventType | 'none';\n\n parseData?: (e: InteractionEvent) => any;\n}\n\nexport interface BrushEventParams {\n operateType: string;\n operateMask: IPolygon;\n activeElements?: (IElement | IGlyphElement)[];\n}\n\nexport interface BrushOptions extends IBaseInteractionOptions, BrushAttributes {\n /**\n * the selector of marks\n */\n selector?: string | string[] | IMark | IMark[];\n\n onStart?: (params: BrushEventParams) => boolean;\n\n onUpdate?: (params: BrushEventParams) => boolean;\n\n onEnd?: (params: BrushEventParams) => boolean;\n\n onReset?: (params: BrushEventParams) => boolean;\n}\n\nexport interface BrushHighlightOptions extends BrushOptions {\n /**\n * the highlight state name\n */\n highlightState?: string;\n /**\n * the blur state name\n */\n blurState?: string;\n}\n\nexport interface BrushActiveOptions extends BrushOptions {\n /**\n * the active state name\n */\n state?: string;\n}\n\nexport interface BrushFilterOptions extends BrushOptions {\n target: {\n data: IData | string;\n transform?: (data: any[], filterValue: any) => any[];\n };\n}\n\nexport interface DataFilterOptions extends IBaseInteractionOptions {\n /**\n * the selector of marks\n */\n source?: string | string[] | IMark | IMark[];\n\n /**\n * data target\n */\n target: {\n data: IData | string;\n filter?: string | ((datum: any, filterValue: any) => boolean);\n transform?: (data: any[], filterValue: any) => any[];\n };\n}\n\nexport interface DrillDownOptions extends BrushOptions {\n /**\n * enable brush\n */\n brush?: boolean;\n // trigger attribute is included in brush attributes\n target: {\n data: IData | string;\n transform?: (data: any[], filterValue: any) => any[];\n };\n}\n\nexport interface RollUpOptions extends DataFilterOptions {\n /**\n * the trigger event name\n */\n trigger?: EventType;\n /**\n * the reset trigger event name\n */\n triggerOff?: EventType | ViewEventType | 'empty';\n}\n\nexport type CustomTooltipCallback = (\n datum: any,\n element: IElement,\n parameters: any\n) => TooltipRowAttrs | TooltipRowAttrs[];\n\nexport interface ITooltipRow {\n visible?: boolean;\n key?: MarkFunctionType<string | Partial<ITextGraphicAttribute>> | FieldEncodeType;\n value?: MarkFunctionType<string | Partial<ITextGraphicAttribute>> | FieldEncodeType;\n symbol?: MarkFunctionType<string | Partial<ISymbolGraphicAttribute>> | FieldEncodeType;\n}\n\nexport type TooltipType = 'x' | 'y' | 'angle' | 'radius';\n\nexport interface TooltipOptions extends IBaseInteractionOptions {\n /**\n * the selector of marks\n */\n selector?: string | string[] | IMark | IMark[];\n /**\n * the trigger event name\n */\n trigger?: EventType;\n /**\n * the reset trigger event name\n */\n triggerOff?: EventType | 'none';\n\n title?: ITooltipRow | string | CustomTooltipCallback;\n content?: ITooltipRow | ITooltipRow[] | CustomTooltipCallback;\n attributes?: MarkFunctionType<TooltipAttributes>;\n}\n\nexport interface DimensionTooltipOptions extends TooltipOptions {\n scale?: IScale | string;\n tooltipType?: TooltipType;\n target?: {\n data: IData | string;\n filter: string | ((datum: any, tooltipValue: any) => boolean);\n };\n avoidMark?: string | string[];\n container?: string | IMark;\n center?: IPointLike;\n}\n\nexport type CrosshairType = 'x' | 'y' | 'angle' | 'radius' | 'radius-polygon';\n\nexport type CrosshairShape = 'line' | 'rect';\n\nexport interface CrosshairOptions extends IBaseInteractionOptions {\n /**\n * the trigger event name\n */\n trigger?: EventType;\n /**\n * the reset trigger event name\n */\n triggerOff?: EventType | 'none';\n scale?: IScale | string;\n crosshairType?: CrosshairType;\n crosshairShape?: CrosshairShape;\n container?: string | IMark;\n radius?: number;\n center?: IPointLike;\n attributes?: MarkFunctionType<BaseCrosshairAttrs>;\n}\nexport interface ViewNavigationBaseOptions {\n enableX?: boolean;\n enableY?: boolean;\n scaleX?: string | IScale;\n scaleY?: string | IScale;\n dataTargetX?: FilterDataTarget;\n dataTargetY?: FilterDataTarget;\n throttle?: number;\n linkedComponentX?: string | IDatazoom | IScrollbar;\n linkedComponentY?: string | IDatazoom | IScrollbar;\n rangeX?: [number, number] | (() => [number, number]);\n rangeY?: [number, number] | (() => [number, number]);\n}\n\nexport interface ViewZoomSimpleOptions {\n realtime?: boolean;\n rate?: number;\n focus?: boolean;\n trigger?: EventType;\n endTrigger?: EventType;\n triggerOff?: EventType | 'none';\n}\n\nexport type ViewZoomOptions = ViewZoomSimpleOptions & IBaseInteractionOptions & ViewNavigationBaseOptions;\n\nexport interface ViewScrollSimpleOptions {\n realtime?: boolean;\n reversed?: boolean;\n trigger?: EventType;\n endTrigger?: EventType;\n}\nexport type ViewScrollOptions = ViewScrollSimpleOptions & IBaseInteractionOptions & ViewNavigationBaseOptions;\n\nexport interface ViewDragSimpleOptions {\n realtime?: boolean;\n reversed?: boolean;\n trigger?: EventType;\n endTrigger?: EventType;\n updateTrigger?: EventType;\n}\n\nexport type ViewDragOptions = ViewDragSimpleOptions & IBaseInteractionOptions & ViewNavigationBaseOptions;\n\nexport interface ViewRoamOptions extends IBaseInteractionOptions, ViewNavigationBaseOptions {\n zoom?: ViewZoomSimpleOptions & { enable?: boolean };\n scroll?: ViewScrollSimpleOptions & { enable?: boolean };\n drag?: ViewDragSimpleOptions & { enable?: boolean };\n}\n\n/**\n * the interaction to set the highlight state of specified marks\n */\nexport interface SankeyHighlightOptions extends IBaseInteractionOptions {\n /**\n * the selector of node mark\n */\n nodeSelector?: string | IMark;\n /**\n * the selector of link mark\n */\n linkSelector?: string | IMark;\n /**\n * the trigger event name\n */\n trigger?: EventType;\n /**\n * the reset trigger event name\n */\n triggerOff?: EventType | 'none';\n /**\n * the highlight state name\n */\n highlightState?: string;\n /**\n * the blur state name\n */\n blurState?: string;\n /** set highlight state to different type of nodes */\n effect?: 'adjacency' | 'related';\n}\n\nexport interface FishEyeOptions extends IBaseInteractionOptions {\n selector?: string | string[] | IMark | IMark[];\n /** the radius of x-direction */\n radiusX?: number;\n /** the radius of y-direction */\n radiusY?: number;\n /** the radiusRatio of x-direction */\n radiusRatioX?: number;\n /** the radiusRatio of y-direction */\n radiusRatioY?: number;\n /** x方向的扰动 */\n distortionX?: number;\n /** y方向的扰动 */\n distortionY?: number;\n /** 禁用 x方向的变形 */\n enableX?: boolean;\n /** 禁用y方向的变形 */\n enableY?: boolean;\n /** x方向的scale */\n scaleX?: string | IScale;\n /** y方向的scale */\n scaleY?: string | IScale;\n /** 节流的时长,单位为ms */\n throttle?: number;\n /**\n * the trigger event name\n */\n trigger?: EventType;\n /**\n * the trigger event of end\n */\n endTrigger?: EventType;\n /**\n * the trigger event of updating\n */\n updateTrigger?: EventType;\n /**\n * the trigger event of reset\n */\n triggerOff?: string | 'none';\n}\n\nexport interface ElementActiveSpec extends ElementActiveOptions {\n type: 'element-active';\n}\nexport interface ElementSelectSpec extends ElementSelectOptions {\n type: 'element-select';\n}\nexport interface ElementHighlightSpec extends ElementHighlightOptions {\n type: 'element-highlight';\n}\nexport interface ElementHighlightByKeySpec extends ElementHighlightOptions {\n type: 'element-highlight-by-key';\n}\nexport interface ElementHighlightByGroupSpec extends ElementHighlightOptions {\n type: 'element-highlight-by-group';\n}\nexport interface ElementActiveByLegendSpec extends ElementActiveByLegendOptions {\n type: 'element-active-by-legend';\n}\n\nexport interface ElementHighlightByLegendSpec extends ElementHighlightByLegendOptions {\n type: 'element-highlight-by-legend';\n}\n\nexport interface ElementHighlightByNameSpec extends ElementHighlightByNameOptions {\n type: 'element-highlight-by-name';\n}\n\nexport interface BrushHighlightSpec extends BrushHighlightOptions {\n type: 'brush-highlight';\n}\n\nexport interface BrushActiveSpec extends BrushActiveOptions {\n type: 'brush-active';\n}\n\nexport interface BrushFilterSpec extends BrushFilterOptions {\n type: 'brush-filter';\n}\n\nexport interface LegendFilterSpec extends DataFilterOptions {\n type: 'legend-filter';\n}\n\nexport interface DatazoomFilterSpec extends DataFilterOptions {\n type: 'datazoom-filter';\n}\n\nexport interface SliderFilterSpec extends DataFilterOptions {\n type: 'slider-filter';\n}\n\nexport interface PlayerFilterSpec extends DataFilterOptions {\n type: 'player-filter';\n}\n\nexport interface ScrollbarFilterSpec extends DataFilterOptions {\n type: 'scrollbar-filter';\n}\n\nexport interface DrillDownSpec extends DrillDownOptions {\n type: 'drill-down';\n}\n\nexport interface RollUpSpec extends RollUpOptions {\n type: 'roll-up';\n}\n\nexport interface TooltipSpec extends TooltipOptions {\n type: 'tooltip';\n}\n\nexport interface DimensionTooltipSpec extends DimensionTooltipOptions {\n type: 'dimension-tooltip';\n}\n\nexport interface CrosshairSpec extends CrosshairOptions {\n type: 'crosshair';\n}\nexport interface ViewRoamSpec extends ViewRoamOptions {\n type: 'view-roam';\n}\n\nexport interface ViewZoomSpec extends ViewZoomOptions {\n type: 'view-zoom';\n}\n\nexport interface ViewScrollSpec extends ViewScrollOptions {\n type: 'view-scroll';\n}\n\nexport interface ViewDragSpec extends ViewDragOptions {\n type: 'view-drag';\n}\n\nexport interface SankeyHighlightSpec extends SankeyHighlightOptions {\n type: 'sankey-highlight';\n}\n\nexport interface FishEyeSpec extends FishEyeOptions {\n type: 'fish-eye';\n}\n\nexport interface CustomizedInteractionSpec extends IBaseInteractionOptions {\n type: string;\n}\n\nexport type InteractionSpec =\n | ElementActiveSpec\n | ElementSelectSpec\n | ElementHighlightSpec\n | ElementHighlightByKeySpec\n | ElementHighlightByGroupSpec\n | ElementActiveByLegendSpec\n | ElementHighlightByLegendSpec\n | ElementHighlightByNameSpec\n | BrushHighlightSpec\n | BrushActiveSpec\n | BrushFilterSpec\n | LegendFilterSpec\n | DatazoomFilterSpec\n | SliderFilterSpec\n | PlayerFilterSpec\n | ScrollbarFilterSpec\n | DrillDownSpec\n | RollUpSpec\n | TooltipSpec\n | DimensionTooltipSpec\n | CrosshairSpec\n | ViewRoamSpec\n | ViewZoomSpec\n | ViewScrollSpec\n | ViewDragSpec\n | SankeyHighlightSpec\n | FishEyeSpec\n | CustomizedInteractionSpec;\n\nexport interface ViewNavigationRange {\n needUpdate?: boolean;\n x?: [number, number];\n y?: [number, number];\n}\n\nexport interface IViewZoomMixin {\n updateZoomRange: (\n rangeFactor: [number, number],\n range: [number, number],\n zoomEvent: { zoomDelta: number; zoomX: number; zoomY: number },\n zoomOptions?: ViewZoomSimpleOptions\n ) => [number, number];\n formatZoomEvent: (e: InteractionEvent) => InteractionEvent & { zoomDelta?: number; zoomX?: number; zoomY?: number };\n handleZoomStart: (\n e: InteractionEvent,\n navState: Partial<Record<'x' | 'y', ViewStateByDim>>,\n zoomOptions?: ViewZoomSimpleOptions\n ) => ViewNavigationRange;\n handleZoomEnd: (\n e: InteractionEvent,\n navState: Partial<Record<'x' | 'y', ViewStateByDim>>,\n zoomOptions?: ViewZoomSimpleOptions\n ) => ViewNavigationRange;\n handleZoomReset: (\n e: InteractionEvent,\n navState: Partial<Record<'x' | 'y', ViewStateByDim>>,\n zoomOptions?: ViewZoomSimpleOptions\n ) => ViewNavigationRange;\n}\n\nexport interface IViewScrollMixin {\n formatScrollEvent: (e: InteractionEvent) => InteractionEvent & { scrollX?: number; scrollY?: number };\n handleScrollStart: (\n e: InteractionEvent,\n navState: Partial<Record<'x' | 'y', ViewStateByDim>>,\n scrollOptions?: ViewScrollSimpleOptions\n ) => ViewNavigationRange;\n handleScrollEnd: (\n e: InteractionEvent,\n navState: Partial<Record<'x' | 'y', ViewStateByDim>>,\n scrollOptions?: ViewScrollSimpleOptions\n ) => ViewNavigationRange;\n}\n\nexport interface IViewDragMixin {\n handleDragStart: (\n e: InteractionEvent,\n navState: Partial<Record<'x' | 'y', ViewStateByDim>>,\n dragOptions?: ViewDragSimpleOptions\n ) => ViewNavigationRange;\n handleDragUpdate: (\n e: InteractionEvent,\n navState: Partial<Record<'x' | 'y', ViewStateByDim>>,\n dragOptions?: ViewDragSimpleOptions\n ) => ViewNavigationRange;\n handleDragEnd: (\n e: InteractionEvent,\n navState: Partial<Record<'x' | 'y', ViewStateByDim>>,\n dragOptions?: ViewDragSimpleOptions\n ) => ViewNavigationRange;\n}\n\nexport interface IToggleStateMixin {\n updateStates: (\n newStatedElements: (IElement | IGlyphElement)[],\n prevStatedElements?: (IElement | IGlyphElement)[],\n state?: string,\n reverseState?: string\n ) => (IElement | IGlyphElement)[];\n clearAllStates: (state?: string, reverseState?: string) => void;\n}\n\nexport interface ViewStateByDim {\n scale?: IScale;\n data?: IData;\n linkedComponent?: IDatazoom | IScrollbar;\n filterValue?: any[];\n wholeScale?: IBaseScale;\n initRangeFactor?: [number, number];\n getCurrentRange?: () => [number, number];\n rangeFactor?: [number, number];\n}\n"]}
|
package/cjs/view/View.js
CHANGED
|
@@ -692,8 +692,8 @@ class View extends vutils_1.EventEmitter {
|
|
|
692
692
|
release() {
|
|
693
693
|
var _a, _b, _c;
|
|
694
694
|
this.removeAllInteractions(), this.releaseStageEvent(), this._unBindResizeEvent(),
|
|
695
|
-
this.clearProgressive(), factory_1.Factory.unregisterRuntimeTransforms(),
|
|
696
|
-
this.grammars.release(), this._cachedGrammars.release(), this._dataflow.release(),
|
|
695
|
+
this.clearProgressive(), factory_1.Factory.unregisterRuntimeTransforms(), vutils_1.Logger.setInstance(null),
|
|
696
|
+
this.animate.stop(), this.grammars.release(), this._cachedGrammars.release(), this._dataflow.release(),
|
|
697
697
|
this._dataflow = null, null === (_b = null === (_a = this.renderer) || void 0 === _a ? void 0 : _a.release) || void 0 === _b || _b.call(_a),
|
|
698
698
|
this.renderer = null, this._boundInteractions = null, this.removeAllListeners(),
|
|
699
699
|
null === (_c = this._eventListeners) || void 0 === _c || _c.forEach((listener => {
|