@visactor/vchart 2.0.23-alpha.7 → 2.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/es5/index.js +3 -3
- package/build/index.es.js +21481 -16992
- package/build/index.js +21483 -16994
- package/build/index.min.js +2 -2
- package/build/tsconfig.tsbuildinfo +1 -1
- package/cjs/animation/index.js +1 -2
- package/cjs/chart/base/base-chart.js +13 -7
- package/cjs/chart/base/base-chart.js.map +1 -1
- package/cjs/chart/radar/radar-transformer.js +4 -4
- package/cjs/chart/radar/radar-transformer.js.map +1 -1
- package/cjs/compile/compiler.d.ts +4 -0
- package/cjs/compile/compiler.js +66 -41
- package/cjs/compile/compiler.js.map +1 -1
- package/cjs/compile/interface/compiler.d.ts +2 -1
- package/cjs/compile/interface/compiler.js.map +1 -1
- package/cjs/compile/stage-app.d.ts +9 -0
- package/cjs/compile/stage-app.js +39 -0
- package/cjs/compile/stage-app.js.map +1 -0
- package/cjs/compile/state-manager.js +2 -1
- package/cjs/component/brush/brush.js +13 -12
- package/cjs/component/brush/brush.js.map +1 -1
- package/cjs/component/util.js +2 -1
- package/cjs/constant/attribute.js +1 -2
- package/cjs/constant/scroll-bar.js +2 -1
- package/cjs/constant/waterfall.js +1 -2
- package/cjs/core/factory.js +1 -1
- package/cjs/core/index.d.ts +1 -1
- package/cjs/core/index.js +2 -2
- package/cjs/core/index.js.map +1 -1
- package/cjs/core/instance-manager.js +1 -1
- package/cjs/env/env.js +1 -1
- package/cjs/env/index.js +1 -1
- package/cjs/interaction/interaction.js +11 -8
- package/cjs/interaction/interaction.js.map +1 -1
- package/cjs/interaction/triggers/element-active-by-legend.js +3 -2
- package/cjs/interaction/triggers/element-active-by-legend.js.map +1 -1
- package/cjs/interaction/triggers/element-active.js +5 -3
- package/cjs/interaction/triggers/element-active.js.map +1 -1
- package/cjs/interaction/triggers/element-highlight-by-group.js +3 -2
- package/cjs/interaction/triggers/element-highlight-by-group.js.map +1 -1
- package/cjs/interaction/triggers/element-highlight-by-legend.js +2 -2
- package/cjs/interaction/triggers/element-highlight-by-legend.js.map +1 -1
- package/cjs/interaction/triggers/element-highlight-by-name.js +2 -2
- package/cjs/interaction/triggers/element-highlight-by-name.js.map +1 -1
- package/cjs/interaction/triggers/element-highlight.js +2 -2
- package/cjs/interaction/triggers/element-highlight.js.map +1 -1
- package/cjs/interaction/triggers/element-select.js +3 -3
- package/cjs/interaction/triggers/element-select.js.map +1 -1
- package/cjs/mark/base/base-mark.d.ts +1 -0
- package/cjs/mark/base/base-mark.js +29 -15
- package/cjs/mark/base/base-mark.js.map +1 -1
- package/cjs/mark/utils/glyph.js +3 -2
- package/cjs/mark/utils/glyph.js.map +1 -1
- package/cjs/series/bar/bar.js +1 -1
- package/cjs/series/bar/bar.js.map +1 -1
- package/cjs/series/sankey/sankey.js +32 -24
- package/cjs/series/sankey/sankey.js.map +1 -1
- package/cjs/series/scatter/scatter.d.ts +0 -3
- package/cjs/series/scatter/scatter.js +6 -24
- package/cjs/series/scatter/scatter.js.map +1 -1
- package/cjs/util/graphic-state.d.ts +3 -0
- package/cjs/util/graphic-state.js +25 -0
- package/cjs/util/graphic-state.js.map +1 -0
- package/esm/animation/index.js +1 -2
- package/esm/chart/base/base-chart.js +12 -7
- package/esm/chart/base/base-chart.js.map +1 -1
- package/esm/chart/radar/radar-transformer.js +4 -4
- package/esm/chart/radar/radar-transformer.js.map +1 -1
- package/esm/compile/compiler.d.ts +4 -0
- package/esm/compile/compiler.js +68 -40
- package/esm/compile/compiler.js.map +1 -1
- package/esm/compile/interface/compiler.d.ts +2 -1
- package/esm/compile/interface/compiler.js.map +1 -1
- package/esm/compile/stage-app.d.ts +9 -0
- package/esm/compile/stage-app.js +35 -0
- package/esm/compile/stage-app.js.map +1 -0
- package/esm/compile/state-manager.js +2 -1
- package/esm/component/brush/brush.js +9 -7
- package/esm/component/brush/brush.js.map +1 -1
- package/esm/component/util.js +2 -1
- package/esm/constant/attribute.js +1 -2
- package/esm/constant/scroll-bar.js +2 -1
- package/esm/constant/waterfall.js +1 -2
- package/esm/core/factory.js +1 -1
- package/esm/core/index.d.ts +1 -1
- package/esm/core/index.js +2 -2
- package/esm/core/index.js.map +1 -1
- package/esm/core/instance-manager.js +1 -1
- package/esm/env/env.js +1 -1
- package/esm/env/index.js +1 -1
- package/esm/interaction/interaction.js +10 -8
- package/esm/interaction/interaction.js.map +1 -1
- package/esm/interaction/triggers/element-active-by-legend.js +3 -1
- package/esm/interaction/triggers/element-active-by-legend.js.map +1 -1
- package/esm/interaction/triggers/element-active.js +5 -2
- package/esm/interaction/triggers/element-active.js.map +1 -1
- package/esm/interaction/triggers/element-highlight-by-group.js +4 -1
- package/esm/interaction/triggers/element-highlight-by-group.js.map +1 -1
- package/esm/interaction/triggers/element-highlight-by-legend.js +3 -1
- package/esm/interaction/triggers/element-highlight-by-legend.js.map +1 -1
- package/esm/interaction/triggers/element-highlight-by-name.js +3 -1
- package/esm/interaction/triggers/element-highlight-by-name.js.map +1 -1
- package/esm/interaction/triggers/element-highlight.js +3 -1
- package/esm/interaction/triggers/element-highlight.js.map +1 -1
- package/esm/interaction/triggers/element-select.js +4 -2
- package/esm/interaction/triggers/element-select.js.map +1 -1
- package/esm/mark/base/base-mark.d.ts +1 -0
- package/esm/mark/base/base-mark.js +29 -14
- package/esm/mark/base/base-mark.js.map +1 -1
- package/esm/mark/utils/glyph.js +3 -1
- package/esm/mark/utils/glyph.js.map +1 -1
- package/esm/series/bar/bar.js +1 -1
- package/esm/series/bar/bar.js.map +1 -1
- package/esm/series/sankey/sankey.js +25 -21
- package/esm/series/sankey/sankey.js.map +1 -1
- package/esm/series/scatter/scatter.d.ts +0 -3
- package/esm/series/scatter/scatter.js +5 -27
- package/esm/series/scatter/scatter.js.map +1 -1
- package/esm/util/graphic-state.d.ts +3 -0
- package/esm/util/graphic-state.js +17 -0
- package/esm/util/graphic-state.js.map +1 -0
- package/package.json +10 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interaction/triggers/element-active.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/interaction/triggers/element-active.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE/E,MAAM,cAAc,GAAmC;IACrD,KAAK,EAAE,gBAAgB,CAAC,YAAY;IACpC,OAAO,EAAE,aAAa;IACtB,UAAU,EAAE,YAAY;CACzB,CAAC;AAEF,MAAM,OAAO,aAAc,SAAQ,WAAkC;IAMnE,YAAY,OAA+B;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QALjB,SAAI,oBAA4C;QAmDhD,gBAAW,GAAG,CAAC,CAAkB,EAAE,EAAE;YACnC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC,CAAC;QAEF,gBAAW,GAAG,CAAC,CAAkB,EAAE,EAAE;YACnC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC,CAAC;QAnDA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;QAE1D,IAAI,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IACjD,CAAC;IACS,SAAS;QACjB,OAAO;YACL;gBACE,IAAI,EAAE,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Ac,GAAG,cAAc,CAAC;AA0DzC,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACxC,OAAO,CAAC,0BAA0B,CAAC,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;AACxE,CAAC,CAAC","file":"element-active.js","sourcesContent":["import { Factory } from '../../core/factory';\nimport { BaseTrigger } from './base';\nimport type { IElementActiveOptions, ITrigger, ITriggerEventHandler } from '../interface/trigger';\nimport { TRIGGER_TYPE_ENUM } from './enum';\nimport { STATE_VALUE_ENUM } from '../../compile/mark/interface';\nimport type { IMarkGraphic } from '../../mark/interface';\nimport type { BaseEventParams } from '../../event/interface';\nimport { addGraphicState, removeGraphicState } from '../../util/graphic-state';\n\nconst defaultOptions: Partial<IElementActiveOptions> = {\n state: STATE_VALUE_ENUM.STATE_ACTIVE,\n trigger: 'pointerover',\n triggerOff: 'pointerout'\n};\n\nexport class ElementActive extends BaseTrigger<IElementActiveOptions> implements ITrigger<IElementActiveOptions> {\n static type: string = TRIGGER_TYPE_ENUM.ELEMENT_ACTIVE;\n type: string = TRIGGER_TYPE_ENUM.ELEMENT_ACTIVE;\n\n static defaultOptions = defaultOptions;\n\n constructor(options?: IElementActiveOptions) {\n super(options);\n this.options = Object.assign({}, defaultOptions, options);\n\n this.updateMarkIdByState([this.options.state]);\n }\n protected getEvents(): Array<{ type: string | string[]; handler: ITriggerEventHandler }> {\n return [\n {\n type: this.options.trigger,\n handler: this.handleStart\n },\n { type: this.options.triggerOff, handler: this.handleReset }\n ];\n }\n\n getStartState(): string {\n return this.options.state;\n }\n\n start(g: IMarkGraphic) {\n if (g) {\n const { state, interaction } = this.options;\n\n if (this.isGraphicInStateMark(g, state)) {\n addGraphicState(g, state, true);\n\n interaction.setStatedGraphics(this, [g]);\n }\n }\n }\n\n reset(graphic?: IMarkGraphic) {\n const { interaction, state } = this.options;\n\n const statedGraphics = interaction.getStatedGraphics(this);\n const g = graphic ?? statedGraphics?.[0];\n\n if (g && statedGraphics?.includes(g)) {\n removeGraphicState(g, state);\n interaction.setStatedGraphics(\n this,\n statedGraphics.filter(sg => sg !== g)\n );\n }\n }\n\n handleStart = (e: BaseEventParams) => {\n this.start(e.item);\n };\n\n handleReset = (e: BaseEventParams) => {\n this.reset(e.item);\n };\n}\n\nexport const registerElementActive = () => {\n Factory.registerInteractionTrigger(ElementActive.type, ElementActive);\n};\n"]}
|
|
@@ -6,6 +6,8 @@ import { isNil } from "@visactor/vutils";
|
|
|
6
6
|
|
|
7
7
|
import { highlightDefaultOptions } from "./util";
|
|
8
8
|
|
|
9
|
+
import { removeGraphicState } from "../../util/graphic-state";
|
|
10
|
+
|
|
9
11
|
const type = "element-highlight-by-group";
|
|
10
12
|
|
|
11
13
|
export class ElementHighlightByGroup extends BaseTrigger {
|
|
@@ -58,7 +60,8 @@ export class ElementHighlightByGroup extends BaseTrigger {
|
|
|
58
60
|
if (g) {
|
|
59
61
|
if (this.isGraphicInMark(g)) {
|
|
60
62
|
const {interaction: interaction} = this.options, statedGraphics = interaction.getStatedGraphics(this);
|
|
61
|
-
g
|
|
63
|
+
removeGraphicState(g, [ this.options.highlightState, this.options.blurState ]),
|
|
64
|
+
interaction.setStatedGraphics(this, statedGraphics.filter((sg => sg !== g)));
|
|
62
65
|
}
|
|
63
66
|
} else this.resetAll();
|
|
64
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interaction/triggers/element-highlight-by-group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/interaction/triggers/element-highlight-by-group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,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C;YAEH,WAAW,CAAC,YAAY,CAAC,IAAI,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;YAC7F,WAAW,CAAC,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;SACxD;IACH,CAAC;IAED,KAAK,CAAC,CAAgB;QACpB,IAAI,CAAC,EAAE;YACL,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE;gBAC3B,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;gBACrC,MAAM,cAAc,GAAG,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;gBAE3D,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;gBAE7E,WAAW,CAAC,iBAAiB,CAC3B,IAAI,EACJ,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CACtC,CAAC;aACH;SACF;aAAM;YACL,IAAI,CAAC,QAAQ,EAAE,CAAC;SACjB;IACH,CAAC;;AAlFM,4BAAI,GAAW,IAAI,CAAC;AAGpB,sCAAc,GAAG,uBAAuB,CAAC;AA+FlD,MAAM,CAAC,MAAM,+BAA+B,GAAG,GAAG,EAAE;IAClD,OAAO,CAAC,0BAA0B,CAAC,IAAI,EAAE,uBAAuB,CAAC,CAAC;AACpE,CAAC,CAAC","file":"element-highlight-by-group.js","sourcesContent":["import { Factory } from '../../core/factory';\nimport { BaseTrigger } from './base';\nimport type { IElementHighlightOptions, ITrigger, ITriggerEventHandler } from '../interface/trigger';\nimport type { IMarkGraphic } from '../../mark/interface';\nimport { isNil } from '@visactor/vutils';\nimport type { BaseEventParams } from '../../core';\nimport { highlightDefaultOptions } from './util';\nimport { removeGraphicState } from '../../util/graphic-state';\n\nconst type = 'element-highlight-by-group';\n\nexport class ElementHighlightByGroup\n extends BaseTrigger<IElementHighlightOptions>\n implements ITrigger<IElementHighlightOptions>\n{\n static type: string = type;\n type: string = type;\n\n static defaultOptions = highlightDefaultOptions;\n constructor(options?: IElementHighlightOptions) {\n super(options);\n this.options = Object.assign({}, highlightDefaultOptions, options);\n\n this.updateMarkIdByState([this.options.highlightState, this.options.blurState]);\n }\n\n getStartState(): string {\n return this.options.highlightState;\n }\n\n getResetState(): string {\n return this.options.blurState;\n }\n\n protected getEvents(): Array<{ type: string | string[]; handler: ITriggerEventHandler }> {\n return [\n {\n type: this.options.trigger,\n handler: this.handleStart\n },\n { type: this.options.triggerOff, handler: this.handleReset }\n ];\n }\n\n resetAll() {\n const { interaction, highlightState, blurState } = this.options;\n\n interaction.clearAllStatesOfTrigger(this, highlightState, blurState);\n\n interaction.setStatedGraphics(this, []);\n }\n\n protected _getHightlightKey(g: IMarkGraphic) {\n return g.context?.groupKey;\n }\n\n start(g: IMarkGraphic) {\n if (g && this.isGraphicInMark(g)) {\n const highlightKey = this._getHightlightKey(g);\n\n if (isNil(highlightKey)) {\n return;\n }\n\n const { interaction, highlightState, blurState } = this.options;\n const statedGraphics = interaction.getStatedGraphics(this);\n const newStatedGraphics: IMarkGraphic[] = [];\n\n this.getMarks().forEach(m => {\n m.getGraphics()?.forEach(g => {\n if (this._getHightlightKey(g) === highlightKey) {\n newStatedGraphics.push(g);\n }\n });\n });\n\n interaction.updateStates(this, newStatedGraphics, statedGraphics, highlightState, blurState);\n interaction.setStatedGraphics(this, newStatedGraphics);\n }\n }\n\n reset(g?: IMarkGraphic) {\n if (g) {\n if (this.isGraphicInMark(g)) {\n const { interaction } = this.options;\n const statedGraphics = interaction.getStatedGraphics(this);\n\n removeGraphicState(g, [this.options.highlightState, this.options.blurState]);\n\n interaction.setStatedGraphics(\n this,\n statedGraphics.filter(sg => sg !== g)\n );\n }\n } else {\n this.resetAll();\n }\n }\n\n handleStart = (e: BaseEventParams) => {\n this.start(e.item);\n };\n\n handleReset = (e: BaseEventParams) => {\n const g = e.item;\n const hasActiveElement = g && this.isGraphicInMark(g);\n\n if (hasActiveElement) {\n this.resetAll();\n }\n };\n}\n\nexport const registerElementHighlightByGroup = () => {\n Factory.registerInteractionTrigger(type, ElementHighlightByGroup);\n};\n"]}
|
|
@@ -8,6 +8,8 @@ import { ChartEvent } from "../../constant/event";
|
|
|
8
8
|
|
|
9
9
|
import { generateFilterValue } from "./util";
|
|
10
10
|
|
|
11
|
+
import { removeGraphicState } from "../../util/graphic-state";
|
|
12
|
+
|
|
11
13
|
const type = "element-highlight-by-legend", defaultOptions = {
|
|
12
14
|
highlightState: STATE_VALUE_ENUM.STATE_HIGHLIGHT,
|
|
13
15
|
blurState: STATE_VALUE_ENUM.STATE_BLUR,
|
|
@@ -59,7 +61,7 @@ export class ElementHighlightByLegend extends BaseTrigger {
|
|
|
59
61
|
const {highlightState: highlightState, blurState: blurState, interaction: interaction} = this.options;
|
|
60
62
|
if (g) {
|
|
61
63
|
const statedGraphics = interaction.getStatedGraphics(this);
|
|
62
|
-
statedGraphics && statedGraphics.includes(g) && (g
|
|
64
|
+
statedGraphics && statedGraphics.includes(g) && (removeGraphicState(g, [ highlightState, blurState ]),
|
|
63
65
|
interaction.setStatedGraphics(this, statedGraphics.filter((sg => sg !== g))));
|
|
64
66
|
} else this.resetAll();
|
|
65
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interaction/triggers/element-highlight-by-legend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/interaction/triggers/element-highlight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AO,CAAC;QAEhE,WAAW,CAAC,uBAAuB,CAAC,IAAI,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;QAErE,WAAW,CAAC,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,CAAgB;QACpB,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAEhE,IAAI,CAAC,EAAE;YACL,MAAM,cAAc,GAAG,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;YAC3D,IAAI,cAAc,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;gBAChD,kBAAkB,CAAC,CAAC,EAAE,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC;gBACnD,WAAW,CAAC,iBAAiB,CAC3B,IAAI,EACJ,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CACtC,CAAC;aACH;SACF;aAAM;YACL,IAAI,CAAC,QAAQ,EAAE,CAAC;SACjB;IACH,CAAC;;AA3EM,6BAAI,GAAW,IAAI,CAAC;AAGpB,uCAAc,GAAG,cAAc,CAAC;AAuFzC,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAG,EAAE;IACnD,OAAO,CAAC,0BAA0B,CAAC,IAAI,EAAE,wBAAwB,CAAC,CAAC;AACrE,CAAC,CAAC","file":"element-highlight-by-legend.js","sourcesContent":["import { Factory } from '../../core/factory';\nimport { BaseTrigger } from './base';\nimport type { IElementHighlightByLegendOptions, ITrigger, ITriggerEventHandler } from '../interface/trigger';\nimport { STATE_VALUE_ENUM } from '../../compile/mark/interface';\nimport { ChartEvent } from '../../constant/event';\nimport { generateFilterValue } from './util';\nimport type { IMarkGraphic } from '../../mark/interface/common';\nimport type { BaseEventParams } from '../../event/interface';\nimport { removeGraphicState } from '../../util/graphic-state';\n\nconst type = 'element-highlight-by-legend';\nconst defaultOptions: Partial<IElementHighlightByLegendOptions> = {\n highlightState: STATE_VALUE_ENUM.STATE_HIGHLIGHT,\n blurState: STATE_VALUE_ENUM.STATE_BLUR,\n filterType: 'groupKey'\n};\n\nexport class ElementHighlightByLegend\n extends BaseTrigger<IElementHighlightByLegendOptions>\n implements ITrigger<IElementHighlightByLegendOptions>\n{\n static type: string = type;\n type: string = type;\n\n static defaultOptions = defaultOptions;\n constructor(options?: IElementHighlightByLegendOptions) {\n super(options);\n this.options = Object.assign({}, defaultOptions, options);\n this.updateMarkIdByState([this.options.highlightState, this.options.blurState]);\n }\n\n getStartState(): string {\n return this.options.highlightState;\n }\n\n getResetState(): string {\n return this.options.blurState;\n }\n\n protected getEvents(): Array<{ type: string | string[]; handler: ITriggerEventHandler }> {\n return [\n {\n type: ChartEvent.legendItemHover,\n handler: this.handleStart\n },\n {\n type: ChartEvent.legendItemUnHover,\n handler: this.handleReset\n }\n ];\n }\n\n start(itemKey: any) {\n if (itemKey) {\n const filterValue = generateFilterValue(this.options as IElementHighlightByLegendOptions);\n\n const { interaction, highlightState, blurState } = this.options;\n const statedGraphics = interaction.getStatedGraphics(this);\n const newStatedGraphics: IMarkGraphic[] = [];\n\n this.getMarks().forEach(m => {\n m.getGraphics()?.forEach(g => {\n if (filterValue(g) === itemKey) {\n newStatedGraphics.push(g);\n }\n });\n });\n\n interaction.updateStates(this, newStatedGraphics, statedGraphics, highlightState, blurState);\n interaction.setStatedGraphics(this, newStatedGraphics);\n }\n }\n\n resetAll() {\n const { interaction, highlightState, blurState } = this.options;\n\n interaction.clearAllStatesOfTrigger(this, highlightState, blurState);\n\n interaction.setStatedGraphics(this, []);\n }\n\n reset(g?: IMarkGraphic) {\n const { highlightState, blurState, interaction } = this.options;\n\n if (g) {\n const statedGraphics = interaction.getStatedGraphics(this);\n if (statedGraphics && statedGraphics.includes(g)) {\n removeGraphicState(g, [highlightState, blurState]);\n interaction.setStatedGraphics(\n this,\n statedGraphics.filter(sg => sg !== g)\n );\n }\n } else {\n this.resetAll();\n }\n }\n\n handleStart = (e: BaseEventParams) => {\n const event = e.event;\n\n if (event) {\n this.start(event.detail?.data?.id);\n }\n };\n\n handleReset = (e: BaseEventParams) => {\n this.resetAll();\n };\n}\n\nexport const registerElementHighlightByLegend = () => {\n Factory.registerInteractionTrigger(type, ElementHighlightByLegend);\n};\n"]}
|
|
@@ -8,6 +8,8 @@ import { array } from "@visactor/vutils";
|
|
|
8
8
|
|
|
9
9
|
import { generateFilterValue } from "./util";
|
|
10
10
|
|
|
11
|
+
import { removeGraphicState } from "../../util/graphic-state";
|
|
12
|
+
|
|
11
13
|
const type = "element-highlight-by-name", defaultOptions = {
|
|
12
14
|
highlightState: STATE_VALUE_ENUM.STATE_HIGHLIGHT,
|
|
13
15
|
blurState: STATE_VALUE_ENUM.STATE_BLUR,
|
|
@@ -68,7 +70,7 @@ export class ElementHighlightByName extends BaseTrigger {
|
|
|
68
70
|
const {highlightState: highlightState, blurState: blurState, interaction: interaction} = this.options;
|
|
69
71
|
if (g) {
|
|
70
72
|
const statedGraphics = interaction.getStatedGraphics(this);
|
|
71
|
-
statedGraphics && statedGraphics.includes(g) && (g
|
|
73
|
+
statedGraphics && statedGraphics.includes(g) && (removeGraphicState(g, [ highlightState, blurState ]),
|
|
72
74
|
interaction.setStatedGraphics(this, statedGraphics.filter((sg => sg !== g))));
|
|
73
75
|
} else this.resetAll();
|
|
74
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interaction/triggers/element-highlight-by-name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAA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EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAEhE,IAAI,CAAC,EAAE;YACL,MAAM,cAAc,GAAG,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;YAC3D,IAAI,cAAc,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;gBAChD,kBAAkB,CAAC,CAAC,EAAE,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC;gBACnD,WAAW,CAAC,iBAAiB,CAC3B,IAAI,EACJ,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CACtC,CAAC;aACH;SACF;aAAM;YACL,IAAI,CAAC,QAAQ,EAAE,CAAC;SACjB;IACH,CAAC;;AAtFM,2BAAI,GAAW,IAAI,CAAC;AAGpB,qCAAc,GAAG,cAAc,CAAC;AAuGzC,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,EAAE;IACjD,OAAO,CAAC,0BAA0B,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;AACnE,CAAC,CAAC","file":"element-highlight-by-name.js","sourcesContent":["import { Factory } from '../../core/factory';\nimport { BaseTrigger } from './base';\nimport type { IElementHighlightByNameOptions, ITrigger } from '../interface/trigger';\nimport { STATE_VALUE_ENUM } from '../../compile/mark/interface';\nimport type { BaseEventParams } from '../../event/interface';\nimport { array } from '@visactor/vutils';\nimport type { IMarkGraphic } from '../../mark/interface';\nimport { generateFilterValue } from './util';\nimport { removeGraphicState } from '../../util/graphic-state';\n\nconst type = 'element-highlight-by-name';\nconst defaultOptions: Partial<IElementHighlightByNameOptions> = {\n highlightState: STATE_VALUE_ENUM.STATE_HIGHLIGHT,\n blurState: STATE_VALUE_ENUM.STATE_BLUR,\n filterType: 'groupKey'\n};\n\nexport class ElementHighlightByName\n extends BaseTrigger<IElementHighlightByNameOptions>\n implements ITrigger<IElementHighlightByNameOptions>\n{\n static type: string = type;\n type: string = type;\n\n static defaultOptions = defaultOptions;\n constructor(options?: IElementHighlightByNameOptions) {\n super(options);\n this.options = Object.assign({}, defaultOptions, options);\n this.updateMarkIdByState([this.options.highlightState, this.options.blurState]);\n }\n\n getStartState(): string {\n return this.options.highlightState;\n }\n\n getResetState(): string {\n return this.options.blurState;\n }\n\n protected getEvents() {\n return [\n {\n type: this.options.trigger,\n handler: this.handleStart\n },\n { type: this.options.triggerOff, handler: this.handleReset }\n ];\n }\n\n protected _filterByName(e: BaseEventParams) {\n const names = array(this.options.graphicName);\n\n return e?.node?.name && names.includes(e.node.name);\n }\n\n protected _parseTargetKey(e: BaseEventParams) {\n return this.options.parseData\n ? this.options.parseData(e)\n : e.node.type === 'text'\n ? (e.node.attribute as any).text\n : null;\n }\n\n start(itemKey: any) {\n if (itemKey) {\n const filterValue = generateFilterValue(this.options as IElementHighlightByNameOptions);\n\n const { interaction, highlightState, blurState } = this.options;\n const statedGraphics = interaction.getStatedGraphics(this);\n const newStatedGraphics: IMarkGraphic[] = [];\n\n this.getMarks().forEach(m => {\n m.getGraphics()?.forEach(g => {\n if (filterValue(g) === itemKey) {\n newStatedGraphics.push(g);\n }\n });\n });\n\n interaction.updateStates(this, newStatedGraphics, statedGraphics, highlightState, blurState);\n interaction.setStatedGraphics(this, newStatedGraphics);\n }\n }\n\n resetAll() {\n const { interaction, highlightState, blurState } = this.options;\n\n interaction.clearAllStatesOfTrigger(this, highlightState, blurState);\n\n interaction.setStatedGraphics(this, []);\n }\n\n reset(g?: IMarkGraphic) {\n const { highlightState, blurState, interaction } = this.options;\n\n if (g) {\n const statedGraphics = interaction.getStatedGraphics(this);\n if (statedGraphics && statedGraphics.includes(g)) {\n removeGraphicState(g, [highlightState, blurState]);\n interaction.setStatedGraphics(\n this,\n statedGraphics.filter(sg => sg !== g)\n );\n }\n } else {\n this.resetAll();\n }\n }\n\n handleStart = (e: BaseEventParams) => {\n const shoudStart = this.options.shouldStart ? this.options.shouldStart(e) : this._filterByName(e);\n\n if (shoudStart) {\n const itemKey = this._parseTargetKey(e);\n this.start(itemKey);\n }\n };\n\n handleReset = (e: BaseEventParams) => {\n const shoudReset = this.options.shouldReset ? this.options.shouldReset(e) : this._filterByName(e);\n\n if (shoudReset) {\n this.resetAll();\n }\n };\n}\n\nexport const registerElementHighlightByName = () => {\n Factory.registerInteractionTrigger(type, ElementHighlightByName);\n};\n"]}
|
|
@@ -6,6 +6,8 @@ import { BaseTrigger } from "./base";
|
|
|
6
6
|
|
|
7
7
|
import { Factory } from "../../core/factory";
|
|
8
8
|
|
|
9
|
+
import { removeGraphicState } from "../../util/graphic-state";
|
|
10
|
+
|
|
9
11
|
const defaultOptions = {
|
|
10
12
|
highlightState: STATE_VALUE_ENUM.STATE_HIGHLIGHT,
|
|
11
13
|
blurState: STATE_VALUE_ENUM.STATE_BLUR,
|
|
@@ -62,7 +64,7 @@ export class ElementHighlight extends BaseTrigger {
|
|
|
62
64
|
} else this._lastGraphic && "view" === this._resetType && this.resetAll(e);
|
|
63
65
|
}
|
|
64
66
|
reset(markGraphic, e) {
|
|
65
|
-
markGraphic ? this._markSet.getMarkInId(markGraphic.context.markId) && markGraphic
|
|
67
|
+
markGraphic ? this._markSet.getMarkInId(markGraphic.context.markId) && removeGraphicState(markGraphic, [ this.options.highlightState, this.options.blurState ]) : this.resetAll(e);
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interaction/triggers/element-highlight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/interaction/triggers/element-highlight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAA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AU,KAAK,MAAM,EAAE;YAC1D,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SAClB;IACH,CAAC;IAED,KAAK,CAAC,WAAyB,EAAE,CAAmB;QAClD,IAAI,WAAW,EAAE;YACf,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;gBACzD,kBAAkB,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;aACxF;SACF;aAAM;YACL,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SAClB;IACH,CAAC;;AAlHM,qBAAI,uBAA+C;AAGnD,+BAAc,GAAG,cAAc,CAAC;AAkHzC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,OAAO,CAAC,0BAA0B,CAAC,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;AAC9E,CAAC,CAAC","file":"element-highlight.js","sourcesContent":["import { isString } from '@visactor/vutils';\nimport { STATE_VALUE_ENUM } from '../../compile/mark/interface';\nimport type { IElementHighlightOptions, ITrigger } from '../interface/trigger';\nimport type { IMarkGraphic } from '../../mark/interface/common';\nimport { BaseTrigger } from './base';\nimport { Factory } from '../../core/factory';\nimport type { GraphicEventType } from '@visactor/vrender-core';\nimport { TRIGGER_TYPE_ENUM } from './enum';\nimport type { BaseEventParams } from '../../event/interface';\nimport { removeGraphicState } from '../../util/graphic-state';\n\nconst defaultOptions: Partial<IElementHighlightOptions> = {\n highlightState: STATE_VALUE_ENUM.STATE_HIGHLIGHT,\n blurState: STATE_VALUE_ENUM.STATE_BLUR,\n trigger: 'pointerover',\n triggerOff: 'pointerout'\n};\n\nexport class ElementHighlight\n extends BaseTrigger<IElementHighlightOptions>\n implements ITrigger<IElementHighlightOptions>\n{\n static type: string = TRIGGER_TYPE_ENUM.ELEMENT_HIGHLIGHT;\n type: string = TRIGGER_TYPE_ENUM.ELEMENT_HIGHLIGHT;\n\n static defaultOptions = defaultOptions;\n\n protected _lastGraphic?: IMarkGraphic;\n\n constructor(options?: IElementHighlightOptions) {\n super(options);\n this.options = Object.assign({}, defaultOptions, options);\n\n this.updateMarkIdByState([this.options.highlightState, this.options.blurState]);\n }\n\n getStartState(): string {\n return this.options.highlightState;\n }\n\n getResetState(): string {\n return this.options.blurState;\n }\n protected _resetType?: 'view' | 'self';\n\n protected getEvents() {\n const triggerOff = this.options.triggerOff;\n const trigger = this.options.trigger;\n const events = [\n {\n type: trigger,\n handler: this.handleStart\n }\n ];\n\n let eventName = triggerOff;\n if (isString(triggerOff) && (triggerOff as string).includes('view:')) {\n eventName = (triggerOff as string).replace('view:', '') as GraphicEventType;\n this._resetType = 'view';\n } else {\n this._resetType = 'self';\n }\n\n events.push({ type: eventName as GraphicEventType, handler: this.handleReset });\n\n return events;\n }\n\n resetAll = (e?: BaseEventParams) => {\n const { highlightState, blurState, interaction } = this.options;\n\n if (this._lastGraphic) {\n interaction.clearAllStatesOfTrigger(this, highlightState, blurState);\n\n this.dispatchEvent('reset', { graphics: [this._lastGraphic], options: this.options, ...e });\n\n this._lastGraphic = null;\n\n interaction.setStatedGraphics(this, []);\n }\n };\n\n handleStart = (e: BaseEventParams) => {\n this.start(e.item, e);\n };\n\n handleReset = (e: BaseEventParams) => {\n const { interaction } = this.options;\n const statedGraphics = interaction.getStatedGraphics(this);\n\n if (!statedGraphics || !statedGraphics.length) {\n return;\n }\n const markGraphic = e.item;\n const hasActiveElement = markGraphic && this._markSet.getMarkInId(markGraphic.context.markId);\n\n if (this._resetType.includes('view') && !hasActiveElement) {\n this.resetAll(e);\n } else if (this._resetType.includes('self') && hasActiveElement) {\n this.resetAll(e);\n }\n };\n\n start(markGraphic: IMarkGraphic, e?: BaseEventParams) {\n if (markGraphic && this._markSet.getMarkInId(markGraphic.context.markId)) {\n const { highlightState, blurState, interaction } = this.options;\n\n if (this._lastGraphic === markGraphic) {\n return;\n }\n\n const newStatedGraphics = interaction.updateStates(\n this,\n [markGraphic],\n interaction.getStatedGraphics(this),\n highlightState,\n blurState\n );\n interaction.setStatedGraphics(this, newStatedGraphics);\n\n this._lastGraphic = markGraphic;\n\n this.dispatchEvent('start', { graphics: newStatedGraphics, options: this.options, ...e });\n } else if (this._lastGraphic && this._resetType === 'view') {\n this.resetAll(e);\n }\n }\n\n reset(markGraphic: IMarkGraphic, e?: BaseEventParams) {\n if (markGraphic) {\n if (this._markSet.getMarkInId(markGraphic.context.markId)) {\n removeGraphicState(markGraphic, [this.options.highlightState, this.options.blurState]);\n }\n } else {\n this.resetAll(e);\n }\n }\n}\n\nexport const registerElementHighlight = () => {\n Factory.registerInteractionTrigger(ElementHighlight.type, ElementHighlight);\n};\n"]}
|
|
@@ -8,6 +8,8 @@ import { parseTriggerOffOfSelect } from "./util";
|
|
|
8
8
|
|
|
9
9
|
import { Factory } from "../../core/factory";
|
|
10
10
|
|
|
11
|
+
import { addGraphicState, removeGraphicState } from "../../util/graphic-state";
|
|
12
|
+
|
|
11
13
|
const defaultOptions = {
|
|
12
14
|
state: STATE_VALUE_ENUM.STATE_SELECTED,
|
|
13
15
|
trigger: "click"
|
|
@@ -57,7 +59,7 @@ export class ElementSelect extends BaseTrigger {
|
|
|
57
59
|
newStatedGraphics && newStatedGraphics.length ? interaction.setStatedGraphics(this, interaction.updateStates(this, newStatedGraphics, statedGraphics, state, reverseState)) : this.resetAll(e);
|
|
58
60
|
}
|
|
59
61
|
} else {
|
|
60
|
-
this._timer && clearTimeout(this._timer), markGraphic
|
|
62
|
+
this._timer && clearTimeout(this._timer), addGraphicState(markGraphic, state, !0);
|
|
61
63
|
const newStatedGraphics = this.options.interaction.updateStates(this, isMultiple && statedGraphics ? [ ...statedGraphics, markGraphic ] : [ markGraphic ], statedGraphics, state, reverseState);
|
|
62
64
|
interaction.setStatedGraphics(this, newStatedGraphics), this.dispatchEvent("start", Object.assign({
|
|
63
65
|
graphics: newStatedGraphics,
|
|
@@ -68,7 +70,7 @@ export class ElementSelect extends BaseTrigger {
|
|
|
68
70
|
} else this._resetType.includes("view") && statedGraphics && statedGraphics.length && this.resetAll(e);
|
|
69
71
|
}
|
|
70
72
|
reset(markGraphic, e) {
|
|
71
|
-
markGraphic ? this._markSet.getMarkInId(markGraphic.context.markId) && markGraphic
|
|
73
|
+
markGraphic ? this._markSet.getMarkInId(markGraphic.context.markId) && removeGraphicState(markGraphic, [ this.options.state, this.options.reverseState ]) : this.resetAll(e);
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interaction/triggers/element-select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAI7C,MAAM,cAAc,GAAmC;IACrD,KAAK,EAAE,gBAAgB,CAAC,cAAc;IACtC,OAAO,EAAE,OAAO;CACjB,CAAC;AAEF,MAAM,OAAO,aAAc,SAAQ,WAAkC;IASnE,YAAY,OAA+B;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QARjB,SAAI,oBAA4C;QAGtC,eAAU,GAAoC,EAAE,CAAC;QA2C3D,aAAQ,GAAG,CAAC,CAAmB,EAAE,EAAE;YACjC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;YAE1D,MAAM,cAAc,GAAG,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;YAE3D,IAAI,cAAc,IAAI,cAAc,CAAC,MAAM,EAAE;gBAC3C,WAA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F,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;oBACvC,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,GAAG,EAAE;wBAC5B,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;oBACnB,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,UAAoB,CAAsB,CAAC;iBAC5D;aACF;SACF;aAAM,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,cAAc,IAAI,cAAc,CAAC,MAAM,EAAE;YACtF,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SAClB;IACH,CAAC;IAED,KAAK,CAAC,WAAyB,EAAE,CAAmB;QAClD,IAAI,WAAW,EAAE;YACf,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;gBACzD,WAAW,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;aAC1E;SACF;aAAM;YACL,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SAClB;IACH,CAAC;;AAtIM,kBAAI,oBAA4C;AAGhD,4BAAc,GAAG,cAAc,CAAC;AAsIzC,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACxC,OAAO,CAAC,0BAA0B,CAAC,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;AACxE,CAAC,CAAC","file":"element-select.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { STATE_VALUE_ENUM } from '../../compile/mark/interface';\nimport type { IElementSelectOptions, ITrigger } from '../interface/trigger';\nimport type { IMarkGraphic } from '../../mark/interface/common';\nimport { BaseTrigger } from './base';\nimport { parseTriggerOffOfSelect } from './util';\nimport { Factory } from '../../core/factory';\nimport { TRIGGER_TYPE_ENUM } from './enum';\nimport type { BaseEventParams } from '../../event/interface';\n\nconst defaultOptions: Partial<IElementSelectOptions> = {\n state: STATE_VALUE_ENUM.STATE_SELECTED,\n trigger: 'click'\n};\n\nexport class ElementSelect extends BaseTrigger<IElementSelectOptions> implements ITrigger<IElementSelectOptions> {\n static type: string = TRIGGER_TYPE_ENUM.ELEMENT_SELECT;\n type: string = TRIGGER_TYPE_ENUM.ELEMENT_SELECT;\n\n static defaultOptions = defaultOptions;\n protected _resetType: ('view' | 'self' | 'timeout')[] = [];\n\n private _timer?: number;\n\n constructor(options?: IElementSelectOptions) {\n super(options);\n this.options = Object.assign({}, defaultOptions, options);\n\n this.updateMarkIdByState([this.options.state, this.options.reverseState]);\n }\n\n getStartState(): string {\n return this.options.state;\n }\n\n getResetState(): string {\n return this.options.reverseState;\n }\n\n protected getEvents() {\n const triggerOff = this.options.triggerOff;\n const trigger = this.options.trigger;\n\n const events = [\n {\n type: trigger,\n handler: this.handleStart\n }\n ];\n\n const { eventNames, resetType } = parseTriggerOffOfSelect(triggerOff);\n\n eventNames.forEach(evt => {\n if (evt && (isArray(trigger) ? !trigger.includes(evt) : evt !== trigger)) {\n events.push({ type: evt, handler: this.handleReset });\n }\n });\n\n this._resetType = resetType;\n\n return events;\n }\n\n resetAll = (e?: BaseEventParams) => {\n const { state, reverseState, interaction } = this.options;\n\n const statedGraphics = interaction.getStatedGraphics(this);\n\n if (statedGraphics && statedGraphics.length) {\n interaction.clearAllStatesOfTrigger(this, state, reverseState);\n this.dispatchEvent('reset', { graphics: statedGraphics, options: this.options, ...e });\n\n interaction.setStatedGraphics(this, []);\n }\n };\n\n handleStart = (e: BaseEventParams) => {\n this.start(e.item, e);\n };\n\n handleReset = (e: BaseEventParams) => {\n const { interaction } = this.options;\n\n const statedGraphics = interaction.getStatedGraphics(this);\n if (!statedGraphics || !statedGraphics.length) {\n return;\n }\n const markGraphic = e.item;\n const hasActiveElement = markGraphic && this._markSet.getMarkInId(markGraphic.context.markId);\n\n if (this._resetType.includes('view') && !hasActiveElement) {\n this.resetAll(e);\n } else if (this._resetType.includes('self') && hasActiveElement) {\n this.resetAll(e);\n }\n };\n\n start(markGraphic: IMarkGraphic, e?: BaseEventParams) {\n const { state, reverseState, isMultiple, interaction } = this.options;\n const statedGraphics = interaction.getStatedGraphics(this);\n\n if (markGraphic && this._markSet.getMarkInId(markGraphic.context.markId)) {\n if (markGraphic.hasState(state)) {\n if (this._resetType.includes('self')) {\n const newStatedGraphics = statedGraphics && statedGraphics.filter(g => g !== markGraphic);\n\n if (newStatedGraphics && newStatedGraphics.length) {\n interaction.setStatedGraphics(\n this,\n interaction.updateStates(this, newStatedGraphics, statedGraphics, state, reverseState)\n );\n } else {\n this.resetAll(e);\n }\n }\n } else {\n if (this._timer) {\n clearTimeout(this._timer);\n }\n markGraphic.addState(state, true);\n\n const newStatedGraphics = this.options.interaction.updateStates(\n this,\n isMultiple && statedGraphics ? [...statedGraphics, markGraphic] : [markGraphic],\n statedGraphics,\n state,\n reverseState\n );\n interaction.setStatedGraphics(this, newStatedGraphics);\n this.dispatchEvent('start', { graphics: newStatedGraphics, options: this.options, ...e });\n\n if (this._resetType.includes('timeout')) {\n this._timer = setTimeout(() => {\n this.resetAll(e);\n }, this.options.triggerOff as number) as unknown as number;\n }\n }\n } else if (this._resetType.includes('view') && statedGraphics && statedGraphics.length) {\n this.resetAll(e);\n }\n }\n\n reset(markGraphic: IMarkGraphic, e?: BaseEventParams) {\n if (markGraphic) {\n if (this._markSet.getMarkInId(markGraphic.context.markId)) {\n markGraphic.removeState([this.options.state, this.options.reverseState]);\n }\n } else {\n this.resetAll(e);\n }\n }\n}\n\nexport const registerElementSelect = () => {\n Factory.registerInteractionTrigger(ElementSelect.type, ElementSelect);\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/interaction/triggers/element-select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,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IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;gBACzD,kBAAkB,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;aAClF;SACF;aAAM;YACL,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SAClB;IACH,CAAC;;AAtIM,kBAAI,oBAA4C;AAGhD,4BAAc,GAAG,cAAc,CAAC;AAsIzC,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACxC,OAAO,CAAC,0BAA0B,CAAC,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;AACxE,CAAC,CAAC","file":"element-select.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { STATE_VALUE_ENUM } from '../../compile/mark/interface';\nimport type { IElementSelectOptions, ITrigger } from '../interface/trigger';\nimport type { IMarkGraphic } from '../../mark/interface/common';\nimport { BaseTrigger } from './base';\nimport { parseTriggerOffOfSelect } from './util';\nimport { Factory } from '../../core/factory';\nimport { TRIGGER_TYPE_ENUM } from './enum';\nimport type { BaseEventParams } from '../../event/interface';\nimport { addGraphicState, removeGraphicState } from '../../util/graphic-state';\n\nconst defaultOptions: Partial<IElementSelectOptions> = {\n state: STATE_VALUE_ENUM.STATE_SELECTED,\n trigger: 'click'\n};\n\nexport class ElementSelect extends BaseTrigger<IElementSelectOptions> implements ITrigger<IElementSelectOptions> {\n static type: string = TRIGGER_TYPE_ENUM.ELEMENT_SELECT;\n type: string = TRIGGER_TYPE_ENUM.ELEMENT_SELECT;\n\n static defaultOptions = defaultOptions;\n protected _resetType: ('view' | 'self' | 'timeout')[] = [];\n\n private _timer?: number;\n\n constructor(options?: IElementSelectOptions) {\n super(options);\n this.options = Object.assign({}, defaultOptions, options);\n\n this.updateMarkIdByState([this.options.state, this.options.reverseState]);\n }\n\n getStartState(): string {\n return this.options.state;\n }\n\n getResetState(): string {\n return this.options.reverseState;\n }\n\n protected getEvents() {\n const triggerOff = this.options.triggerOff;\n const trigger = this.options.trigger;\n\n const events = [\n {\n type: trigger,\n handler: this.handleStart\n }\n ];\n\n const { eventNames, resetType } = parseTriggerOffOfSelect(triggerOff);\n\n eventNames.forEach(evt => {\n if (evt && (isArray(trigger) ? !trigger.includes(evt) : evt !== trigger)) {\n events.push({ type: evt, handler: this.handleReset });\n }\n });\n\n this._resetType = resetType;\n\n return events;\n }\n\n resetAll = (e?: BaseEventParams) => {\n const { state, reverseState, interaction } = this.options;\n\n const statedGraphics = interaction.getStatedGraphics(this);\n\n if (statedGraphics && statedGraphics.length) {\n interaction.clearAllStatesOfTrigger(this, state, reverseState);\n this.dispatchEvent('reset', { graphics: statedGraphics, options: this.options, ...e });\n\n interaction.setStatedGraphics(this, []);\n }\n };\n\n handleStart = (e: BaseEventParams) => {\n this.start(e.item, e);\n };\n\n handleReset = (e: BaseEventParams) => {\n const { interaction } = this.options;\n\n const statedGraphics = interaction.getStatedGraphics(this);\n if (!statedGraphics || !statedGraphics.length) {\n return;\n }\n const markGraphic = e.item;\n const hasActiveElement = markGraphic && this._markSet.getMarkInId(markGraphic.context.markId);\n\n if (this._resetType.includes('view') && !hasActiveElement) {\n this.resetAll(e);\n } else if (this._resetType.includes('self') && hasActiveElement) {\n this.resetAll(e);\n }\n };\n\n start(markGraphic: IMarkGraphic, e?: BaseEventParams) {\n const { state, reverseState, isMultiple, interaction } = this.options;\n const statedGraphics = interaction.getStatedGraphics(this);\n\n if (markGraphic && this._markSet.getMarkInId(markGraphic.context.markId)) {\n if (markGraphic.hasState(state)) {\n if (this._resetType.includes('self')) {\n const newStatedGraphics = statedGraphics && statedGraphics.filter(g => g !== markGraphic);\n\n if (newStatedGraphics && newStatedGraphics.length) {\n interaction.setStatedGraphics(\n this,\n interaction.updateStates(this, newStatedGraphics, statedGraphics, state, reverseState)\n );\n } else {\n this.resetAll(e);\n }\n }\n } else {\n if (this._timer) {\n clearTimeout(this._timer);\n }\n addGraphicState(markGraphic, state, true);\n\n const newStatedGraphics = this.options.interaction.updateStates(\n this,\n isMultiple && statedGraphics ? [...statedGraphics, markGraphic] : [markGraphic],\n statedGraphics,\n state,\n reverseState\n );\n interaction.setStatedGraphics(this, newStatedGraphics);\n this.dispatchEvent('start', { graphics: newStatedGraphics, options: this.options, ...e });\n\n if (this._resetType.includes('timeout')) {\n this._timer = setTimeout(() => {\n this.resetAll(e);\n }, this.options.triggerOff as number) as unknown as number;\n }\n }\n } else if (this._resetType.includes('view') && statedGraphics && statedGraphics.length) {\n this.resetAll(e);\n }\n }\n\n reset(markGraphic: IMarkGraphic, e?: BaseEventParams) {\n if (markGraphic) {\n if (this._markSet.getMarkInId(markGraphic.context.markId)) {\n removeGraphicState(markGraphic, [this.options.state, this.options.reverseState]);\n }\n } else {\n this.resetAll(e);\n }\n }\n}\n\nexport const registerElementSelect = () => {\n Factory.registerInteractionTrigger(ElementSelect.type, ElementSelect);\n};\n"]}
|
|
@@ -155,6 +155,7 @@ export declare class BaseMark<T extends ICommonSpec> extends GrammarItem impleme
|
|
|
155
155
|
protected _getEncoderOfStyle: (stateName: string, style: Partial<IAttrs<T>>) => Record<string, (datum: Datum) => any>;
|
|
156
156
|
protected _setGraphicFromMarkConfig: (g: IMarkGraphic) => void;
|
|
157
157
|
protected _setStateOfGraphic: (g: IMarkGraphic, hasAnimation?: boolean) => void;
|
|
158
|
+
protected _applySharedStateDefinitions(): void;
|
|
158
159
|
protected _addProgressiveGraphic(parent: IGroup, g: IMarkGraphic): void;
|
|
159
160
|
protected _runEncoder(graphics: IMarkGraphic[], noGroupEncode?: boolean): void;
|
|
160
161
|
protected _runApplyGraphic(graphics: IMarkGraphic[]): void;
|
|
@@ -56,6 +56,8 @@ import { log } from "../../util/debug";
|
|
|
56
56
|
|
|
57
57
|
import { morph as runMorph } from "../../compile/morph";
|
|
58
58
|
|
|
59
|
+
import { addGraphicState, removeGraphicState } from "../../util/graphic-state";
|
|
60
|
+
|
|
59
61
|
export class BaseMark extends GrammarItem {
|
|
60
62
|
commit(render, recursion) {
|
|
61
63
|
recursion && this.getMarks().length > 0 && this.getMarks().forEach((m => m.commit(!1, recursion))),
|
|
@@ -241,10 +243,7 @@ export class BaseMark extends GrammarItem {
|
|
|
241
243
|
setCustomizedShape && (g.pathProxy = attrs => setCustomizedShape(g.context.data, attrs, new CustomPath2D)),
|
|
242
244
|
graphicName && (isFunction(graphicName) ? g.name = graphicName(g) : g.name = graphicName);
|
|
243
245
|
}, this._setStateOfGraphic = (g, hasAnimation) => {
|
|
244
|
-
g.clearStates(), g.stateProxy = null, g.context.diffState !== DiffState.enter && g.context.diffState !== DiffState.update ||
|
|
245
|
-
var _a;
|
|
246
|
-
return this._runEncoderOfGraphic(null === (_a = this._encoderOfState) || void 0 === _a ? void 0 : _a[stateName], g);
|
|
247
|
-
}, g.context.states && g.useStates(g.context.states, hasAnimation));
|
|
246
|
+
g.clearStates(), g.stateProxy = null, g.context.diffState !== DiffState.enter && g.context.diffState !== DiffState.update || g.context.states && g.useStates(g.context.states, hasAnimation);
|
|
248
247
|
}, this.name = name, this.model = option.model, this.key = option.key, this.state = new MarkStateManager(option, this),
|
|
249
248
|
this._attributeContext = option.attributeContext, null === (_a = option.map) || void 0 === _a || _a.set(this.id, this);
|
|
250
249
|
}
|
|
@@ -676,20 +675,36 @@ export class BaseMark extends GrammarItem {
|
|
|
676
675
|
groupStyles: groupStyles
|
|
677
676
|
};
|
|
678
677
|
}
|
|
678
|
+
_applySharedStateDefinitions() {
|
|
679
|
+
var _a;
|
|
680
|
+
if (!this._product) return;
|
|
681
|
+
const stateNames = Object.keys(null !== (_a = this._encoderOfState) && void 0 !== _a ? _a : {}).filter((stateName => "group" !== stateName && "update" !== stateName));
|
|
682
|
+
if (!stateNames.length) return void (this._product.sharedStateDefinitions = void 0);
|
|
683
|
+
const sortedStateNames = this._stateSort ? stateNames.slice().sort(this._stateSort) : stateNames, statePriority = new Map;
|
|
684
|
+
sortedStateNames.forEach(((stateName, index) => {
|
|
685
|
+
statePriority.set(stateName, index);
|
|
686
|
+
}));
|
|
687
|
+
const sharedStateDefinitions = {};
|
|
688
|
+
stateNames.forEach((stateName => {
|
|
689
|
+
var _a;
|
|
690
|
+
const encoder = this._encoderOfState[stateName];
|
|
691
|
+
sharedStateDefinitions[stateName] = {
|
|
692
|
+
priority: null !== (_a = statePriority.get(stateName)) && void 0 !== _a ? _a : 0,
|
|
693
|
+
declaredAffectedKeys: Object.keys(null != encoder ? encoder : {}),
|
|
694
|
+
resolver: ({graphic: graphic}) => this._runEncoderOfGraphic(encoder, graphic)
|
|
695
|
+
};
|
|
696
|
+
})), this._product.sharedStateDefinitions = sharedStateDefinitions;
|
|
697
|
+
}
|
|
679
698
|
_addProgressiveGraphic(parent, g) {
|
|
680
699
|
parent.incrementalAppendChild(g);
|
|
681
700
|
}
|
|
682
701
|
_runEncoder(graphics, noGroupEncode) {
|
|
683
702
|
var _a;
|
|
684
703
|
const attrsByGroup = noGroupEncode ? null : this._runGroupEncoder(null === (_a = this._encoderOfState) || void 0 === _a ? void 0 : _a.group);
|
|
685
|
-
graphics.forEach((
|
|
686
|
-
var _a
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
var _a;
|
|
690
|
-
const stateAttr = this._runEncoderOfGraphic(null === (_a = this._encoderOfState) || void 0 === _a ? void 0 : _a[_state], g);
|
|
691
|
-
attrs = Object.assign(Object.assign({}, attrs), stateAttr);
|
|
692
|
-
})), isNil(this._markConfig.interactive) || (attrs.pickable = this._markConfig.interactive);
|
|
704
|
+
graphics.forEach((g => {
|
|
705
|
+
var _a;
|
|
706
|
+
const attrs = this._runEncoderOfGraphic(null === (_a = this._encoderOfState) || void 0 === _a ? void 0 : _a.update, g);
|
|
707
|
+
isNil(this._markConfig.interactive) || (attrs.pickable = this._markConfig.interactive);
|
|
693
708
|
const finalAttrs = this._transformGraphicAttributes(g, attrs, null == attrsByGroup ? void 0 : attrsByGroup[g.context.groupKey]);
|
|
694
709
|
g.context.finalAttrs = finalAttrs;
|
|
695
710
|
}));
|
|
@@ -773,7 +788,7 @@ export class BaseMark extends GrammarItem {
|
|
|
773
788
|
}
|
|
774
789
|
renderInner() {
|
|
775
790
|
var _a, _b, _c;
|
|
776
|
-
this._updateEncoderByState();
|
|
791
|
+
this._updateEncoderByState(), this._applySharedStateDefinitions();
|
|
777
792
|
const data = null !== (_b = null === (_a = this._data) || void 0 === _a ? void 0 : _a.getProduct()) && void 0 !== _b ? _b : [ {} ], transformData = this._runBeforeTransform(data);
|
|
778
793
|
let markData;
|
|
779
794
|
if (null == transformData ? void 0 : transformData.progressive) {
|
|
@@ -798,7 +813,7 @@ export class BaseMark extends GrammarItem {
|
|
|
798
813
|
if (!this._product) return;
|
|
799
814
|
const stateInfo = this.state.getStateInfo(key);
|
|
800
815
|
this._graphics.forEach((g => {
|
|
801
|
-
"in" === this.state.checkOneState(g, g.context.data, stateInfo) ? g
|
|
816
|
+
"in" === this.state.checkOneState(g, g.context.data, stateInfo) ? addGraphicState(g, key, !0, this.hasAnimationByState("state")) : removeGraphicState(g, key, this.hasAnimationByState("state"));
|
|
802
817
|
}));
|
|
803
818
|
}
|
|
804
819
|
clearExitGraphics() {
|