@visactor/vgrammar-core 0.11.0-alpha.1 → 0.11.1
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/component/label.js.map +1 -1
- package/cjs/graph/attributes/line.d.ts +2 -0
- package/cjs/graph/attributes/line.js +38 -5
- package/cjs/graph/attributes/line.js.map +1 -1
- package/cjs/graph/element.js +15 -6
- package/cjs/graph/element.js.map +1 -1
- package/cjs/graph/enums.d.ts +2 -1
- package/cjs/graph/enums.js +1 -1
- package/cjs/graph/enums.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-highlight.d.ts +5 -2
- package/cjs/interactions/element-highlight.js +8 -23
- package/cjs/interactions/element-highlight.js.map +1 -1
- package/cjs/interactions/element-select.d.ts +6 -3
- package/cjs/interactions/element-select.js +20 -28
- package/cjs/interactions/element-select.js.map +1 -1
- package/cjs/interactions/filter.js +1 -1
- package/cjs/interactions/filter.js.map +1 -1
- package/cjs/interactions/fish-eye.js +1 -1
- package/cjs/interactions/fish-eye.js.map +1 -1
- package/cjs/interactions/index.js +4 -0
- package/cjs/interactions/index.js.map +1 -1
- package/cjs/interactions/toggle-state-mixin.d.ts +8 -0
- package/cjs/interactions/toggle-state-mixin.js +30 -0
- package/cjs/interactions/toggle-state-mixin.js.map +1 -0
- package/cjs/interactions/utils.d.ts +2 -1
- package/cjs/interactions/utils.js +15 -2
- package/cjs/interactions/utils.js.map +1 -1
- package/cjs/interactions/view-navigation-base.js +1 -1
- package/cjs/interactions/view-navigation-base.js.map +1 -1
- package/cjs/transforms/data/sampling.js.map +1 -1
- package/cjs/types/dataflow.d.ts +1 -2
- package/cjs/types/dataflow.js.map +1 -1
- package/cjs/types/grammar.d.ts +1 -1
- package/cjs/types/grammar.js.map +1 -1
- package/cjs/types/interaction.d.ts +4 -0
- package/cjs/types/interaction.js.map +1 -1
- package/cjs/types/mark.d.ts +1 -1
- package/cjs/types/mark.js.map +1 -1
- package/cjs/types/plot.d.ts +0 -1
- package/cjs/types/plot.js.map +1 -1
- package/cjs/types/transform.d.ts +1 -1
- package/cjs/types/transform.js.map +1 -1
- package/cjs/types/view.d.ts +2 -5
- package/cjs/types/view.js.map +1 -1
- package/cjs/util/data.d.ts +0 -1
- package/cjs/util/data.js +1 -37
- package/cjs/util/data.js.map +1 -1
- package/cjs/view/View.d.ts +2 -10
- package/cjs/view/View.js +15 -99
- package/cjs/view/View.js.map +1 -1
- package/cjs/view/data.d.ts +1 -2
- package/cjs/view/data.js +7 -49
- package/cjs/view/data.js.map +1 -1
- package/cjs/view/dataflow.d.ts +1 -6
- package/cjs/view/dataflow.js +7 -72
- package/cjs/view/dataflow.js.map +1 -1
- package/cjs/view/grammar-base.d.ts +3 -6
- package/cjs/view/grammar-base.js +0 -46
- package/cjs/view/grammar-base.js.map +1 -1
- package/cjs/view/mark.d.ts +1 -2
- package/cjs/view/mark.js +9 -38
- package/cjs/view/mark.js.map +1 -1
- package/es/component/label.js.map +1 -1
- package/es/graph/attributes/line.d.ts +2 -0
- package/es/graph/attributes/line.js +34 -5
- package/es/graph/attributes/line.js.map +1 -1
- package/es/graph/element.js +17 -8
- package/es/graph/element.js.map +1 -1
- package/es/graph/enums.d.ts +2 -1
- package/es/graph/enums.js +1 -1
- package/es/graph/enums.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/element-highlight.d.ts +5 -2
- package/es/interactions/element-highlight.js +9 -22
- package/es/interactions/element-highlight.js.map +1 -1
- package/es/interactions/element-select.d.ts +6 -3
- package/es/interactions/element-select.js +21 -27
- package/es/interactions/element-select.js.map +1 -1
- package/es/interactions/filter.js +1 -1
- package/es/interactions/filter.js.map +1 -1
- package/es/interactions/fish-eye.js +1 -1
- package/es/interactions/fish-eye.js.map +1 -1
- package/es/interactions/index.js +4 -2
- package/es/interactions/index.js.map +1 -1
- package/es/interactions/toggle-state-mixin.d.ts +8 -0
- package/es/interactions/toggle-state-mixin.js +22 -0
- package/es/interactions/toggle-state-mixin.js.map +1 -0
- package/es/interactions/utils.d.ts +2 -1
- package/es/interactions/utils.js +11 -0
- package/es/interactions/utils.js.map +1 -1
- package/es/interactions/view-navigation-base.js +1 -1
- package/es/interactions/view-navigation-base.js.map +1 -1
- package/es/transforms/data/sampling.js.map +1 -1
- package/es/types/dataflow.d.ts +1 -2
- package/es/types/dataflow.js.map +1 -1
- package/es/types/grammar.d.ts +1 -1
- package/es/types/grammar.js.map +1 -1
- package/es/types/interaction.d.ts +4 -0
- package/es/types/interaction.js.map +1 -1
- package/es/types/mark.d.ts +1 -1
- package/es/types/mark.js.map +1 -1
- package/es/types/plot.d.ts +0 -1
- package/es/types/plot.js.map +1 -1
- package/es/types/transform.d.ts +1 -1
- package/es/types/transform.js.map +1 -1
- package/es/types/view.d.ts +2 -5
- package/es/types/view.js.map +1 -1
- package/es/util/data.d.ts +0 -1
- package/es/util/data.js +0 -34
- package/es/util/data.js.map +1 -1
- package/es/view/View.d.ts +2 -10
- package/es/view/View.js +14 -99
- package/es/view/View.js.map +1 -1
- package/es/view/data.d.ts +1 -2
- package/es/view/data.js +8 -49
- package/es/view/data.js.map +1 -1
- package/es/view/dataflow.d.ts +1 -6
- package/es/view/dataflow.js +7 -72
- package/es/view/dataflow.js.map +1 -1
- package/es/view/grammar-base.d.ts +3 -6
- package/es/view/grammar-base.js +0 -45
- package/es/view/grammar-base.js.map +1 -1
- package/es/view/mark.d.ts +1 -2
- package/es/view/mark.js +8 -39
- package/es/view/mark.js.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interactions/filter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAW5C,MAAM,OAAO,WAAW;IACtB,W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C,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;SAC1G;IACH,CAAC;;AARM,qBAAc,GAAsC,EAAE,CAAC","file":"filter.js","sourcesContent":["import type { DataFilterOptions, IData, IDataFilter, IMark, IView, InteractionEvent } from '../types';\nimport { BaseInteraction } from './base';\nimport { isString } from '@visactor/vutils';\n\nexport interface FilterMixin {\n view: IView;\n _data?: IData;\n _marks?: IMark[];\n _filterValue: any;\n _dataFilter: IDataFilter;\n handleFilter: (event?: InteractionEvent) => void;\n}\n\nexport class FilterMixin {\n _filterData(\n data: IData,\n source: IMark | null,\n filterRank: number,\n getFilterValue: (event: any) => any,\n filter?: (data: any[], parameters: any) => boolean,\n transform?: (data: any[], parameters: any) => any[]\n ) {\n const dataGrammar = isString(data) ? this.view.getDataById(data) : data;\n if (dataGrammar) {\n this.handleFilter = (event: InteractionEvent) => {\n const element = event?.element;\n if (!dataGrammar || (source && (!element || element.mark !== source))) {\n return;\n }\n if (getFilterValue) {\n this._filterValue = getFilterValue(event);\n }\n dataGrammar.commit();\n this.view.run();\n };\n\n this._dataFilter = {\n source: source ? `${source.uid}` : null,\n rank: filterRank,\n filter: (data: any[]) => {\n if (!this._filterValue) {\n return data;\n }\n const filteredData = filter ? data.filter(datum => filter(datum, this._filterValue)) : data;\n return transform ? transform(filteredData, this._filterValue) : filteredData;\n }\n };\n dataGrammar.addDataFilter(this._dataFilter);\n }\n return this;\n }\n}\n\nexport interface Filter\n extends Pick<FilterMixin, '_data' | '_marks' | '_filterValue' | '_dataFilter' | 'handleFilter' | '_filterData'>,\n BaseInteraction<DataFilterOptions> {}\n\nexport abstract class Filter extends BaseInteraction<DataFilterOptions> {\n static defaultOptions: Omit<DataFilterOptions, 'target'> = {};\n options: DataFilterOptions;\n\n constructor(view: IView, options?: DataFilterOptions) {\n super(view, options);\n if (options.target) {\n this._data = isString(options.target.data) ? view.getDataById(options.target.data) : options.target.data;\n }\n }\n}\n"]}
|
|
@@ -69,7 +69,7 @@ export class FishEye extends BaseInteraction {
|
|
|
69
69
|
const dimState = this._state[dim];
|
|
70
70
|
dimState.scale && !isNil(dimState.focus) && (needUpdate = !0, dimState.focus = null,
|
|
71
71
|
dimState.scale.setFishEye(null), dimState.scale.commit());
|
|
72
|
-
})), needUpdate && this.view.
|
|
72
|
+
})), needUpdate && this.view.run();
|
|
73
73
|
}
|
|
74
74
|
shouldHandle(e) {
|
|
75
75
|
var _a, _b, _c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interactions/fish-eye.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,MAAM,OAAO,OAAQ,SAAQ,eAA+B;IAuB1D,YAAY,IAAW,EAAE,OAAwB;QAC/C,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAtBvB,SAAI,GAAW,OAAO,CAAC,IAAI,CAAC;QAyH5B,gBAAW,GAAG,CAAC,CAAmB,EAAE,EAAE;YACpC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE;gBAC1F,OAAO;aACR;YAED,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,IAAI,CAAC,aAAa,EAAE,CAAC;aACtB;YACD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;gBACnB,IAAI,CAAC,SAAS,GAAG,IAAI,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, IView, InteractionEvent, ViewNavigationRange } from '../types';\nimport { BaseInteraction } from './base';\n\nexport class FishEye extends BaseInteraction<FishEyeOptions> {\n static type: string = 'fish-eye';\n type: string = FishEye.type;\n\n static defaultOptions: FishEyeOptions = {\n trigger: 'pointerenter',\n updateTrigger: 'pointermove',\n endTrigger: 'pointerleave',\n distortionX: 2,\n distortionY: 2,\n throttle: 100\n };\n\n options: FishEyeOptions;\n protected _inited?: boolean;\n protected _state: Partial<\n Record<'x' | 'y', { scale?: IScale; focus?: number; distortion?: number; radius?: number; radiusRatio?: number }>\n >;\n protected _isActive?: boolean;\n protected _marks?: IMark[];\n\n protected handleUpdate: (e: InteractionEvent) => void;\n\n constructor(view: IView, options?: FishEyeOptions) {\n super(view, options);\n this.options = Object.assign({}, FishEye.defaultOptions, options);\n this._marks = view.getMarksBySelector(this.options.selector);\n\n this.handleUpdate = throttle(this.handleUpdateInner, this.options.throttle);\n }\n\n protected getEvents() {\n return [\n { type: this.options.trigger, handler: this.handleStart },\n { type: this.options.updateTrigger, handler: this.handleUpdate },\n { type: this.options.endTrigger, handler: this.handleEnd },\n { type: this.options.triggerOff, handler: this.handleReset }\n ];\n }\n\n protected _initStateByDim(\n dim: 'x' | 'y',\n distortion: number,\n scale?: string | IScale,\n radius?: number,\n radiusRatio?: number\n ) {\n const scaleGrammar = !isNil(scale) ? (isString(scale) ? this.view.getScaleById(scale) : scale) : null;\n\n this._state[dim] = { scale: scaleGrammar, distortion, radius, radiusRatio };\n }\n\n protected _initGrammars() {\n const { enableX, enableY, scaleX, scaleY, distortionX, distortionY, radiusRatioX, radiusRatioY, radiusX, radiusY } =\n this.options;\n\n this._state = {};\n\n if (enableX !== false) {\n this._initStateByDim('x', distortionX, scaleX, radiusX, radiusRatioX);\n }\n\n if (enableY !== false) {\n this._initStateByDim('y', distortionY, scaleY, radiusY, radiusRatioY);\n }\n\n this._inited = true;\n }\n\n updateView(focus?: { x: number; y: number }, e?: InteractionEvent) {\n let needUpdate = false;\n\n if (focus) {\n Object.keys(this._state).forEach(dim => {\n const dimState = this._state[dim];\n\n if (dimState.scale && dimState.focus !== focus[dim]) {\n needUpdate = true;\n // 坐标转换问题\n dimState.focus = focus[dim];\n dimState.scale.setFishEye({\n distortion: dimState.distortion,\n radius: dimState.radius,\n radiusRatio: dimState.radiusRatio,\n focus: focus[dim]\n });\n dimState.scale.commit();\n }\n });\n } else {\n Object.keys(this._state).forEach(dim => {\n const dimState = this._state[dim];\n\n if (dimState.scale && !isNil(dimState.focus)) {\n needUpdate = true;\n // 坐标转换问题\n dimState.focus = null;\n dimState.scale.setFishEye(null);\n dimState.scale.commit();\n }\n });\n }\n\n if (needUpdate) {\n this.view.runSync();\n }\n }\n\n shouldHandle(e: InteractionEvent) {\n if (this._marks) {\n return e.element && this._marks && this._marks.includes(e.element.mark);\n }\n return (e.target as any) === this.view?.renderer?.stage?.();\n }\n\n shouldUpdate(e: InteractionEvent) {\n if (this._marks) {\n return e.element && this._marks && this._marks.includes(e.element.mark);\n }\n const viewBox = this.view.getViewBox();\n return e.canvasX >= viewBox.x1 && e.canvasX <= viewBox.x2 && e.canvasY >= viewBox.y1 && e.canvasY <= viewBox.y2;\n }\n\n handleStart = (e: InteractionEvent) => {\n if (!e || !(this.options.shouldStart ? this.options.shouldStart(e) : this.shouldHandle(e))) {\n return;\n }\n\n if (!this._inited) {\n this._initGrammars();\n }\n if (!this._isActive) {\n this._isActive = true;\n this.updateView({ x: e.canvasX, y: e.canvasY }, e);\n }\n };\n\n handleUpdateInner = (e: InteractionEvent) => {\n if (!e || !(this.options.shouldUpdate ? this.options.shouldUpdate(e) : this.shouldUpdate(e))) {\n return;\n }\n\n this._isActive && this.updateView({ x: e.canvasX, y: e.canvasY }, e);\n };\n\n handleEnd = (e: InteractionEvent) => {\n if (!e || !(this.options.shouldEnd ? this.options.shouldEnd(e) : this.shouldHandle(e))) {\n return;\n }\n\n if (!this.options.triggerOff && this._isActive) {\n this._isActive = false;\n this.updateView(null, e);\n }\n };\n\n handleReset = (e: InteractionEvent) => {\n if (!e || !(this.options.shouldReset ? this.options.shouldReset(e) : this.shouldHandle(e))) {\n return;\n }\n\n if (this._isActive) {\n this.updateView(null, e);\n this._isActive = false;\n }\n };\n\n unbind() {\n super.unbind();\n\n if (this._state) {\n Object.keys(this._state).forEach(dim => {\n const { scale } = this._state[dim as 'x' | 'y'];\n\n if (scale) {\n scale.setRangeFactor(null);\n scale.commit();\n }\n });\n }\n\n this._state = null;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/interactions/fish-eye.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,MAAM,OAAO,OAAQ,SAAQ,eAA+B;IAuB1D,YAAY,IAAW,EAAE,OAAwB;QAC/C,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAtBvB,SAAI,GAAW,OAAO,CAAC,IAAI,CAAC;QAyH5B,gBAAW,GAAG,CAAC,CAAmB,EAAE,EAAE;YACpC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE;gBAC1F,OAAO;aACR;YAED,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,IAAI,CAAC,aAAa,EAAE,CAAC;aACtB;YACD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;gBACnB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBACtB,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;aAC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C,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACzE;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;QACvC,OAAO,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,EAAE,CAAC;IAClH,CAAC;IA8CD,MAAM;QACJ,KAAK,CAAC,MAAM,EAAE,CAAC;QAEf,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBACrC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,GAAgB,CAAC,CAAC;gBAEhD,IAAI,KAAK,EAAE;oBACT,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;oBAC3B,KAAK,CAAC,MAAM,EAAE,CAAC;iBAChB;YACH,CAAC,CAAC,CAAC;SACJ;QAED,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;;AArLM,YAAI,GAAW,UAAU,CAAC;AAG1B,sBAAc,GAAmB;IACtC,OAAO,EAAE,cAAc;IACvB,aAAa,EAAE,aAAa;IAC5B,UAAU,EAAE,cAAc;IAC1B,WAAW,EAAE,CAAC;IACd,WAAW,EAAE,CAAC;IACd,QAAQ,EAAE,GAAG;CACd,CAAC","file":"fish-eye.js","sourcesContent":["import { isNil, isString, throttle } from '@visactor/vutils';\nimport type { FishEyeOptions, IMark, IScale, IView, InteractionEvent, ViewNavigationRange } from '../types';\nimport { BaseInteraction } from './base';\n\nexport class FishEye extends BaseInteraction<FishEyeOptions> {\n static type: string = 'fish-eye';\n type: string = FishEye.type;\n\n static defaultOptions: FishEyeOptions = {\n trigger: 'pointerenter',\n updateTrigger: 'pointermove',\n endTrigger: 'pointerleave',\n distortionX: 2,\n distortionY: 2,\n throttle: 100\n };\n\n options: FishEyeOptions;\n protected _inited?: boolean;\n protected _state: Partial<\n Record<'x' | 'y', { scale?: IScale; focus?: number; distortion?: number; radius?: number; radiusRatio?: number }>\n >;\n protected _isActive?: boolean;\n protected _marks?: IMark[];\n\n protected handleUpdate: (e: InteractionEvent) => void;\n\n constructor(view: IView, options?: FishEyeOptions) {\n super(view, options);\n this.options = Object.assign({}, FishEye.defaultOptions, options);\n this._marks = view.getMarksBySelector(this.options.selector);\n\n this.handleUpdate = throttle(this.handleUpdateInner, this.options.throttle);\n }\n\n protected getEvents() {\n return [\n { type: this.options.trigger, handler: this.handleStart },\n { type: this.options.updateTrigger, handler: this.handleUpdate },\n { type: this.options.endTrigger, handler: this.handleEnd },\n { type: this.options.triggerOff, handler: this.handleReset }\n ];\n }\n\n protected _initStateByDim(\n dim: 'x' | 'y',\n distortion: number,\n scale?: string | IScale,\n radius?: number,\n radiusRatio?: number\n ) {\n const scaleGrammar = !isNil(scale) ? (isString(scale) ? this.view.getScaleById(scale) : scale) : null;\n\n this._state[dim] = { scale: scaleGrammar, distortion, radius, radiusRatio };\n }\n\n protected _initGrammars() {\n const { enableX, enableY, scaleX, scaleY, distortionX, distortionY, radiusRatioX, radiusRatioY, radiusX, radiusY } =\n this.options;\n\n this._state = {};\n\n if (enableX !== false) {\n this._initStateByDim('x', distortionX, scaleX, radiusX, radiusRatioX);\n }\n\n if (enableY !== false) {\n this._initStateByDim('y', distortionY, scaleY, radiusY, radiusRatioY);\n }\n\n this._inited = true;\n }\n\n updateView(focus?: { x: number; y: number }, e?: InteractionEvent) {\n let needUpdate = false;\n\n if (focus) {\n Object.keys(this._state).forEach(dim => {\n const dimState = this._state[dim];\n\n if (dimState.scale && dimState.focus !== focus[dim]) {\n needUpdate = true;\n // 坐标转换问题\n dimState.focus = focus[dim];\n dimState.scale.setFishEye({\n distortion: dimState.distortion,\n radius: dimState.radius,\n radiusRatio: dimState.radiusRatio,\n focus: focus[dim]\n });\n dimState.scale.commit();\n }\n });\n } else {\n Object.keys(this._state).forEach(dim => {\n const dimState = this._state[dim];\n\n if (dimState.scale && !isNil(dimState.focus)) {\n needUpdate = true;\n // 坐标转换问题\n dimState.focus = null;\n dimState.scale.setFishEye(null);\n dimState.scale.commit();\n }\n });\n }\n\n if (needUpdate) {\n this.view.run();\n }\n }\n\n shouldHandle(e: InteractionEvent) {\n if (this._marks) {\n return e.element && this._marks && this._marks.includes(e.element.mark);\n }\n return (e.target as any) === this.view?.renderer?.stage?.();\n }\n\n shouldUpdate(e: InteractionEvent) {\n if (this._marks) {\n return e.element && this._marks && this._marks.includes(e.element.mark);\n }\n const viewBox = this.view.getViewBox();\n return e.canvasX >= viewBox.x1 && e.canvasX <= viewBox.x2 && e.canvasY >= viewBox.y1 && e.canvasY <= viewBox.y2;\n }\n\n handleStart = (e: InteractionEvent) => {\n if (!e || !(this.options.shouldStart ? this.options.shouldStart(e) : this.shouldHandle(e))) {\n return;\n }\n\n if (!this._inited) {\n this._initGrammars();\n }\n if (!this._isActive) {\n this._isActive = true;\n this.updateView({ x: e.canvasX, y: e.canvasY }, e);\n }\n };\n\n handleUpdateInner = (e: InteractionEvent) => {\n if (!e || !(this.options.shouldUpdate ? this.options.shouldUpdate(e) : this.shouldUpdate(e))) {\n return;\n }\n\n this._isActive && this.updateView({ x: e.canvasX, y: e.canvasY }, e);\n };\n\n handleEnd = (e: InteractionEvent) => {\n if (!e || !(this.options.shouldEnd ? this.options.shouldEnd(e) : this.shouldHandle(e))) {\n return;\n }\n\n if (!this.options.triggerOff && this._isActive) {\n this._isActive = false;\n this.updateView(null, e);\n }\n };\n\n handleReset = (e: InteractionEvent) => {\n if (!e || !(this.options.shouldReset ? this.options.shouldReset(e) : this.shouldHandle(e))) {\n return;\n }\n\n if (this._isActive) {\n this.updateView(null, e);\n this._isActive = false;\n }\n };\n\n unbind() {\n super.unbind();\n\n if (this._state) {\n Object.keys(this._state).forEach(dim => {\n const { scale } = this._state[dim as 'x' | 'y'];\n\n if (scale) {\n scale.setRangeFactor(null);\n scale.commit();\n }\n });\n }\n\n this._state = null;\n }\n}\n"]}
|
package/es/interactions/index.js
CHANGED
|
@@ -52,6 +52,8 @@ import { ViewRoam } from "./view-roam";
|
|
|
52
52
|
|
|
53
53
|
import { FishEye } from "./fish-eye";
|
|
54
54
|
|
|
55
|
+
import { ToggleStateMixin } from "./toggle-state-mixin";
|
|
56
|
+
|
|
55
57
|
export { BaseTooltip } from "./base-tooltip";
|
|
56
58
|
|
|
57
59
|
export { BaseInteraction } from "./base";
|
|
@@ -67,11 +69,11 @@ export const registerElementActive = () => {
|
|
|
67
69
|
};
|
|
68
70
|
|
|
69
71
|
export const registerElementSelect = () => {
|
|
70
|
-
Factory.registerInteraction(ElementSelect.type, ElementSelect);
|
|
72
|
+
mixin(ElementSelect, ToggleStateMixin), Factory.registerInteraction(ElementSelect.type, ElementSelect);
|
|
71
73
|
};
|
|
72
74
|
|
|
73
75
|
export const registerElementHighlight = () => {
|
|
74
|
-
Factory.registerInteraction(ElementHighlight.type, ElementHighlight);
|
|
76
|
+
mixin(ElementHighlight, ToggleStateMixin), Factory.registerInteraction(ElementHighlight.type, ElementHighlight);
|
|
75
77
|
};
|
|
76
78
|
|
|
77
79
|
export const registerElementHighlightByKey = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interactions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,uBAAu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AC;AACvD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,KAAK,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IAC/B,KAAK,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IAC/B,KAAK,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IACjC,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC,CAAC","file":"index.js","sourcesContent":["import { Factory } from '../core/factory';\nimport { ElementActive } from './element-active';\nimport { ElementSelect } from './element-select';\nimport { ElementHighlight } from './element-highlight';\nimport { ElementHighlightByKey } from './element-highlight-by-key';\nimport { ElementHighlightByGroup } from './element-highlight-by-group';\nimport { ElementActiveByLegend } from './element-active-by-legend';\nimport { ElementHighlightByLegend } from './element-highlight-by-legend';\nimport { ElementHighlightByName } from './element-highlight-by-name';\nimport { BrushHighlight } from './brush-highlight';\nimport { BrushActive } from './brush-active';\nimport { BrushFilter } from './brush-filter';\nimport { DrillDown } from './drill-down';\nimport { RollUp } from './roll-up';\nimport { Tooltip } from './tooltip';\nimport { DimensionTooltip } from './dimension-tooltip';\nimport { Crosshair } from './crosshair';\nimport { FilterMixin } from './filter';\nimport { ViewZoom } from './view-zoom';\nimport { ViewScroll } from './view-scroll';\nimport { ViewDrag } from './view-drag';\nimport { mixin } from '@visactor/vutils';\nimport { ViewZoomMixin } from './view-zoom-mixin';\nimport { ViewScrollMixin } from './view-scroll-mixin';\nimport { ViewDragMixin } from './view-drag-mixin';\nimport { ViewRoam } from './view-roam';\nimport { FishEye } from './fish-eye';\nimport { ToggleStateMixin } from './toggle-state-mixin';\n\nexport { BaseTooltip } from './base-tooltip';\nexport { BaseInteraction } from './base';\nexport { BrushBase } from './brush-base';\nexport { ViewNavigationBase } from './view-navigation-base';\nexport {\n ElementActive,\n ElementSelect,\n ElementHighlight,\n ElementHighlightByKey,\n ElementHighlightByGroup,\n ElementActiveByLegend,\n ElementHighlightByLegend,\n ElementHighlightByName,\n BrushHighlight,\n BrushActive,\n DrillDown,\n RollUp,\n Tooltip,\n DimensionTooltip,\n Crosshair,\n FilterMixin,\n ViewZoom,\n ViewScroll,\n ViewDrag,\n ViewRoam,\n ViewScrollMixin,\n ViewZoomMixin,\n ViewDragMixin,\n FishEye\n};\n\nexport const registerElementActive = () => {\n Factory.registerInteraction(ElementActive.type, ElementActive);\n};\n\nexport const registerElementSelect = () => {\n mixin(ElementSelect, ToggleStateMixin);\n Factory.registerInteraction(ElementSelect.type, ElementSelect);\n};\n\nexport const registerElementHighlight = () => {\n mixin(ElementHighlight, ToggleStateMixin);\n Factory.registerInteraction(ElementHighlight.type, ElementHighlight);\n};\n\nexport const registerElementHighlightByKey = () => {\n Factory.registerInteraction(ElementHighlightByKey.type, ElementHighlightByKey);\n};\n\nexport const registerElementHighlightByGroup = () => {\n Factory.registerInteraction(ElementHighlightByGroup.type, ElementHighlightByGroup);\n};\n\nexport const registerElementActiveByLegend = () => {\n Factory.registerInteraction(ElementActiveByLegend.type, ElementActiveByLegend);\n};\n\nexport const registerElementHighlightByLegend = () => {\n Factory.registerInteraction(ElementHighlightByLegend.type, ElementHighlightByLegend);\n};\n\nexport const registerElementHighlightByName = () => {\n Factory.registerInteraction(ElementHighlightByName.type, ElementHighlightByName);\n};\n\nexport const registerBrushHighlight = () => {\n Factory.registerInteraction(BrushHighlight.type, BrushHighlight);\n};\n\nexport const registerBrushActive = () => {\n Factory.registerInteraction(BrushActive.type, BrushActive);\n};\n\nexport const registerBrushFilter = () => {\n mixin(BrushFilter, FilterMixin);\n Factory.registerInteraction(BrushFilter.type, BrushFilter);\n};\n\nexport const registerDrillDown = () => {\n mixin(DrillDown, FilterMixin);\n Factory.registerInteraction(DrillDown.type, DrillDown);\n};\n\nexport const registerRollUp = () => {\n Factory.registerInteraction(RollUp.type, RollUp);\n};\n\nexport const registerTooltip = () => {\n Factory.registerInteraction(Tooltip.type, Tooltip);\n};\n\nexport const registerDimensionTooltip = () => {\n Factory.registerInteraction(DimensionTooltip.type, DimensionTooltip);\n};\n\nexport const registerCrosshair = () => {\n Factory.registerInteraction(Crosshair.type, Crosshair);\n};\nexport const registerViewZoom = () => {\n mixin(ViewZoom, ViewZoomMixin);\n Factory.registerInteraction(ViewZoom.type, ViewZoom);\n};\n\nexport const registerViewScroll = () => {\n mixin(ViewScroll, ViewScrollMixin);\n Factory.registerInteraction(ViewScroll.type, ViewScroll);\n};\n\nexport const registerViewDrag = () => {\n mixin(ViewDrag, ViewDragMixin);\n Factory.registerInteraction(ViewDrag.type, ViewDrag);\n};\n\nexport const registerViewRoam = () => {\n mixin(ViewRoam, ViewZoomMixin);\n mixin(ViewRoam, ViewDragMixin);\n mixin(ViewRoam, ViewScrollMixin);\n Factory.registerInteraction(ViewRoam.type, ViewRoam);\n};\n\nexport const registerFishEye = () => {\n Factory.registerInteraction(FishEye.type, FishEye);\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IElement, IGlyphElement, IMark, IToggleStateMixin } from '../types';
|
|
2
|
+
export declare class ToggleStateMixin implements IToggleStateMixin {
|
|
3
|
+
protected _statedElements?: (IElement | IGlyphElement)[];
|
|
4
|
+
protected _marks?: IMark[];
|
|
5
|
+
protected _stateMarks: Record<string, IMark[]>;
|
|
6
|
+
updateStates(state?: string, reverseState?: string): void;
|
|
7
|
+
clearAllStates(state?: string, reverseState?: string): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class ToggleStateMixin {
|
|
2
|
+
updateStates(state, reverseState) {
|
|
3
|
+
this._marks.forEach((mark => {
|
|
4
|
+
const hasReverse = reverseState && this._stateMarks[reverseState] && this._stateMarks[reverseState].includes(mark), hasState = state && this._stateMarks[state] && this._stateMarks[state].includes(mark);
|
|
5
|
+
(hasReverse || hasState) && mark.elements.forEach((el => {
|
|
6
|
+
this._statedElements && this._statedElements.includes(el) ? (hasState && el.addState(state),
|
|
7
|
+
hasReverse && el.removeState(reverseState)) : (hasState && el.removeState(state),
|
|
8
|
+
hasReverse && el.addState(reverseState));
|
|
9
|
+
}));
|
|
10
|
+
}));
|
|
11
|
+
}
|
|
12
|
+
clearAllStates(state, reverseState) {
|
|
13
|
+
this._statedElements && this._statedElements.length && this._marks.forEach((mark => {
|
|
14
|
+
reverseState && this._stateMarks[reverseState] && this._stateMarks[reverseState].includes(mark) && mark.elements.forEach((el => {
|
|
15
|
+
el.removeState(reverseState);
|
|
16
|
+
})), state && this._stateMarks[state] && this._stateMarks[state].includes(mark) && mark.elements.forEach((el => {
|
|
17
|
+
el.removeState(state);
|
|
18
|
+
}));
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=toggle-state-mixin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/interactions/toggle-state-mixin.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,gBAAgB;IAK3B,YAAY,CAAC,KAAc,EAAE,YAAqB;QAChD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACzB,MAAM,UAAU,GACd,YAAY,IAAI,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAClG,MAAM,QAAQ,GAAG,KAAK,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAE5F,IAAI,CAAC,UAAU,IAAI,CAAC,QAAQ,EAAE;gBAC5B,OAA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IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;oBACzB,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;gBACxB,CAAC,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF","file":"toggle-state-mixin.js","sourcesContent":["import type { IElement, IGlyphElement, IMark, IToggleStateMixin } from '../types';\n\nexport class ToggleStateMixin implements IToggleStateMixin {\n protected _statedElements?: (IElement | IGlyphElement)[];\n protected _marks?: IMark[];\n protected _stateMarks: Record<string, IMark[]>;\n\n updateStates(state?: string, reverseState?: string) {\n this._marks.forEach(mark => {\n const hasReverse =\n reverseState && this._stateMarks[reverseState] && this._stateMarks[reverseState].includes(mark);\n const hasState = state && this._stateMarks[state] && this._stateMarks[state].includes(mark);\n\n if (!hasReverse && !hasState) {\n return;\n }\n\n mark.elements.forEach(el => {\n const isStated = this._statedElements && this._statedElements.includes(el);\n\n if (isStated) {\n if (hasState) {\n el.addState(state);\n }\n\n if (hasReverse) {\n el.removeState(reverseState);\n }\n } else {\n if (hasState) {\n el.removeState(state);\n }\n\n if (hasReverse) {\n el.addState(reverseState);\n }\n }\n });\n });\n }\n\n clearAllStates(state?: string, reverseState?: string) {\n if (!this._statedElements || !this._statedElements.length) {\n return;\n }\n\n this._marks.forEach(mark => {\n if (reverseState && this._stateMarks[reverseState] && this._stateMarks[reverseState].includes(mark)) {\n mark.elements.forEach(el => {\n el.removeState(reverseState);\n });\n }\n\n if (state && this._stateMarks[state] && this._stateMarks[state].includes(mark)) {\n mark.elements.forEach(el => {\n el.removeState(state);\n });\n }\n });\n }\n}\n"]}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type { ElementFilterOptions, IElement } from '../types';
|
|
1
|
+
import type { ElementFilterOptions, IElement, IMark } from '../types';
|
|
2
2
|
export declare const generateFilterValue: (options: ElementFilterOptions) => (el: IElement) => any;
|
|
3
|
+
export declare const groupMarksByState: (marks: IMark[], states: string[]) => Record<string, IMark[]>;
|
package/es/interactions/utils.js
CHANGED
|
@@ -2,4 +2,15 @@ export const generateFilterValue = options => options.filterField ? el => {
|
|
|
2
2
|
var _a;
|
|
3
3
|
return null === (_a = el.getDatum()) || void 0 === _a ? void 0 : _a[options.filterField];
|
|
4
4
|
} : el => el[options.filterType];
|
|
5
|
+
|
|
6
|
+
export const groupMarksByState = (marks, states) => {
|
|
7
|
+
if (!states || !marks) return null;
|
|
8
|
+
const res = {};
|
|
9
|
+
return marks.forEach((mark => {
|
|
10
|
+
const encode = mark.getSpec().encode;
|
|
11
|
+
encode && states.forEach((state => {
|
|
12
|
+
state && encode[state] && (res[state] || (res[state] = []), res[state].push(mark));
|
|
13
|
+
}));
|
|
14
|
+
})), res;
|
|
15
|
+
};
|
|
5
16
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interactions/utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,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","file":"utils.js","sourcesContent":["import type { ElementFilterOptions, IElement } 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"]}
|
|
1
|
+
{"version":3,"sources":["../src/interactions/utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,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;AAEF,MAAM,CAAC,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,MAAM,GAAI,IAAI,CAAC,OAAO,EAAe,CAAC,MAAM,CAAC;QAEnD,IAAI,CAAC,MAAM,EAAE;YACX,OAAO;SACR;QAED,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACrB,IAAI,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;gBAC1B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;oBACf,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;iBACjB;gBAED,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACvB;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC,CAAC","file":"utils.js","sourcesContent":["import type { ElementFilterOptions, 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 encode = (mark.getSpec() as 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"]}
|
|
@@ -59,7 +59,7 @@ export class ViewNavigationBase extends BaseInteraction {
|
|
|
59
59
|
var _a, _b, _c, _d;
|
|
60
60
|
newRange && newRange.x && (null === (_b = null === (_a = this._state) || void 0 === _a ? void 0 : _a.x) || void 0 === _b ? void 0 : _b.linkedComponent) && this._updateLinkedComponent(this._state.x.linkedComponent, newRange.x),
|
|
61
61
|
newRange && newRange.y && (null === (_d = null === (_c = this._state) || void 0 === _c ? void 0 : _c.y) || void 0 === _d ? void 0 : _d.linkedComponent) && this._updateLinkedComponent(this._state.y.linkedComponent, newRange.y),
|
|
62
|
-
newRange && newRange.needUpdate && this.view.
|
|
62
|
+
newRange && newRange.needUpdate && this.view.run(), this.dispatchEvent(type, {
|
|
63
63
|
viewRange: newRange,
|
|
64
64
|
event: e
|
|
65
65
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interactions/view-navigation-base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAgBnD,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,OAAgB,kBAEpB,SAAQ,eAAkB;IAQ1B,YAAY,IAAW,EAAE,OAAW;QAClC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrB,IAAI,CAA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CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;iBAC5E;qBAAM,IAAI,KAAK,EAAE;oBAChB,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;oBAC3B,KAAK,CAAC,MAAM,EAAE,CAAC;iBAChB;YACH,CAAC,CAAC,CAAC;SACJ;QAED,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;CACF","file":"view-navigation-base.js","sourcesContent":["import { isNil, isString } from '@visactor/vutils';\nimport type {\n FilterDataTarget,\n IBaseInteractionOptions,\n IComponent,\n IDataFilter,\n IDatazoom,\n IMark,\n IScale,\n IScrollbar,\n IView,\n InteractionEvent,\n ViewNavigationBaseOptions,\n ViewNavigationRange,\n ViewStateByDim\n} from '../types';\nimport { BaseInteraction } from './base';\nimport { ComponentEnum, DataFilterRank, GrammarMarkType } from '../graph/enums';\nimport { getScaleRangeRatio } from '../util/scale';\n\nexport abstract class ViewNavigationBase<\n T extends ViewNavigationBaseOptions & IBaseInteractionOptions\n> extends BaseInteraction<T> {\n options: T;\n\n protected _state: Partial<Record<'x' | 'y', ViewStateByDim>>;\n protected _inited?: boolean;\n protected _dataFilterX: IDataFilter;\n protected _dataFilterY: IDataFilter;\n\n constructor(view: IView, options?: T) {\n super(view, options);\n this.options = options;\n }\n\n protected _parseLinkedComponent(option: string | IDatazoom | IScrollbar): IDatazoom | IScrollbar {\n if (!option) {\n return null;\n }\n const comp: IMark = isString(option) ? this.view.getMarkById(option) : option;\n\n if (\n comp &&\n comp.markType === GrammarMarkType.component &&\n ((comp as IComponent).componentType === ComponentEnum.datazoom ||\n (comp as IComponent).componentType === ComponentEnum.scrollbar)\n ) {\n return comp as IDatazoom | IScrollbar;\n }\n\n return null;\n }\n\n protected _initStateByDim(\n dim: 'x' | 'y',\n linkedComponent?: string | IDatazoom | IScrollbar,\n scale?: string | IScale,\n dataTarget?: FilterDataTarget\n ) {\n const comp = this._parseLinkedComponent(linkedComponent);\n\n if (comp) {\n this._state[dim] = { linkedComponent: comp };\n return;\n }\n\n const scaleGrammar = !isNil(scale) ? (isString(scale) ? this.view.getScaleById(scale) : scale) : null;\n const dataGrammar = !isNil(dataTarget?.data)\n ? isString(dataTarget.data)\n ? this.view.getDataById(dataTarget.data)\n : dataTarget.data\n : null;\n\n if (!scaleGrammar || !dataGrammar) {\n this._state[dim] = { data: dataGrammar, scale: scaleGrammar };\n return;\n }\n\n dataGrammar.attach(scaleGrammar);\n\n const filterByScale = isString(dataTarget.filter)\n ? (datum: any, filterValue: number[]) => {\n const scale = scaleGrammar.getScale();\n const ratio = getScaleRangeRatio(scale, datum[dataTarget.filter as string]);\n\n return ratio >= filterValue[0] && ratio <= filterValue[1];\n }\n : dataTarget.filter;\n const dataFilter = {\n source: `${scaleGrammar.uid}`,\n rank: DataFilterRank.normal,\n filter: (data: any[]) => {\n const filterValue = dim === 'x' ? this._state?.x?.filterValue : this._state?.y?.filterValue;\n if (!filterValue) {\n return data;\n }\n const filteredData = data.filter(datum => filterByScale(datum, filterValue));\n return dataTarget.transform ? dataTarget.transform(filteredData, filterValue) : filteredData;\n }\n };\n\n if (dim === 'x') {\n this._dataFilterX = dataFilter;\n } else {\n this._dataFilterY = dataFilter;\n }\n\n dataGrammar.addDataFilter(dataFilter);\n\n this._state[dim] = { data: dataGrammar, scale: scaleGrammar };\n }\n\n protected _initGrammars() {\n const { enableX, enableY, scaleX, scaleY, dataTargetX, dataTargetY, linkedComponentX, linkedComponentY } =\n this.options;\n\n this._state = {};\n\n if (enableX !== false) {\n this._initStateByDim('x', linkedComponentX, scaleX, dataTargetX);\n }\n\n if (enableY !== false) {\n this._initStateByDim('y', linkedComponentY, scaleY, dataTargetY);\n }\n\n this._inited = true;\n }\n\n protected _updateLinkedComponent(comp: IDatazoom | IScrollbar, newRange: [number, number]) {\n if (comp.componentType === ComponentEnum.datazoom) {\n (comp as IDatazoom).setStartEndValue(newRange[0], newRange[1]);\n } else {\n // fix: need to update range scrollbar\n (comp as IScrollbar).setScrollStart(newRange[0]);\n }\n }\n\n updateView(type: 'start' | 'reset' | 'update' | 'end', newRange: ViewNavigationRange, e?: InteractionEvent) {\n if (newRange && newRange.x && this._state?.x?.linkedComponent) {\n this._updateLinkedComponent(this._state.x.linkedComponent, newRange.x);\n }\n\n if (newRange && newRange.y && this._state?.y?.linkedComponent) {\n this._updateLinkedComponent(this._state.y.linkedComponent, newRange.y);\n }\n\n if (newRange && newRange.needUpdate) {\n this.view.runAsync();\n }\n\n this.dispatchEvent(type, { viewRange: newRange, event: e });\n }\n\n unbind() {\n super.unbind();\n\n if (this._state) {\n Object.keys(this._state).forEach(dim => {\n const { data, scale } = this._state[dim as 'x' | 'y'];\n\n if (data && scale) {\n data.detach(scale);\n data.removeDataFilter(dim === 'x' ? this._dataFilterX : this._dataFilterY);\n } else if (scale) {\n scale.setRangeFactor(null);\n scale.commit();\n }\n });\n }\n\n this._state = null;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/interactions/view-navigation-base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAgBnD,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,OAAgB,kBAEpB,SAAQ,eAAkB;IAQ1B,YAAY,IAAW,EAAE,OAAW;QAClC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAES,qBAAqB,CAAC,MAAuC;QACrE,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,IAAI,CAAC;SACb;QACD,MAAM,IAAI,GAAU,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,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AC;iBAChB;YACH,CAAC,CAAC,CAAC;SACJ;QAED,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;CACF","file":"view-navigation-base.js","sourcesContent":["import { isNil, isString } from '@visactor/vutils';\nimport type {\n FilterDataTarget,\n IBaseInteractionOptions,\n IComponent,\n IDataFilter,\n IDatazoom,\n IMark,\n IScale,\n IScrollbar,\n IView,\n InteractionEvent,\n ViewNavigationBaseOptions,\n ViewNavigationRange,\n ViewStateByDim\n} from '../types';\nimport { BaseInteraction } from './base';\nimport { ComponentEnum, DataFilterRank, GrammarMarkType } from '../graph/enums';\nimport { getScaleRangeRatio } from '../util/scale';\n\nexport abstract class ViewNavigationBase<\n T extends ViewNavigationBaseOptions & IBaseInteractionOptions\n> extends BaseInteraction<T> {\n options: T;\n\n protected _state: Partial<Record<'x' | 'y', ViewStateByDim>>;\n protected _inited?: boolean;\n protected _dataFilterX: IDataFilter;\n protected _dataFilterY: IDataFilter;\n\n constructor(view: IView, options?: T) {\n super(view, options);\n this.options = options;\n }\n\n protected _parseLinkedComponent(option: string | IDatazoom | IScrollbar): IDatazoom | IScrollbar {\n if (!option) {\n return null;\n }\n const comp: IMark = isString(option) ? this.view.getMarkById(option) : option;\n\n if (\n comp &&\n comp.markType === GrammarMarkType.component &&\n ((comp as IComponent).componentType === ComponentEnum.datazoom ||\n (comp as IComponent).componentType === ComponentEnum.scrollbar)\n ) {\n return comp as IDatazoom | IScrollbar;\n }\n\n return null;\n }\n\n protected _initStateByDim(\n dim: 'x' | 'y',\n linkedComponent?: string | IDatazoom | IScrollbar,\n scale?: string | IScale,\n dataTarget?: FilterDataTarget\n ) {\n const comp = this._parseLinkedComponent(linkedComponent);\n\n if (comp) {\n this._state[dim] = { linkedComponent: comp };\n return;\n }\n\n const scaleGrammar = !isNil(scale) ? (isString(scale) ? this.view.getScaleById(scale) : scale) : null;\n const dataGrammar = !isNil(dataTarget?.data)\n ? isString(dataTarget.data)\n ? this.view.getDataById(dataTarget.data)\n : dataTarget.data\n : null;\n\n if (!scaleGrammar || !dataGrammar) {\n this._state[dim] = { data: dataGrammar, scale: scaleGrammar };\n return;\n }\n\n dataGrammar.attach(scaleGrammar);\n\n const filterByScale = isString(dataTarget.filter)\n ? (datum: any, filterValue: number[]) => {\n const scale = scaleGrammar.getScale();\n const ratio = getScaleRangeRatio(scale, datum[dataTarget.filter as string]);\n\n return ratio >= filterValue[0] && ratio <= filterValue[1];\n }\n : dataTarget.filter;\n const dataFilter = {\n source: `${scaleGrammar.uid}`,\n rank: DataFilterRank.normal,\n filter: (data: any[]) => {\n const filterValue = dim === 'x' ? this._state?.x?.filterValue : this._state?.y?.filterValue;\n if (!filterValue) {\n return data;\n }\n const filteredData = data.filter(datum => filterByScale(datum, filterValue));\n return dataTarget.transform ? dataTarget.transform(filteredData, filterValue) : filteredData;\n }\n };\n\n if (dim === 'x') {\n this._dataFilterX = dataFilter;\n } else {\n this._dataFilterY = dataFilter;\n }\n\n dataGrammar.addDataFilter(dataFilter);\n\n this._state[dim] = { data: dataGrammar, scale: scaleGrammar };\n }\n\n protected _initGrammars() {\n const { enableX, enableY, scaleX, scaleY, dataTargetX, dataTargetY, linkedComponentX, linkedComponentY } =\n this.options;\n\n this._state = {};\n\n if (enableX !== false) {\n this._initStateByDim('x', linkedComponentX, scaleX, dataTargetX);\n }\n\n if (enableY !== false) {\n this._initStateByDim('y', linkedComponentY, scaleY, dataTargetY);\n }\n\n this._inited = true;\n }\n\n protected _updateLinkedComponent(comp: IDatazoom | IScrollbar, newRange: [number, number]) {\n if (comp.componentType === ComponentEnum.datazoom) {\n (comp as IDatazoom).setStartEndValue(newRange[0], newRange[1]);\n } else {\n // fix: need to update range scrollbar\n (comp as IScrollbar).setScrollStart(newRange[0]);\n }\n }\n\n updateView(type: 'start' | 'reset' | 'update' | 'end', newRange: ViewNavigationRange, e?: InteractionEvent) {\n if (newRange && newRange.x && this._state?.x?.linkedComponent) {\n this._updateLinkedComponent(this._state.x.linkedComponent, newRange.x);\n }\n\n if (newRange && newRange.y && this._state?.y?.linkedComponent) {\n this._updateLinkedComponent(this._state.y.linkedComponent, newRange.y);\n }\n\n if (newRange && newRange.needUpdate) {\n this.view.run();\n }\n\n this.dispatchEvent(type, { viewRange: newRange, event: e });\n }\n\n unbind() {\n super.unbind();\n\n if (this._state) {\n Object.keys(this._state).forEach(dim => {\n const { data, scale } = this._state[dim as 'x' | 'y'];\n\n if (data && scale) {\n data.detach(scale);\n data.removeDataFilter(dim === 'x' ? this._dataFilterX : this._dataFilterY);\n } else if (scale) {\n scale.setRangeFactor(null);\n scale.commit();\n }\n });\n }\n\n this._state = null;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/transforms/data/sampling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,UAAU,GAAG;IACjB,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,UAAU;IACf,OAAO,EAAE,OAAO;IAChB,GAAG,EAAE,GAAG;CACT,CAAC;AAEF,SAAS,IAAI,CAAC,IAAY,EAAE,KAAY,EAAE,OAAgB,EAAE,MAAc;IACxE,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,EAAE,CAAC;IACtB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC;IAEzB,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAI,OAAO,CAAC;IACZ,IAAI,IAAI,CAAC;IACT,IAAI,SAAS,CAAC;IAGd,UAAU,CAAC,YAAY,EAAE,CAAC,GAAG,YAAY,CAAC;IAE1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,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M,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;gBAChC,IAAI,KAAK,CAAC,MAAM,IAAI,IAAI,EAAE;oBACxB,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE;wBACvC,OAAO,KAAK,CAAC,CAAC,CAAC;oBACjB,CAAC,CAAC,CAAC;oBACH,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;iBACvC;qBAAM;oBACL,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;oBACnD,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;oBACtC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;iBAChF;YACH,CAAC,CAAC,CAAC;YAGH,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAEhC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;SAC9D;QACD,OAAO,OAAO,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;KACrF;IAED,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC","file":"sampling.js","sourcesContent":["import { maxInArray, minInArray } from '@visactor/vutils';\nimport type { SampleTransformOptions } from '../../types';\nimport { average, sum } from '../util/util';\n\nconst samplerMap = {\n min: minInArray,\n max: maxInArray,\n average: average,\n sum: sum\n};\n\nfunction lttb(size: number, array: any[], isGroup: boolean, yfield: string) {\n const frameSize = Math.floor(array.length / size);\n const newIndices = [];\n const len = array.length;\n\n let currentIndex = 0;\n let sampledIndex = 0;\n let maxArea;\n let area;\n let nextIndex;\n\n // First frame use the first data.\n newIndices[sampledIndex++] = currentIndex;\n\n for (let i = 1; i < len - 1; i += frameSize) {\n const nextFrameStart = Math.min(i + frameSize, len - 1);\n const nextFrameEnd = Math.min(i + frameSize * 2, len);\n\n const avgX = (nextFrameEnd + nextFrameStart) / 2;\n let avgY = 0;\n\n for (let idx = nextFrameStart; idx < nextFrameEnd; idx++) {\n const value = array[idx][yfield];\n if (Number.isNaN(value)) {\n continue;\n }\n avgY += value;\n }\n avgY /= nextFrameEnd - nextFrameStart;\n\n const frameStart = i;\n const frameEnd = Math.min(i + frameSize, len);\n\n const pointAX = i - 1;\n const pointAY = array[currentIndex][yfield];\n\n maxArea = -1;\n\n nextIndex = frameStart;\n // Find a point from current frame that construct a triangel with largest area with previous selected point\n // And the average of next frame.\n for (let idx = frameStart; idx < frameEnd; idx++) {\n const value = array[idx][yfield];\n if (Number.isNaN(yfield)) {\n continue;\n }\n // Calculate triangle area over three buckets\n area = Math.abs((pointAX - avgX) * (value - pointAY) - (pointAX - idx) * (avgY - pointAY));\n if (area > maxArea) {\n maxArea = area;\n nextIndex = idx; // Next a is this b\n }\n }\n\n newIndices[sampledIndex++] = nextIndex;\n\n currentIndex = nextIndex; // This a is the next a (chosen b)\n }\n\n // First frame use the last data.\n if (newIndices[sampledIndex - 1] !== len - 1) {\n newIndices[sampledIndex++] = len - 1;\n }\n\n // output newly added tuples\n const newRawIndices = newIndices.map(i => (isGroup ? array[i].i : i));\n return newRawIndices;\n}\n\nfunction sample(size: number, array: any[], isGroup: boolean, mode: 'min' | 'max' | 'average' | 'sum', yfield: string) {\n let frameSize = Math.floor(array.length / size);\n const newIndices = [];\n const len = array.length;\n let sampledIndex = 0;\n let frameValues = [];\n\n newIndices.push(sampledIndex);\n array[sampledIndex][yfield] = array[sampledIndex][yfield];\n\n for (let i = 1; i < len - 1; i += frameSize) {\n if (frameSize > len - i) {\n frameSize = len - i;\n frameValues.length = frameSize;\n }\n frameValues = [];\n for (let k = 0; k < frameSize; k++) {\n frameValues.push(array[i + k][yfield]);\n }\n const value = samplerMap[mode](frameValues);\n sampledIndex = Math.min(Math.round(i + frameValues.length / 2) || 0, len - 1);\n array[sampledIndex][yfield] = value;\n newIndices.push(sampledIndex);\n }\n const newRawIndices = newIndices.map(i => (isGroup ? array[i].i : i));\n return newRawIndices;\n}\n\nfunction sampleMin(size: number, array: any[], isGroup: boolean, yfield: string) {\n return sample(size, array, isGroup, 'min', yfield);\n}\n\nfunction sampleMax(size: number, array: any[], isGroup: boolean, yfield: string) {\n return sample(size, array, isGroup, 'max', yfield);\n}\n\nfunction sampleAverage(size: number, array: any[], isGroup: boolean, yfield: string) {\n return sample(size, array, isGroup, 'average', yfield);\n}\n\nfunction sampleSum(size: number, array: any[], isGroup: boolean, yfield: string) {\n return sample(size, array, isGroup, 'sum', yfield);\n}\n\n/**\n * Samples tuples passing through this operator.\n * mode: 'lttb' - Uses lttb sampling to maintain a trend-maintained sample.\n * mode: 'min' | 'max' | 'average' | 'sum' - Uses aggregation methods to location sample points.\n * @constructor\n * @param {object} options - The parameters for this operator.\n * @param {number} [options.size=1000] - The maximum number of samples.\n * @param {string} [options.yfield] - The yfield string of data.\n * @param {string} [options.groupBy] - The groupBy string of data.\n */\n\nexport const transform = (options: SampleTransformOptions, upstreamData: any[]) => {\n let size = options.size;\n const factor = options.factor || 1;\n\n if (Array.isArray(size)) {\n size = Math.floor(size[1] - size[0]);\n }\n\n size *= factor;\n\n // size<=0的特殊情况不采样,返回空\n if (size <= 0) {\n return [];\n }\n\n // 数据<size的情况,不进行采样,保留所有数据\n if (upstreamData.length <= size) {\n return upstreamData;\n }\n\n const skipfirst = options.skipfirst;\n // 如果是ChartSpace的第一次数据流(evaluateAsync),不需要采样,返回一条数据供布局使用\n // 这里需要依据this.value.length判断是不是第一次数据流,\n // 以避免点击图例,updateChartData等操作清空所有label\n if (skipfirst) {\n return upstreamData.slice(0, 1);\n }\n\n const { mode, yfield: y, groupBy } = options;\n const yfield = y ?? 'y';\n\n // 采样方法\n let sampler = lttb;\n if (mode === 'min') {\n sampler = sampleMin;\n } else if (mode === 'max') {\n sampler = sampleMax;\n } else if (mode === 'average') {\n sampler = sampleAverage;\n } else if (mode === 'sum') {\n sampler = sampleSum;\n }\n\n // 处理数据source,source为采样前的原始数据\n if (upstreamData.length) {\n // 如果有groupBy,数据分组\n const groups = {};\n if (groupBy) {\n for (let i = 0, n = upstreamData.length; i < n; i++) {\n const datum = upstreamData[i];\n const groupId = datum[groupBy];\n if (groups[groupId]) {\n groups[groupId].push({ [yfield]: datum[yfield], i });\n } else {\n groups[groupId] = [];\n groups[groupId].push({ [yfield]: datum[yfield], i });\n }\n }\n\n // 分组采样\n let rawIndice: any[] = [];\n\n Object.keys(groups).forEach(groupName => {\n const group = groups[groupName];\n if (group.length <= size) {\n const indices = group.map((datum: any) => {\n return datum.i;\n });\n rawIndice = rawIndice.concat(indices);\n } else {\n const indices = sampler(size, group, true, yfield);\n rawIndice = rawIndice.concat(indices);\n group.forEach((datum: any) => (upstreamData[datum.i][yfield] = datum[yfield]));\n }\n });\n\n // 采样后,按照原始顺序排序\n rawIndice.sort((a, b) => a - b);\n\n return rawIndice.map((index: number) => upstreamData[index]);\n }\n return sampler(size, upstreamData, false, yfield).map(index => upstreamData[index]);\n }\n\n return [];\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/transforms/data/sampling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,UAAU,GAAG;IACjB,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,UAAU;IACf,OAAO,EAAE,OAAO;IAChB,GAAG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AE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAEhC,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;SAC9D;QACD,OAAO,OAAO,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;KACrF;IAED,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC","file":"sampling.js","sourcesContent":["import { maxInArray, minInArray } from '@visactor/vutils';\nimport type { SampleTransformOptions } from '../../types';\nimport { average, sum } from '../util/util';\n\nconst samplerMap = {\n min: minInArray,\n max: maxInArray,\n average: average,\n sum: sum\n};\n\nfunction lttb(size: number, array: any[], isGroup: boolean, yfield: string) {\n const frameSize = Math.floor(array.length / size);\n const newIndices = [];\n const len = array.length;\n\n let currentIndex = 0;\n let sampledIndex = 0;\n let maxArea;\n let area;\n let nextIndex;\n\n // First frame use the first data.\n newIndices[sampledIndex++] = currentIndex;\n\n for (let i = 1; i < len - 1; i += frameSize) {\n const nextFrameStart = Math.min(i + frameSize, len - 1);\n const nextFrameEnd = Math.min(i + frameSize * 2, len);\n\n const avgX = (nextFrameEnd + nextFrameStart) / 2;\n let avgY = 0;\n\n for (let idx = nextFrameStart; idx < nextFrameEnd; idx++) {\n const value = array[idx][yfield];\n if (Number.isNaN(value)) {\n continue;\n }\n avgY += value;\n }\n avgY /= nextFrameEnd - nextFrameStart;\n\n const frameStart = i;\n const frameEnd = Math.min(i + frameSize, len);\n\n const pointAX = i - 1;\n const pointAY = array[currentIndex][yfield];\n\n maxArea = -1;\n\n nextIndex = frameStart;\n // Find a point from current frame that construct a triangel with largest area with previous selected point\n // And the average of next frame.\n for (let idx = frameStart; idx < frameEnd; idx++) {\n const value = array[idx][yfield];\n if (Number.isNaN(yfield)) {\n continue;\n }\n // Calculate triangle area over three buckets\n area = Math.abs((pointAX - avgX) * (value - pointAY) - (pointAX - idx) * (avgY - pointAY));\n if (area > maxArea) {\n maxArea = area;\n nextIndex = idx; // Next a is this b\n }\n }\n\n newIndices[sampledIndex++] = nextIndex;\n\n currentIndex = nextIndex; // This a is the next a (chosen b)\n }\n\n // First frame use the last data.\n if (newIndices[sampledIndex - 1] !== len - 1) {\n newIndices[sampledIndex++] = len - 1;\n }\n\n // output newly added tuples\n const newRawIndices = newIndices.map(i => (isGroup ? array[i].i : i));\n return newRawIndices;\n}\n\nfunction sample(size: number, array: any[], isGroup: boolean, mode: 'min' | 'max' | 'average' | 'sum', yfield: string) {\n let frameSize = Math.floor(array.length / size);\n const newIndices = [];\n const len = array.length;\n let sampledIndex = 0;\n let frameValues = [];\n\n newIndices.push(sampledIndex);\n array[sampledIndex][yfield] = array[sampledIndex][yfield];\n\n for (let i = 1; i < len - 1; i += frameSize) {\n if (frameSize > len - i) {\n frameSize = len - i;\n frameValues.length = frameSize;\n }\n frameValues = [];\n for (let k = 0; k < frameSize; k++) {\n frameValues.push(array[i + k][yfield]);\n }\n const value = samplerMap[mode](frameValues);\n sampledIndex = Math.min(Math.round(i + frameValues.length / 2) || 0, len - 1);\n array[sampledIndex][yfield] = value;\n newIndices.push(sampledIndex);\n }\n const newRawIndices = newIndices.map(i => (isGroup ? array[i].i : i));\n return newRawIndices;\n}\n\nfunction sampleMin(size: number, array: any[], isGroup: boolean, yfield: string) {\n return sample(size, array, isGroup, 'min', yfield);\n}\n\nfunction sampleMax(size: number, array: any[], isGroup: boolean, yfield: string) {\n return sample(size, array, isGroup, 'max', yfield);\n}\n\nfunction sampleAverage(size: number, array: any[], isGroup: boolean, yfield: string) {\n return sample(size, array, isGroup, 'average', yfield);\n}\n\nfunction sampleSum(size: number, array: any[], isGroup: boolean, yfield: string) {\n return sample(size, array, isGroup, 'sum', yfield);\n}\n\n/**\n * Samples tuples passing through this operator.\n * mode: 'lttb' - Uses lttb sampling to maintain a trend-maintained sample.\n * mode: 'min' | 'max' | 'average' | 'sum' - Uses aggregation methods to location sample points.\n * @constructor\n * @param {object} options - The parameters for this operator.\n * @param {number} [options.size=1000] - The maximum number of samples.\n * @param {string} [options.yfield] - The yfield string of data.\n * @param {string} [options.groupBy] - The groupBy string of data.\n */\n\nexport const transform = (options: SampleTransformOptions, upstreamData: any[]) => {\n let size = options.size;\n const factor = options.factor || 1;\n\n if (Array.isArray(size)) {\n size = Math.floor(size[1] - size[0]);\n }\n\n size *= factor;\n\n // size<=0的特殊情况不采样,返回空\n if (size <= 0) {\n return [];\n }\n\n // 数据<size的情况,不进行采样,保留所有数据\n if (upstreamData.length <= size) {\n return upstreamData;\n }\n\n const skipfirst = options.skipfirst;\n // 这里需要依据this.value.length判断是不是第一次数据流,\n // 以避免点击图例,updateChartData等操作清空所有label\n if (skipfirst) {\n return upstreamData.slice(0, 1);\n }\n\n const { mode, yfield: y, groupBy } = options;\n const yfield = y ?? 'y';\n\n // 采样方法\n let sampler = lttb;\n if (mode === 'min') {\n sampler = sampleMin;\n } else if (mode === 'max') {\n sampler = sampleMax;\n } else if (mode === 'average') {\n sampler = sampleAverage;\n } else if (mode === 'sum') {\n sampler = sampleSum;\n }\n\n // 处理数据source,source为采样前的原始数据\n if (upstreamData.length) {\n // 如果有groupBy,数据分组\n const groups = {};\n if (groupBy) {\n for (let i = 0, n = upstreamData.length; i < n; i++) {\n const datum = upstreamData[i];\n const groupId = datum[groupBy];\n if (groups[groupId]) {\n groups[groupId].push({ [yfield]: datum[yfield], i });\n } else {\n groups[groupId] = [];\n groups[groupId].push({ [yfield]: datum[yfield], i });\n }\n }\n\n // 分组采样\n let rawIndice: any[] = [];\n\n Object.keys(groups).forEach(groupName => {\n const group = groups[groupName];\n if (group.length <= size) {\n const indices = group.map((datum: any) => {\n return datum.i;\n });\n rawIndice = rawIndice.concat(indices);\n } else {\n const indices = sampler(size, group, true, yfield);\n rawIndice = rawIndice.concat(indices);\n group.forEach((datum: any) => (upstreamData[datum.i][yfield] = datum[yfield]));\n }\n });\n\n // 采样后,按照原始顺序排序\n rawIndice.sort((a, b) => a - b);\n\n return rawIndice.map((index: number) => upstreamData[index]);\n }\n return sampler(size, upstreamData, false, yfield).map(index => upstreamData[index]);\n }\n\n return [];\n};\n"]}
|
package/es/types/dataflow.d.ts
CHANGED
|
@@ -6,8 +6,7 @@ export interface IDataflow {
|
|
|
6
6
|
remove: (grammar: IGrammarBase) => void;
|
|
7
7
|
hasCommitted: () => boolean;
|
|
8
8
|
commit: (grammar: IGrammarBase) => this;
|
|
9
|
-
evaluate: () =>
|
|
10
|
-
evaluateSync: () => boolean;
|
|
9
|
+
evaluate: () => boolean;
|
|
11
10
|
runBefore: (callback?: IDataflowCallback) => void;
|
|
12
11
|
runAfter: (callback?: IDataflowCallback) => void;
|
|
13
12
|
}
|
package/es/types/dataflow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/dataflow.ts"],"names":[],"mappings":"","file":"dataflow.js","sourcesContent":["import type { IGrammarBase } from './grammar';\n\nexport type IDataflowCallback = (df: IDataflow) => void;\n\n/**\n * Dataflow定义,\n */\nexport interface IDataflow {\n logger: any;\n add: (grammar: IGrammarBase) => boolean | undefined;\n remove: (grammar: IGrammarBase) => void;\n hasCommitted: () => boolean;\n commit: (grammar: IGrammarBase) => this;\n evaluate: () =>
|
|
1
|
+
{"version":3,"sources":["../src/types/dataflow.ts"],"names":[],"mappings":"","file":"dataflow.js","sourcesContent":["import type { IGrammarBase } from './grammar';\n\nexport type IDataflowCallback = (df: IDataflow) => void;\n\n/**\n * Dataflow定义,\n */\nexport interface IDataflow {\n logger: any;\n add: (grammar: IGrammarBase) => boolean | undefined;\n remove: (grammar: IGrammarBase) => void;\n hasCommitted: () => boolean;\n commit: (grammar: IGrammarBase) => this;\n evaluate: () => boolean;\n runBefore: (callback?: IDataflowCallback) => void;\n runAfter: (callback?: IDataflowCallback) => void;\n}\n"]}
|
package/es/types/grammar.d.ts
CHANGED
|
@@ -52,11 +52,11 @@ export interface IGrammarBase {
|
|
|
52
52
|
parameters: () => {
|
|
53
53
|
[key: string]: any;
|
|
54
54
|
};
|
|
55
|
-
evaluateSync?: (upstream: any, parameters: any) => this;
|
|
56
55
|
getSpec: () => any;
|
|
57
56
|
reuse: (grammar: IGrammarBase) => this;
|
|
58
57
|
clear: () => void;
|
|
59
58
|
release: () => void;
|
|
59
|
+
evaluate: (upstream: any, parameters: any) => this;
|
|
60
60
|
}
|
|
61
61
|
export interface IData extends IGrammarBase {
|
|
62
62
|
values: (values: any | Nil, format?: ParameterFunctionType<DataFormatSpec>, load?: boolean) => this;
|
package/es/types/grammar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/grammar.ts"],"names":[],"mappings":"","file":"grammar.js","sourcesContent":["import type { EventEmitter, IBounds, IPointLike } from '@visactor/vutils';\nimport type { IGraphic, IGroup } from '@visactor/vrender-core';\nimport type { IBaseScale, ScaleFishEyeOptions, TickData } from '@visactor/vscale';\nimport type { ITransform, TransformSpec } from './transform';\nimport type { DataFormatSpec, IDataFilter } from './data';\nimport type { ParameterFunctionType, SignalFunctionType } from './signal';\nimport type { IAnimate } from './animate';\nimport type { IGlyphMeta } from './glyph';\nimport type { GrammarTypeEnum } from '../graph/enums';\nimport type { Nil } from './base';\nimport type { CoordinateFunctionType } from './coordinate';\nimport type { IElement } from './element';\nimport type {\n MarkFunctionType,\n MarkAnimationSpec,\n MarkType,\n MarkLayoutSpec,\n MarkLayoutCallback,\n MarkSortSpec,\n MarkKeySpec,\n IMarkConfig,\n ChannelEncodeType,\n AttributeTransform,\n BaseSingleEncodeSpec\n} from './mark';\nimport type { ScaleConfigureSpec, ScaleData, ScaleFunctionType, GrammarScaleType, MultiScaleData } from './scale';\nimport type { IView } from './view';\nimport type { BaseEventHandler } from './event';\nimport type { ICartesianCoordinate, IPolarCoordinate } from '@visactor/vgrammar-coordinate';\n\nexport type BuiltInGrammarType = keyof typeof GrammarTypeEnum;\nexport type GrammarType = BuiltInGrammarType | string;\n\n/** 语法元素内置运行的任务 */\nexport interface IGrammarTask extends ITransform {\n /**\n * 参数依赖\n * 只做一级解析\n */\n options?: Record<string, any | IGrammarBase> | (IGrammarBase | any)[];\n /**\n * 依赖的语法元素\n */\n references?: IGrammarBase[];\n /**\n * 是否只支持简单的options配置,不支持在options引用语法元素\n */\n isRawOptions?: boolean;\n}\n\nexport interface GrammarSpec {\n id?: string;\n dependency?: IGrammarBase[] | IGrammarBase | string[] | string;\n}\n\nexport interface IGrammarBase {\n readonly grammarType: GrammarType;\n readonly view: IView;\n readonly uid: number;\n /**\n * 执行的上游节点\n */\n grammarSource: IGrammarBase;\n /**\n * 影响的下游节点\n */\n targets: IGrammarBase[];\n /**\n * 依赖的上游节点,由于不同 spec 配置项中可能引用同一个节点,需要进行计数\n */\n references: Map<IGrammarBase, number>;\n\n depend: (grammar: IGrammarBase[] | IGrammarBase | string[] | string) => this;\n\n addEventListener: (type: string, handler: BaseEventHandler, options?: any) => this;\n removeEventListener: (type: string, handler: BaseEventHandler) => this;\n\n // extended from EventEmitter\n emit: <T extends EventEmitter.EventNames<string | symbol>>(\n event: T,\n ...args: EventEmitter.EventArgs<string | symbol, T>\n ) => boolean;\n emitGrammarEvent: <T extends EventEmitter.EventNames<string | symbol>>(\n event: T,\n ...args: EventEmitter.EventArgs<string | symbol, T>\n ) => boolean;\n\n tasks?: IGrammarTask[];\n // value?: any;\n /** FIXME: operator执行顺序,改造后,dataflow执行元素,应该抽象出来 */\n rank?: number;\n // todo\n set: (value: any) => boolean;\n id: (() => string) & ((id: string) => this);\n name: (() => string) & ((name: string) => this);\n attach: (reference: IGrammarBase | IGrammarBase[], count?: number) => this;\n detach: (reference: IGrammarBase | IGrammarBase[], count?: number) => this;\n detachAll: () => void;\n commit: () => void;\n output: () => any;\n parse: (spec: any) => this;\n parameters: () => { [key: string]: any };\n evaluateSync?: (upstream: any, parameters: any) => this;\n getSpec: () => any;\n reuse: (grammar: IGrammarBase) => this;\n /** clear references */\n clear: () => void;\n /** release all memory storage */\n release: () => void;\n}\n\nexport interface IData extends IGrammarBase {\n values: (values: any | Nil, format?: ParameterFunctionType<DataFormatSpec>, load?: boolean) => this;\n url: (\n url: ParameterFunctionType<string> | Nil,\n format?: ParameterFunctionType<DataFormatSpec>,\n load?: boolean\n ) => this;\n source: (\n source: string | string[] | IData | IData[],\n format?: ParameterFunctionType<DataFormatSpec>,\n load?: boolean\n ) => this;\n transform: (transform: TransformSpec[] | Nil) => this;\n\n // only used in VGrammar\n addDataFilter: (filter: IDataFilter | IDataFilter[]) => this;\n removeDataFilter: (filter: IDataFilter | IDataFilter[]) => this;\n\n // data util methods\n field: (field: string) => any[];\n getValue: () => any[];\n getInput: () => any[];\n getDataIDKey: () => string;\n}\n\n/** 语法元素,TODO */\nexport interface ISignal<T> extends IGrammarBase {\n value: (value: T | Nil) => this;\n update: (update: SignalFunctionType<T> | Nil) => this;\n\n getValue: () => T;\n}\n\n/** 语法元素,TODO */\nexport interface IScale extends IGrammarBase {\n domain: (domain: ScaleFunctionType<any[]> | ScaleData | MultiScaleData | Nil) => this;\n range: (range: ScaleFunctionType<any[]> | ScaleData | MultiScaleData | Nil) => this;\n configure: (config: ScaleConfigureSpec | Nil) => this;\n tickCount: (tickCount: ScaleFunctionType<number> | Nil) => this;\n\n // only used in VGrammar\n getRangeFactor: () => [number, number] | Nil;\n setRangeFactor: (range?: [number, number]) => this;\n getFishEye: () => ScaleFishEyeOptions | Nil;\n setFishEye: (option?: ScaleFishEyeOptions) => this;\n\n // scale util methods\n getScaleType: () => GrammarScaleType;\n getScale: () => IBaseScale;\n ticks: (count?: number) => TickData[];\n getCoordinateAxisPoints: (baseValue?: number) => [IPointLike, IPointLike];\n getCoordinate: () => IPolarCoordinate | ICartesianCoordinate;\n getCoordinateAxisPosition: () => 'top' | 'bottom' | 'left' | 'right' | 'inside' | 'outside' | 'start' | 'end';\n}\n\nexport interface ICoordinate extends IGrammarBase {\n start: (start: CoordinateFunctionType<[number, number]> | Nil) => this;\n end: (end: CoordinateFunctionType<[number, number]> | Nil) => this;\n origin: (origin: CoordinateFunctionType<[number, number]> | Nil) => this;\n\n translate: (offset: CoordinateFunctionType<[number, number]> | Nil) => this;\n rotate: (angle: CoordinateFunctionType<number> | Nil) => this;\n scale: (ratio: CoordinateFunctionType<[number, number]> | Nil) => this;\n transpose: (isTransposed: CoordinateFunctionType<boolean> | Nil) => this;\n\n // coordinate util methods\n}\n\n/** 语法元素,TODO */\n\n/** group mark */\nexport interface IGroupMark extends IMark {\n children: (IMark | IGroupMark | IGlyphMark)[];\n\n layoutChildren?: (IMark | IGroupMark | IGlyphMark)[];\n\n appendChild: (mark: IMark | IGroupMark | IGlyphMark) => this;\n removeChild: (mark: IMark | IGroupMark | IGlyphMark) => this;\n includesChild: (mark: IMark, descendant?: boolean) => boolean;\n\n updateLayoutChildren: () => this;\n}\n\nexport interface IGlyphMark extends IMark {\n glyphType: string;\n getGlyphMeta: () => IGlyphMeta;\n configureGlyph: (config: any) => this;\n getGlyphConfig: () => any;\n}\n\nexport interface IComponent extends IMark {\n componentType: string;\n configureComponent: (config: any) => this;\n}\n\nexport interface IProgressiveGrammar {\n /** 是否启动了增量渲染模式 */\n isProgressive: () => boolean;\n /** 是否正在执行增量渲染 */\n isDoingProgressive: () => boolean;\n /** 清除增量渲染相关状态 */\n clearProgressive: () => void;\n /** 从第一帧开始增量计算 */\n restartProgressive: () => void;\n /** 分片执行 */\n evaluateProgressive: () => void;\n}\n\nexport interface IMark extends IGrammarBase, IProgressiveGrammar {\n group?: IGroupMark;\n\n markType: MarkType;\n coord: ICoordinate;\n /**\n * disable coordinate transform when need\n */\n disableCoordinateTransform?: boolean;\n elements: IElement[];\n elementMap: Map<string, IElement>;\n graphicIndex: number;\n graphicItem?: IGroup;\n animate?: IAnimate;\n\n join: (\n data: IData | string | Nil,\n key?: MarkKeySpec,\n sort?: MarkSortSpec,\n groupBy?: MarkKeySpec,\n groupSort?: MarkSortSpec\n ) => this;\n coordinate: (coordinate: ICoordinate | string | Nil) => this;\n state: (state: MarkFunctionType<string | string[]> | Nil) => this;\n encode: ((encoders: BaseSingleEncodeSpec, clear?: boolean) => this) &\n ((channel: string, value: ChannelEncodeType, clear?: boolean) => this);\n encodeState: ((state: string, channel: string, value: ChannelEncodeType, clear?: boolean) => this) &\n ((state: string, encoders: BaseSingleEncodeSpec, clear?: boolean) => this);\n animation: (animationConfig: MarkAnimationSpec | Nil) => this;\n animationState: (animationState: MarkFunctionType<string> | Nil) => this;\n layout: (layout: MarkLayoutSpec | MarkLayoutCallback | Nil) => this;\n configure: (config: IMarkConfig | Nil) => this;\n context: (context: any) => this;\n transform: (transform: TransformSpec[] | Nil) => this;\n\n needAnimate: () => boolean;\n getBounds: () => IBounds;\n isCollectionMark: () => boolean;\n getAllElements: () => IElement[];\n getContext: () => any;\n\n // position: () => this;\n // color: () => this;\n // shape: () => this;\n\n // mark 执行流程相关接口\n\n isUpdated: boolean;\n getGroupGraphicItem: () => any;\n cleanExitElements: () => void;\n addGraphicItem: (attrs: any, groupKey?: string) => IGraphic;\n getMorphConfig: () => { morph: boolean; morphKey: string | undefined; morphElementKey: string | undefined };\n prepareRelease: () => void;\n\n layoutBounds?: IBounds;\n relativePosition?: { top?: number; bottom?: number; left?: number; right?: number };\n needLayout: () => boolean;\n handleLayoutEnd: () => void;\n handleRenderEnd: () => void;\n isLargeMode: () => boolean;\n getAttributeTransforms: () => AttributeTransform[];\n\n getScalesByChannel: () => Record<string, IBaseScale> | undefined;\n getFieldsByChannel: () => Record<string, string> | undefined;\n getScales: () => Record<string, IBaseScale> | undefined;\n}\n\nexport interface IGrammarBaseConstructor<T extends string = any> {\n new (view: IView, grammarType: T): IGrammarBase;\n}\n\nexport interface ProgressiveContext {\n currentIndex: number;\n totalStep: number;\n step: number;\n data: any[];\n groupKeys?: string[];\n groupedData?: Map<string, any[]>;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/types/grammar.ts"],"names":[],"mappings":"","file":"grammar.js","sourcesContent":["import type { EventEmitter, IBounds, IPointLike } from '@visactor/vutils';\nimport type { IGraphic, IGroup } from '@visactor/vrender-core';\nimport type { IBaseScale, ScaleFishEyeOptions, TickData } from '@visactor/vscale';\nimport type { ITransform, TransformSpec } from './transform';\nimport type { DataFormatSpec, IDataFilter } from './data';\nimport type { ParameterFunctionType, SignalFunctionType } from './signal';\nimport type { IAnimate } from './animate';\nimport type { IGlyphMeta } from './glyph';\nimport type { GrammarTypeEnum } from '../graph/enums';\nimport type { Nil } from './base';\nimport type { CoordinateFunctionType } from './coordinate';\nimport type { IElement } from './element';\nimport type {\n MarkFunctionType,\n MarkAnimationSpec,\n MarkType,\n MarkLayoutSpec,\n MarkLayoutCallback,\n MarkSortSpec,\n MarkKeySpec,\n IMarkConfig,\n ChannelEncodeType,\n AttributeTransform,\n BaseSingleEncodeSpec\n} from './mark';\nimport type { ScaleConfigureSpec, ScaleData, ScaleFunctionType, GrammarScaleType, MultiScaleData } from './scale';\nimport type { IView } from './view';\nimport type { BaseEventHandler } from './event';\nimport type { ICartesianCoordinate, IPolarCoordinate } from '@visactor/vgrammar-coordinate';\n\nexport type BuiltInGrammarType = keyof typeof GrammarTypeEnum;\nexport type GrammarType = BuiltInGrammarType | string;\n\n/** 语法元素内置运行的任务 */\nexport interface IGrammarTask extends ITransform {\n /**\n * 参数依赖\n * 只做一级解析\n */\n options?: Record<string, any | IGrammarBase> | (IGrammarBase | any)[];\n /**\n * 依赖的语法元素\n */\n references?: IGrammarBase[];\n /**\n * 是否只支持简单的options配置,不支持在options引用语法元素\n */\n isRawOptions?: boolean;\n}\n\nexport interface GrammarSpec {\n id?: string;\n dependency?: IGrammarBase[] | IGrammarBase | string[] | string;\n}\n\nexport interface IGrammarBase {\n readonly grammarType: GrammarType;\n readonly view: IView;\n readonly uid: number;\n /**\n * 执行的上游节点\n */\n grammarSource: IGrammarBase;\n /**\n * 影响的下游节点\n */\n targets: IGrammarBase[];\n /**\n * 依赖的上游节点,由于不同 spec 配置项中可能引用同一个节点,需要进行计数\n */\n references: Map<IGrammarBase, number>;\n\n depend: (grammar: IGrammarBase[] | IGrammarBase | string[] | string) => this;\n\n addEventListener: (type: string, handler: BaseEventHandler, options?: any) => this;\n removeEventListener: (type: string, handler: BaseEventHandler) => this;\n\n // extended from EventEmitter\n emit: <T extends EventEmitter.EventNames<string | symbol>>(\n event: T,\n ...args: EventEmitter.EventArgs<string | symbol, T>\n ) => boolean;\n emitGrammarEvent: <T extends EventEmitter.EventNames<string | symbol>>(\n event: T,\n ...args: EventEmitter.EventArgs<string | symbol, T>\n ) => boolean;\n\n tasks?: IGrammarTask[];\n // value?: any;\n /** FIXME: operator执行顺序,改造后,dataflow执行元素,应该抽象出来 */\n rank?: number;\n // todo\n set: (value: any) => boolean;\n id: (() => string) & ((id: string) => this);\n name: (() => string) & ((name: string) => this);\n attach: (reference: IGrammarBase | IGrammarBase[], count?: number) => this;\n detach: (reference: IGrammarBase | IGrammarBase[], count?: number) => this;\n detachAll: () => void;\n commit: () => void;\n output: () => any;\n parse: (spec: any) => this;\n parameters: () => { [key: string]: any };\n getSpec: () => any;\n reuse: (grammar: IGrammarBase) => this;\n /** clear references */\n clear: () => void;\n /** release all memory storage */\n release: () => void;\n evaluate: (upstream: any, parameters: any) => this;\n}\n\nexport interface IData extends IGrammarBase {\n values: (values: any | Nil, format?: ParameterFunctionType<DataFormatSpec>, load?: boolean) => this;\n url: (\n url: ParameterFunctionType<string> | Nil,\n format?: ParameterFunctionType<DataFormatSpec>,\n load?: boolean\n ) => this;\n source: (\n source: string | string[] | IData | IData[],\n format?: ParameterFunctionType<DataFormatSpec>,\n load?: boolean\n ) => this;\n transform: (transform: TransformSpec[] | Nil) => this;\n\n // only used in VGrammar\n addDataFilter: (filter: IDataFilter | IDataFilter[]) => this;\n removeDataFilter: (filter: IDataFilter | IDataFilter[]) => this;\n\n // data util methods\n field: (field: string) => any[];\n getValue: () => any[];\n getInput: () => any[];\n getDataIDKey: () => string;\n}\n\n/** 语法元素,TODO */\nexport interface ISignal<T> extends IGrammarBase {\n value: (value: T | Nil) => this;\n update: (update: SignalFunctionType<T> | Nil) => this;\n\n getValue: () => T;\n}\n\n/** 语法元素,TODO */\nexport interface IScale extends IGrammarBase {\n domain: (domain: ScaleFunctionType<any[]> | ScaleData | MultiScaleData | Nil) => this;\n range: (range: ScaleFunctionType<any[]> | ScaleData | MultiScaleData | Nil) => this;\n configure: (config: ScaleConfigureSpec | Nil) => this;\n tickCount: (tickCount: ScaleFunctionType<number> | Nil) => this;\n\n // only used in VGrammar\n getRangeFactor: () => [number, number] | Nil;\n setRangeFactor: (range?: [number, number]) => this;\n getFishEye: () => ScaleFishEyeOptions | Nil;\n setFishEye: (option?: ScaleFishEyeOptions) => this;\n\n // scale util methods\n getScaleType: () => GrammarScaleType;\n getScale: () => IBaseScale;\n ticks: (count?: number) => TickData[];\n getCoordinateAxisPoints: (baseValue?: number) => [IPointLike, IPointLike];\n getCoordinate: () => IPolarCoordinate | ICartesianCoordinate;\n getCoordinateAxisPosition: () => 'top' | 'bottom' | 'left' | 'right' | 'inside' | 'outside' | 'start' | 'end';\n}\n\nexport interface ICoordinate extends IGrammarBase {\n start: (start: CoordinateFunctionType<[number, number]> | Nil) => this;\n end: (end: CoordinateFunctionType<[number, number]> | Nil) => this;\n origin: (origin: CoordinateFunctionType<[number, number]> | Nil) => this;\n\n translate: (offset: CoordinateFunctionType<[number, number]> | Nil) => this;\n rotate: (angle: CoordinateFunctionType<number> | Nil) => this;\n scale: (ratio: CoordinateFunctionType<[number, number]> | Nil) => this;\n transpose: (isTransposed: CoordinateFunctionType<boolean> | Nil) => this;\n\n // coordinate util methods\n}\n\n/** 语法元素,TODO */\n\n/** group mark */\nexport interface IGroupMark extends IMark {\n children: (IMark | IGroupMark | IGlyphMark)[];\n\n layoutChildren?: (IMark | IGroupMark | IGlyphMark)[];\n\n appendChild: (mark: IMark | IGroupMark | IGlyphMark) => this;\n removeChild: (mark: IMark | IGroupMark | IGlyphMark) => this;\n includesChild: (mark: IMark, descendant?: boolean) => boolean;\n\n updateLayoutChildren: () => this;\n}\n\nexport interface IGlyphMark extends IMark {\n glyphType: string;\n getGlyphMeta: () => IGlyphMeta;\n configureGlyph: (config: any) => this;\n getGlyphConfig: () => any;\n}\n\nexport interface IComponent extends IMark {\n componentType: string;\n configureComponent: (config: any) => this;\n}\n\nexport interface IProgressiveGrammar {\n /** 是否启动了增量渲染模式 */\n isProgressive: () => boolean;\n /** 是否正在执行增量渲染 */\n isDoingProgressive: () => boolean;\n /** 清除增量渲染相关状态 */\n clearProgressive: () => void;\n /** 从第一帧开始增量计算 */\n restartProgressive: () => void;\n /** 分片执行 */\n evaluateProgressive: () => void;\n}\n\nexport interface IMark extends IGrammarBase, IProgressiveGrammar {\n group?: IGroupMark;\n\n markType: MarkType;\n coord: ICoordinate;\n /**\n * disable coordinate transform when need\n */\n disableCoordinateTransform?: boolean;\n elements: IElement[];\n elementMap: Map<string, IElement>;\n graphicIndex: number;\n graphicItem?: IGroup;\n animate?: IAnimate;\n\n join: (\n data: IData | string | Nil,\n key?: MarkKeySpec,\n sort?: MarkSortSpec,\n groupBy?: MarkKeySpec,\n groupSort?: MarkSortSpec\n ) => this;\n coordinate: (coordinate: ICoordinate | string | Nil) => this;\n state: (state: MarkFunctionType<string | string[]> | Nil) => this;\n encode: ((encoders: BaseSingleEncodeSpec, clear?: boolean) => this) &\n ((channel: string, value: ChannelEncodeType, clear?: boolean) => this);\n encodeState: ((state: string, channel: string, value: ChannelEncodeType, clear?: boolean) => this) &\n ((state: string, encoders: BaseSingleEncodeSpec, clear?: boolean) => this);\n animation: (animationConfig: MarkAnimationSpec | Nil) => this;\n animationState: (animationState: MarkFunctionType<string> | Nil) => this;\n layout: (layout: MarkLayoutSpec | MarkLayoutCallback | Nil) => this;\n configure: (config: IMarkConfig | Nil) => this;\n context: (context: any) => this;\n transform: (transform: TransformSpec[] | Nil) => this;\n\n needAnimate: () => boolean;\n getBounds: () => IBounds;\n isCollectionMark: () => boolean;\n getAllElements: () => IElement[];\n getContext: () => any;\n\n // position: () => this;\n // color: () => this;\n // shape: () => this;\n\n // mark 执行流程相关接口\n\n isUpdated: boolean;\n getGroupGraphicItem: () => any;\n cleanExitElements: () => void;\n addGraphicItem: (attrs: any, groupKey?: string) => IGraphic;\n getMorphConfig: () => { morph: boolean; morphKey: string | undefined; morphElementKey: string | undefined };\n prepareRelease: () => void;\n\n layoutBounds?: IBounds;\n relativePosition?: { top?: number; bottom?: number; left?: number; right?: number };\n needLayout: () => boolean;\n handleLayoutEnd: () => void;\n handleRenderEnd: () => void;\n isLargeMode: () => boolean;\n getAttributeTransforms: () => AttributeTransform[];\n\n getScalesByChannel: () => Record<string, IBaseScale> | undefined;\n getFieldsByChannel: () => Record<string, string> | undefined;\n getScales: () => Record<string, IBaseScale> | undefined;\n}\n\nexport interface IGrammarBaseConstructor<T extends string = any> {\n new (view: IView, grammarType: T): IGrammarBase;\n}\n\nexport interface ProgressiveContext {\n currentIndex: number;\n totalStep: number;\n step: number;\n data: any[];\n groupKeys?: string[];\n groupedData?: Map<string, any[]>;\n}\n"]}
|
|
@@ -351,6 +351,10 @@ export interface IViewDragMixin {
|
|
|
351
351
|
handleDragUpdate: (e: InteractionEvent, navState: Partial<Record<'x' | 'y', ViewStateByDim>>, dragOptions?: ViewDragSimpleOptions) => ViewNavigationRange;
|
|
352
352
|
handleDragEnd: (e: InteractionEvent, navState: Partial<Record<'x' | 'y', ViewStateByDim>>, dragOptions?: ViewDragSimpleOptions) => ViewNavigationRange;
|
|
353
353
|
}
|
|
354
|
+
export interface IToggleStateMixin {
|
|
355
|
+
updateStates: (state?: string, reverseState?: string) => void;
|
|
356
|
+
clearAllStates: (state?: string, reverseState?: string) => void;
|
|
357
|
+
}
|
|
354
358
|
export interface ViewStateByDim {
|
|
355
359
|
scale?: IScale;
|
|
356
360
|
data?: IData;
|
|
@@ -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}\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[];\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' | 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;\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;\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;\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;\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}\n\nexport interface ViewZoomSimpleOptions {\n realtime?: boolean;\n rate?: number;\n focus?: boolean;\n trigger?: EventType;\n endTrigger?: EventType;\n triggerOff?: EventType;\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;\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;\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 ViewStateByDim {\n scale?: IScale;\n data?: IData;\n linkedComponent?: IDatazoom | IScrollbar;\n filterValue?: any[];\n wholeScale?: IBaseScale;\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}\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[];\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' | 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;\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;\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;\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;\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}\n\nexport interface ViewZoomSimpleOptions {\n realtime?: boolean;\n rate?: number;\n focus?: boolean;\n trigger?: EventType;\n endTrigger?: EventType;\n triggerOff?: EventType;\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;\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;\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: (state?: string, reverseState?: string) => void;\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 rangeFactor?: [number, number];\n}\n"]}
|
package/es/types/mark.d.ts
CHANGED
|
@@ -78,7 +78,7 @@ export type BasicEncoderSpecMap = {
|
|
|
78
78
|
};
|
|
79
79
|
};
|
|
80
80
|
export type GenerateBaseEncodeSpec<BasicSpec = GenerateBasicEncoderSpec<IGraphicAttribute>> = GenerateEncoderSpec<BasicSpec> | MarkFunctionCallback<BasicSpec>;
|
|
81
|
-
export type StateProxyEncodeSpec<T = any> = (datum: any, element: IElement, state
|
|
81
|
+
export type StateProxyEncodeSpec<T = any> = (datum: any, element: IElement, state?: string, nextStates?: string[]) => T;
|
|
82
82
|
export type StateEncodeSpec<BasicSpec = GenerateBasicEncoderSpec<IGraphicAttribute>> = {
|
|
83
83
|
enter?: GenerateBaseEncodeSpec<BasicSpec>;
|
|
84
84
|
update?: GenerateBaseEncodeSpec<BasicSpec>;
|