@visactor/vgrammar-core 0.9.1 → 0.9.3
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/title.d.ts +4 -3
- package/cjs/component/title.js.map +1 -1
- package/cjs/graph/animation/animate.js +5 -3
- package/cjs/graph/animation/animate.js.map +1 -1
- package/cjs/graph/animation/animator.js +2 -1
- package/cjs/graph/animation/animator.js.map +1 -1
- package/cjs/graph/animation/config.js +9 -7
- package/cjs/graph/animation/config.js.map +1 -1
- package/cjs/graph/attributes/line.d.ts +1 -0
- package/cjs/graph/attributes/line.js +11 -3
- package/cjs/graph/attributes/line.js.map +1 -1
- package/cjs/graph/attributes/transform.js +0 -24
- package/cjs/graph/attributes/transform.js.map +1 -1
- package/cjs/graph/constants.d.ts +1 -0
- package/cjs/graph/constants.js +3 -3
- package/cjs/graph/constants.js.map +1 -1
- package/cjs/graph/element.d.ts +1 -1
- package/cjs/graph/element.js +14 -17
- package/cjs/graph/element.js.map +1 -1
- package/cjs/graph/glyph-element.js +2 -3
- package/cjs/graph/glyph-element.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/parse/scale.js +1 -1
- package/cjs/parse/scale.js.map +1 -1
- package/cjs/semantic-marks/interval.js +4 -2
- package/cjs/semantic-marks/interval.js.map +1 -1
- package/cjs/transforms/data/contour.js +2 -1
- package/cjs/transforms/data/contour.js.map +1 -1
- package/cjs/transforms/data/sampling.js +3 -3
- package/cjs/transforms/data/sampling.js.map +1 -1
- package/cjs/transforms/data/unfold.js +2 -2
- package/cjs/transforms/data/unfold.js.map +1 -1
- package/cjs/transforms/mark/symmetry.js +2 -1
- package/cjs/transforms/mark/symmetry.js.map +1 -1
- package/cjs/transforms/util/util.d.ts +0 -2
- package/cjs/transforms/util/util.js +2 -11
- package/cjs/transforms/util/util.js.map +1 -1
- package/cjs/types/animate.d.ts +2 -0
- package/cjs/types/animate.js.map +1 -1
- package/cjs/types/component.d.ts +5 -5
- package/cjs/types/component.js.map +1 -1
- package/cjs/types/grammar.d.ts +2 -1
- package/cjs/types/grammar.js.map +1 -1
- package/cjs/types/mark.d.ts +1 -0
- package/cjs/types/mark.js.map +1 -1
- package/cjs/view/mark.d.ts +3 -1
- package/cjs/view/mark.js +9 -3
- package/cjs/view/mark.js.map +1 -1
- package/es/component/title.d.ts +4 -3
- package/es/component/title.js.map +1 -1
- package/es/graph/animation/animate.js +4 -3
- package/es/graph/animation/animate.js.map +1 -1
- package/es/graph/animation/animator.js +2 -1
- package/es/graph/animation/animator.js.map +1 -1
- package/es/graph/animation/config.js +10 -8
- package/es/graph/animation/config.js.map +1 -1
- package/es/graph/attributes/line.d.ts +1 -0
- package/es/graph/attributes/line.js +8 -1
- package/es/graph/attributes/line.js.map +1 -1
- package/es/graph/attributes/transform.js +0 -24
- package/es/graph/attributes/transform.js.map +1 -1
- package/es/graph/constants.d.ts +1 -0
- package/es/graph/constants.js +2 -0
- package/es/graph/constants.js.map +1 -1
- package/es/graph/element.d.ts +1 -1
- package/es/graph/element.js +15 -18
- package/es/graph/element.js.map +1 -1
- package/es/graph/glyph-element.js +2 -3
- package/es/graph/glyph-element.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/interactions/brush-filter.js +2 -1
- package/es/interactions/element-highlight-by-group.js +1 -2
- package/es/interactions/index.js +2 -1
- package/es/interactions/legend-filter.js +1 -1
- package/es/interactions/player-filter.js +1 -1
- package/es/interactions/roll-up.js +1 -1
- package/es/interactions/scrollbar-filter.js +1 -1
- package/es/interactions/slider-filter.js +1 -1
- package/es/interactions/tooltip.js +1 -1
- package/es/interactions/view-drag-mixin.js +1 -1
- package/es/parse/coordinate.js +1 -1
- package/es/parse/event.js +1 -1
- package/es/parse/mark.js +1 -1
- package/es/parse/option.js +1 -1
- package/es/parse/scale.js +3 -4
- package/es/parse/scale.js.map +1 -1
- package/es/parse/transform.js +1 -1
- package/es/parse/util.js +1 -1
- package/es/parse/view.js +1 -1
- package/es/semantic-marks/interval.js +3 -3
- package/es/semantic-marks/interval.js.map +1 -1
- package/es/transforms/data/contour.js +2 -2
- package/es/transforms/data/contour.js.map +1 -1
- package/es/transforms/data/sampling.js +5 -3
- package/es/transforms/data/sampling.js.map +1 -1
- package/es/transforms/data/unfold.js +3 -3
- package/es/transforms/data/unfold.js.map +1 -1
- package/es/transforms/mark/symmetry.js +2 -2
- package/es/transforms/mark/symmetry.js.map +1 -1
- package/es/transforms/util/util.d.ts +0 -2
- package/es/transforms/util/util.js +0 -8
- package/es/transforms/util/util.js.map +1 -1
- package/es/types/animate.d.ts +2 -0
- package/es/types/animate.js.map +1 -1
- package/es/types/component.d.ts +5 -5
- package/es/types/component.js.map +1 -1
- package/es/types/grammar.d.ts +2 -1
- package/es/types/grammar.js.map +1 -1
- package/es/types/mark.d.ts +1 -0
- package/es/types/mark.js.map +1 -1
- package/es/view/mark.d.ts +3 -1
- package/es/view/mark.js +9 -3
- package/es/view/mark.js.map +1 -1
- package/package.json +10 -10
|
@@ -65,7 +65,7 @@ export class Animator {
|
|
|
65
65
|
}));
|
|
66
66
|
}
|
|
67
67
|
animateTimeSlice(graphicAnimate, timeSlice, animationParameters, parameters) {
|
|
68
|
-
const delay = timeSlice.delay, duration = timeSlice.duration, effects = timeSlice.effects;
|
|
68
|
+
const delay = timeSlice.delay, delayAfter = timeSlice.delayAfter, duration = timeSlice.duration, effects = timeSlice.effects;
|
|
69
69
|
if (delay > 0 && graphicAnimate.wait(delay), effects.length < 0) graphicAnimate.wait(duration); else {
|
|
70
70
|
const customAnimates = effects.map(((effect, index) => {
|
|
71
71
|
var _a;
|
|
@@ -80,6 +80,7 @@ export class Animator {
|
|
|
80
80
|
})).filter((animate => !isNil(animate)));
|
|
81
81
|
1 === customAnimates.length ? graphicAnimate.play(customAnimates[0]) : graphicAnimate.play(new AnimateGroup(duration, customAnimates));
|
|
82
82
|
}
|
|
83
|
+
delayAfter > 0 && graphicAnimate.wait(delayAfter);
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
//# sourceMappingURL=animator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/animation/animator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAa5F,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAExH,OAAO,CAAC,IAAI,IAAI,WAAW,CAAC,oBAAoB,CAAC;AAEjD,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAEzB,MAAM,mBAAmB,GAAG,CAAC,MAAoE,EAAE,EAAE;IACnG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,SAAS,YAAY,cAAc,CAAC;AACtE,CAAC,CAAC;AAEF,MAAM,OAAO,QAAQ;IAUnB,YACE,OAAiB,EACjB,IAAoB,EACpB,gBAIC;QAhBH,OAAE,GAAW,gBAAgB,EAAE,CAAC;QAGhC,gBAAW,GAAY,KAAK,CAAC;QAGrB,aAAQ,GAAsB,EAAE,CAAC;QAYvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,QAAQ,CAAC,gBAA0C;QACjD,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CAAC,mBAAyC,EAAE,UAAe;QAChE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAExB,IAAI,CAAC,cAAc,CAAC,m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,EACb,QAAQ,EACR,MAAM,CAAC,MAAM,EACb,sBAAsB,CACvB,CAAC;iBACH;qBAAM,IAAI,UAAU,CAAC,EAAE,EAAE;oBACxB,OAAO,IAAI,gBAAgB,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;iBACtF;YACH,CAAC,CAAC;iBACD,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YAEtC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC/B,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;aACxC;iBAAM;gBACL,cAAc,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;aACjE;SACF;IACH,CAAC;CACF","file":"animator.js","sourcesContent":["import { isNil, isValidNumber } from '@visactor/vutils';\nimport type { IAnimate as IGraphicAnimate } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { ACustomAnimate, Animate, AnimateGroup, AnimateMode } from '@visactor/vrender-core';\nimport type {\n IAnimationChannelInterpolator,\n IAnimationCustomConstructor,\n IAnimationTimeline,\n IAnimator,\n IAnimatorOptions,\n IAnimationUnit,\n IAnimationParameters,\n IAnimationTimeSlice,\n IElement,\n IAnimationEffect\n} from '../../types';\nimport { AttributeAnimate, channelAnimationAttributes, CustomInterpolator, typeAnimationAttributes } from './attribute';\n\nAnimate.mode |= AnimateMode.SET_ATTR_IMMEDIATELY;\n\nlet GlobalAnimatorId = 0;\n\nconst isCustomAnimateCtor = (custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor) => {\n return !isNil(custom) && custom.prototype instanceof ACustomAnimate;\n};\n\nexport class Animator implements IAnimator {\n id: number = GlobalAnimatorId++;\n element: IElement;\n animationOptions: IAnimatorOptions;\n isAnimating: boolean = false;\n\n private unit: IAnimationUnit;\n private runnings: IGraphicAnimate[] = [];\n private callbackFunction: (...args: any[]) => any;\n\n constructor(\n element: IElement,\n unit: IAnimationUnit,\n animationOptions: {\n state: string;\n timeline: IAnimationTimeline;\n id: string;\n }\n ) {\n this.element = element;\n this.animationOptions = animationOptions;\n this.unit = unit;\n }\n\n callback(callbackFunction: (...args: any[]) => void): this {\n this.callbackFunction = callbackFunction;\n return this;\n }\n\n animate(animationParameters: IAnimationParameters, parameters: any): this {\n this.isAnimating = true;\n\n this.animateElement(animationParameters, parameters);\n\n // if no valid running, end animating immediately\n if (this.runnings.length === 0) {\n this.animationEnd();\n }\n return this;\n }\n\n stop(stopState: 'start' | 'end' = 'end', invokeCallback: boolean = true): this {\n // FIXME: wait for VRender to fix 'end' parameter\n this.runnings.forEach(running => running.stop(stopState));\n this.animationEnd(invokeCallback);\n return this;\n }\n\n pause(): this {\n this.runnings.forEach(running => running.pause());\n return this;\n }\n\n resume(): this {\n this.runnings.forEach(running => running.resume());\n return this;\n }\n\n startAt(startTime: number): this {\n this.runnings.forEach(running => {\n const initialDelay = this.unit.initialDelay;\n running.startAt(initialDelay + startTime);\n });\n return this;\n }\n\n getTotalAnimationTime() {\n const timeLineDuration = this.unit.initialDelay + this.unit.loopDuration * this.unit.loopCount;\n return this.unit.totalTime ?? timeLineDuration;\n }\n\n getEndAttributes() {\n return this.runnings.reduce((attributes, running) => {\n return Object.assign(attributes, running.getEndProps());\n }, {} as Record<string, any>);\n }\n\n private animationEnd(invokeCallback: boolean = true) {\n this.isAnimating = false;\n this.runnings = null;\n if (invokeCallback) {\n this.callbackFunction?.call(null);\n }\n }\n\n private animateElement(animationParameters: IAnimationParameters, parameters: any) {\n const graphicItem = this.element.getGraphicItem();\n\n if (!graphicItem) {\n return;\n }\n\n const graphicAnimate: IGraphicAnimate = graphicItem.animate();\n this.runnings.push(graphicAnimate);\n // initialDelay is only used at first loop\n graphicAnimate.startAt(this.unit.initialDelay);\n // execute loop animation\n graphicAnimate.wait(this.unit.loopDelay);\n this.unit.timeSlices.forEach(timeSlice => {\n this.animateTimeSlice(graphicAnimate, timeSlice, animationParameters, parameters);\n });\n graphicAnimate.wait(this.unit.loopDelayAfter);\n\n graphicAnimate.loop(this.unit.loopCount - 1);\n\n if (isValidNumber(this.unit.totalTime)) {\n // FIXME: use VRender api instead after VRender refactor is finished\n setTimeout(() => {\n if (graphicAnimate) {\n graphicAnimate.stop('end');\n }\n }, this.unit.totalTime);\n }\n\n graphicAnimate.onEnd(() => {\n this.runnings = this.runnings.filter(running => running !== graphicAnimate);\n if (this.runnings.length === 0) {\n this.animationEnd();\n }\n });\n }\n\n private animateTimeSlice(\n graphicAnimate: IGraphicAnimate,\n timeSlice: IAnimationTimeSlice,\n animationParameters: IAnimationParameters,\n parameters: any\n ) {\n const delay = timeSlice.delay as number;\n const duration = timeSlice.duration as number;\n const effects = timeSlice.effects as IAnimationEffect[];\n\n // wait in loop animation before animation starts\n if (delay > 0) {\n graphicAnimate.wait(delay);\n }\n\n if (effects.length < 0) {\n graphicAnimate.wait(duration);\n } else {\n const customAnimates = effects\n .map((effect, index) => {\n const attributes =\n (effect.type\n ? typeAnimationAttributes(this.element, effect, animationParameters, parameters)\n : channelAnimationAttributes(this.element, effect, animationParameters, parameters)) ?? {};\n const customOption = attributes?.custom || effect?.custom;\n const customParametersOption = attributes?.customParameters || effect?.customParameters;\n\n if (\n attributes.from &&\n Object.keys(attributes.from).length &&\n this.unit &&\n this.animationOptions.timeline.controlOptions.immediatelyApply &&\n this.element.mark.markType !== 'component'\n ) {\n this.element.getGraphicItem().setAttributes(attributes.from);\n }\n\n const isCustomAnimate = isCustomAnimateCtor(customOption);\n const isCustomInterpolator = !isNil(customOption) && !isCustomAnimateCtor(customOption);\n\n if (isCustomInterpolator) {\n return new CustomInterpolator(attributes.from, attributes.to, duration, effect.easing, {\n interpolator: customOption as IAnimationChannelInterpolator,\n element: this.element,\n parameters: customParametersOption\n });\n } else if (isCustomAnimate) {\n return new (customOption as IAnimationCustomConstructor)(\n attributes.from,\n attributes.to,\n duration,\n effect.easing,\n customParametersOption\n );\n } else if (attributes.to) {\n return new AttributeAnimate(attributes.from, attributes.to, duration, effect.easing);\n }\n })\n .filter(animate => !isNil(animate));\n\n if (customAnimates.length === 1) {\n graphicAnimate.play(customAnimates[0]);\n } else {\n graphicAnimate.play(new AnimateGroup(duration, customAnimates));\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graph/animation/animator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAa5F,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAExH,OAAO,CAAC,IAAI,IAAI,WAAW,CAAC,oBAAoB,CAAC;AAEjD,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAEzB,MAAM,mBAAmB,GAAG,CAAC,MAAoE,EAAE,EAAE;IACnG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,SAAS,YAAY,cAAc,CAAC;AACtE,CAAC,CAAC;AAEF,MAAM,OAAO,QAAQ;IAUnB,YACE,OAAiB,EACjB,IAAoB,EACpB,gBAIC;QAhBH,OAAE,GAAW,gBAAgB,EAAE,CAAC;QAGhC,gBAAW,GAAY,KAAK,CAAC;QAGrB,aAAQ,GAAsB,EAAE,CAAC;QAYvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,QAAQ,CAAC,gBAA0C;QACjD,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,OAAO,I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AAO,EAAE,IAAI,CAAC,OAAO;wBACrB,UAAU,EAAE,sBAAsB;qBACnC,CAAC,CAAC;iBACJ;qBAAM,IAAI,eAAe,EAAE;oBAC1B,OAAO,IAAK,YAA4C,CACtD,UAAU,CAAC,IAAI,EACf,UAAU,CAAC,EAAE,EACb,QAAQ,EACR,MAAM,CAAC,MAAM,EACb,sBAAsB,CACvB,CAAC;iBACH;qBAAM,IAAI,UAAU,CAAC,EAAE,EAAE;oBACxB,OAAO,IAAI,gBAAgB,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;iBACtF;YACH,CAAC,CAAC;iBACD,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YAEtC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC/B,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;aACxC;iBAAM;gBACL,cAAc,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;aACjE;SACF;QAED,IAAI,UAAU,GAAG,CAAC,EAAE;YAClB,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SACjC;IACH,CAAC;CACF","file":"animator.js","sourcesContent":["import { isNil, isValidNumber } from '@visactor/vutils';\nimport type { IAnimate as IGraphicAnimate } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { ACustomAnimate, Animate, AnimateGroup, AnimateMode } from '@visactor/vrender-core';\nimport type {\n IAnimationChannelInterpolator,\n IAnimationCustomConstructor,\n IAnimationTimeline,\n IAnimator,\n IAnimatorOptions,\n IAnimationUnit,\n IAnimationParameters,\n IAnimationTimeSlice,\n IElement,\n IAnimationEffect\n} from '../../types';\nimport { AttributeAnimate, channelAnimationAttributes, CustomInterpolator, typeAnimationAttributes } from './attribute';\n\nAnimate.mode |= AnimateMode.SET_ATTR_IMMEDIATELY;\n\nlet GlobalAnimatorId = 0;\n\nconst isCustomAnimateCtor = (custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor) => {\n return !isNil(custom) && custom.prototype instanceof ACustomAnimate;\n};\n\nexport class Animator implements IAnimator {\n id: number = GlobalAnimatorId++;\n element: IElement;\n animationOptions: IAnimatorOptions;\n isAnimating: boolean = false;\n\n private unit: IAnimationUnit;\n private runnings: IGraphicAnimate[] = [];\n private callbackFunction: (...args: any[]) => any;\n\n constructor(\n element: IElement,\n unit: IAnimationUnit,\n animationOptions: {\n state: string;\n timeline: IAnimationTimeline;\n id: string;\n }\n ) {\n this.element = element;\n this.animationOptions = animationOptions;\n this.unit = unit;\n }\n\n callback(callbackFunction: (...args: any[]) => void): this {\n this.callbackFunction = callbackFunction;\n return this;\n }\n\n animate(animationParameters: IAnimationParameters, parameters: any): this {\n this.isAnimating = true;\n\n this.animateElement(animationParameters, parameters);\n\n // if no valid running, end animating immediately\n if (this.runnings.length === 0) {\n this.animationEnd();\n }\n return this;\n }\n\n stop(stopState: 'start' | 'end' = 'end', invokeCallback: boolean = true): this {\n // FIXME: wait for VRender to fix 'end' parameter\n this.runnings.forEach(running => running.stop(stopState));\n this.animationEnd(invokeCallback);\n return this;\n }\n\n pause(): this {\n this.runnings.forEach(running => running.pause());\n return this;\n }\n\n resume(): this {\n this.runnings.forEach(running => running.resume());\n return this;\n }\n\n startAt(startTime: number): this {\n this.runnings.forEach(running => {\n const initialDelay = this.unit.initialDelay;\n running.startAt(initialDelay + startTime);\n });\n return this;\n }\n\n getTotalAnimationTime() {\n const timeLineDuration = this.unit.initialDelay + this.unit.loopDuration * this.unit.loopCount;\n return this.unit.totalTime ?? timeLineDuration;\n }\n\n getEndAttributes() {\n return this.runnings.reduce((attributes, running) => {\n return Object.assign(attributes, running.getEndProps());\n }, {} as Record<string, any>);\n }\n\n private animationEnd(invokeCallback: boolean = true) {\n this.isAnimating = false;\n this.runnings = null;\n if (invokeCallback) {\n this.callbackFunction?.call(null);\n }\n }\n\n private animateElement(animationParameters: IAnimationParameters, parameters: any) {\n const graphicItem = this.element.getGraphicItem();\n\n if (!graphicItem) {\n return;\n }\n\n const graphicAnimate: IGraphicAnimate = graphicItem.animate();\n this.runnings.push(graphicAnimate);\n // initialDelay is only used at first loop\n graphicAnimate.startAt(this.unit.initialDelay);\n // execute loop animation\n graphicAnimate.wait(this.unit.loopDelay);\n this.unit.timeSlices.forEach(timeSlice => {\n this.animateTimeSlice(graphicAnimate, timeSlice, animationParameters, parameters);\n });\n graphicAnimate.wait(this.unit.loopDelayAfter);\n\n graphicAnimate.loop(this.unit.loopCount - 1);\n\n if (isValidNumber(this.unit.totalTime)) {\n // FIXME: use VRender api instead after VRender refactor is finished\n setTimeout(() => {\n if (graphicAnimate) {\n graphicAnimate.stop('end');\n }\n }, this.unit.totalTime);\n }\n\n graphicAnimate.onEnd(() => {\n this.runnings = this.runnings.filter(running => running !== graphicAnimate);\n if (this.runnings.length === 0) {\n this.animationEnd();\n }\n });\n }\n\n private animateTimeSlice(\n graphicAnimate: IGraphicAnimate,\n timeSlice: IAnimationTimeSlice,\n animationParameters: IAnimationParameters,\n parameters: any\n ) {\n const delay = timeSlice.delay as number;\n const delayAfter = timeSlice.delayAfter as number;\n const duration = timeSlice.duration as number;\n const effects = timeSlice.effects as IAnimationEffect[];\n\n // wait in loop animation before animation starts\n if (delay > 0) {\n graphicAnimate.wait(delay);\n }\n\n if (effects.length < 0) {\n graphicAnimate.wait(duration);\n } else {\n const customAnimates = effects\n .map((effect, index) => {\n const attributes =\n (effect.type\n ? typeAnimationAttributes(this.element, effect, animationParameters, parameters)\n : channelAnimationAttributes(this.element, effect, animationParameters, parameters)) ?? {};\n const customOption = attributes?.custom || effect?.custom;\n const customParametersOption = attributes?.customParameters || effect?.customParameters;\n\n if (\n attributes.from &&\n Object.keys(attributes.from).length &&\n this.unit &&\n this.animationOptions.timeline.controlOptions.immediatelyApply &&\n this.element.mark.markType !== 'component'\n ) {\n this.element.getGraphicItem().setAttributes(attributes.from);\n }\n\n const isCustomAnimate = isCustomAnimateCtor(customOption);\n const isCustomInterpolator = !isNil(customOption) && !isCustomAnimateCtor(customOption);\n\n if (isCustomInterpolator) {\n return new CustomInterpolator(attributes.from, attributes.to, duration, effect.easing, {\n interpolator: customOption as IAnimationChannelInterpolator,\n element: this.element,\n parameters: customParametersOption\n });\n } else if (isCustomAnimate) {\n return new (customOption as IAnimationCustomConstructor)(\n attributes.from,\n attributes.to,\n duration,\n effect.easing,\n customParametersOption\n );\n } else if (attributes.to) {\n return new AttributeAnimate(attributes.from, attributes.to, duration, effect.easing);\n }\n })\n .filter(animate => !isNil(animate));\n\n if (customAnimates.length === 1) {\n graphicAnimate.play(customAnimates[0]);\n } else {\n graphicAnimate.play(new AnimateGroup(duration, customAnimates));\n }\n }\n\n if (delayAfter > 0) {\n graphicAnimate.wait(delayAfter);\n }\n }\n}\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { array, isFunction, isNil, merge } from "@visactor/vutils";
|
|
2
2
|
|
|
3
|
-
import { DefaultAnimationControlOptions, DefaultAnimationDelay, DefaultAnimationDuration, DefaultAnimationEasing, DefaultAnimationLoop, DefaultAnimationOneByOne, DefaultAnimationStartTime } from "../constants";
|
|
3
|
+
import { DefaultAnimationControlOptions, DefaultAnimationDelay, DefaultAnimationDelayAfter, DefaultAnimationDuration, DefaultAnimationEasing, DefaultAnimationLoop, DefaultAnimationOneByOne, DefaultAnimationStartTime } from "../constants";
|
|
4
4
|
|
|
5
5
|
function transformToTimelineConfig(animationConfig) {
|
|
6
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
7
7
|
if (isNil(animationConfig.timeSlices)) {
|
|
8
8
|
const typeConfig = animationConfig;
|
|
9
9
|
return {
|
|
@@ -15,11 +15,12 @@ function transformToTimelineConfig(animationConfig) {
|
|
|
15
15
|
timeSlices: [ {
|
|
16
16
|
duration: null !== (_e = typeConfig.duration) && void 0 !== _e ? _e : DefaultAnimationDuration,
|
|
17
17
|
delay: null !== (_f = typeConfig.delay) && void 0 !== _f ? _f : DefaultAnimationDelay,
|
|
18
|
+
delayAfter: null !== (_g = typeConfig.delayAfter) && void 0 !== _g ? _g : DefaultAnimationDelayAfter,
|
|
18
19
|
effects: [ {
|
|
19
20
|
type: typeConfig.type,
|
|
20
21
|
channel: typeConfig.channel,
|
|
21
22
|
custom: typeConfig.custom,
|
|
22
|
-
easing: null !== (
|
|
23
|
+
easing: null !== (_h = typeConfig.easing) && void 0 !== _h ? _h : DefaultAnimationEasing,
|
|
23
24
|
customParameters: typeConfig.customParameters,
|
|
24
25
|
options: typeConfig.options
|
|
25
26
|
} ]
|
|
@@ -28,16 +29,17 @@ function transformToTimelineConfig(animationConfig) {
|
|
|
28
29
|
}
|
|
29
30
|
const formattedTimeSlices = array(animationConfig.timeSlices).filter((timeSlice => timeSlice.effects && array(timeSlice.effects).filter((effect => effect.channel || effect.type)).length));
|
|
30
31
|
if (formattedTimeSlices.length) return {
|
|
31
|
-
startTime: null !== (
|
|
32
|
+
startTime: null !== (_j = animationConfig.startTime) && void 0 !== _j ? _j : DefaultAnimationStartTime,
|
|
32
33
|
totalTime: animationConfig.totalTime,
|
|
33
|
-
oneByOne: null !== (
|
|
34
|
-
loop: null !== (
|
|
35
|
-
controlOptions: merge({}, DefaultAnimationControlOptions, null !== (
|
|
34
|
+
oneByOne: null !== (_k = animationConfig.oneByOne) && void 0 !== _k ? _k : DefaultAnimationOneByOne,
|
|
35
|
+
loop: null !== (_l = animationConfig.loop) && void 0 !== _l ? _l : DefaultAnimationLoop,
|
|
36
|
+
controlOptions: merge({}, DefaultAnimationControlOptions, null !== (_m = animationConfig.controlOptions) && void 0 !== _m ? _m : {}),
|
|
36
37
|
timeSlices: formattedTimeSlices.map((timeSlice => {
|
|
37
|
-
var _a;
|
|
38
|
+
var _a, _b;
|
|
38
39
|
return {
|
|
39
40
|
duration: timeSlice.duration,
|
|
40
41
|
delay: null !== (_a = timeSlice.delay) && void 0 !== _a ? _a : DefaultAnimationDelay,
|
|
42
|
+
delayAfter: null !== (_b = timeSlice.delayAfter) && void 0 !== _b ? _b : DefaultAnimationDelayAfter,
|
|
41
43
|
effects: array(timeSlice.effects).filter((effect => effect.channel || effect.type)).map((effect => {
|
|
42
44
|
var _a;
|
|
43
45
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/animation/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AASnE,OAAO,EACL,8BAA8B,EAC9B,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,cAAc,CAAC;AAEtB,SAAS,yBAAyB,CAAC,eAAiC;;IAClE,IAAI,KAAK,CAAE,eAAsC,CAAC,UAAU,CAAC,EAAE;QAC7D,MAAM,UAAU,GAAG,eAAuC,CAAC;QAE3D,OAAO;YACL,SAAS,EAAE,MAAA,UAAU,CAAC,SAAS,mCAAI,yBAAyB;YAC5D,SAAS,EAAE,UAAU,CAAC,SAAS;YAC/B,QAAQ,EAAE,MAAA,UAAU,CAAC,QAAQ,mCAAI,wBAAwB;YACzD,IAAI,EAAE,MAAA,UAAU,CAAC,IAAI,mCAAI,oBAAoB;YAC7C,cAAc,EAAE,KAAK,CAAC,EAAE,EAAE,8BAA8B,EAAE,MAAA,UAAU,CAAC,cAAc,mCAAI,EAAE,CAAC;YAC1F,UAAU,EAAE;gBACV;oBACE,QAAQ,EAAE,MAAA,UAAU,CAAC,QAAQ,mCAAI,wBAAwB;oBACzD,KAAK,EAAE,MAAA,UAAU,CAAC,KAAK,mCAAI,qBAAqB;oBAChD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B,gBAAgB,CAAC,IAAI,CAAC;gBACpB,KAAK;gBACL,EAAE,EAAE,MAAA,cAAc,CAAC,EAAE,mCAAI,GAAG,KAAK,IAAI,KAAK,EAAE;gBAC5C,QAAQ,EAAE,cAAc;gBACxB,YAAY,EAAE,eAAe;aAC9B,CAAC,CAAC;YACH,KAAK,IAAI,CAAC,CAAC;SACZ;IACH,CAAC,CAAC,CAAC;IACH,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAI,IAA8B,EAAE,OAAiB,EAAE,UAAe;IACrG,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;KACjE;IACD,OAAO,IAAI,CAAC;AACd,CAAC","file":"config.js","sourcesContent":["import { array, isFunction, isNil, merge } from '@visactor/vutils';\nimport type { IElement } from '../../types';\nimport type {\n IAnimationConfig,\n IAnimationTimeline,\n IAnimationTypeConfig,\n IParsedAnimationConfig,\n MarkFunctionValueType\n} from '../../types/animate';\nimport {\n DefaultAnimationControlOptions,\n DefaultAnimationDelay,\n DefaultAnimationDuration,\n DefaultAnimationEasing,\n DefaultAnimationLoop,\n DefaultAnimationOneByOne,\n DefaultAnimationStartTime\n} from '../constants';\n\nfunction transformToTimelineConfig(animationConfig: IAnimationConfig): IAnimationTimeline {\n if (isNil((animationConfig as IAnimationTimeline).timeSlices)) {\n const typeConfig = animationConfig as IAnimationTypeConfig;\n // transform type animation config into timeline animation config\n return {\n startTime: typeConfig.startTime ?? DefaultAnimationStartTime,\n totalTime: typeConfig.totalTime,\n oneByOne: typeConfig.oneByOne ?? DefaultAnimationOneByOne,\n loop: typeConfig.loop ?? DefaultAnimationLoop,\n controlOptions: merge({}, DefaultAnimationControlOptions, typeConfig.controlOptions ?? {}),\n timeSlices: [\n {\n duration: typeConfig.duration ?? DefaultAnimationDuration,\n delay: typeConfig.delay ?? DefaultAnimationDelay,\n effects: [\n {\n type: typeConfig.type,\n channel: typeConfig.channel,\n custom: typeConfig.custom,\n easing: typeConfig.easing ?? DefaultAnimationEasing,\n customParameters: typeConfig.customParameters,\n options: typeConfig.options\n }\n ]\n }\n ]\n };\n }\n\n const timeSlices = array((animationConfig as IAnimationTimeline).timeSlices);\n const formattedTimeSlices = timeSlices.filter(timeSlice => {\n return timeSlice.effects && array(timeSlice.effects).filter(effect => effect.channel || effect.type).length;\n });\n\n if (formattedTimeSlices.length) {\n // fill up default animation config\n return {\n startTime: (animationConfig as IAnimationTimeline).startTime ?? DefaultAnimationStartTime,\n totalTime: (animationConfig as IAnimationTimeline).totalTime,\n oneByOne: (animationConfig as IAnimationTimeline).oneByOne ?? DefaultAnimationOneByOne,\n loop: (animationConfig as IAnimationTimeline).loop ?? DefaultAnimationLoop,\n controlOptions: merge({}, DefaultAnimationControlOptions, animationConfig.controlOptions ?? {}),\n timeSlices: formattedTimeSlices.map(timeSlice => {\n return {\n duration: timeSlice.duration,\n delay: timeSlice.delay ?? DefaultAnimationDelay,\n effects: array(timeSlice.effects)\n .filter(effect => effect.channel || effect.type)\n .map(effect => {\n return {\n type: effect.type,\n channel: effect.channel,\n custom: effect.custom,\n easing: effect.easing ?? DefaultAnimationEasing,\n customParameters: effect.customParameters,\n options: effect.options\n };\n })\n };\n }),\n partitioner: (animationConfig as IAnimationTimeline).partitioner,\n sort: (animationConfig as IAnimationTimeline).sort\n };\n }\n\n return;\n}\n\nexport function normalizeAnimationConfig(\n config: Record<string, IAnimationConfig | IAnimationConfig[]>\n): Array<IParsedAnimationConfig> {\n let normalizedConfig: Array<IParsedAnimationConfig> = [];\n\n Object.keys(config).forEach(state => {\n normalizedConfig = normalizedConfig.concat(normalizeStateAnimationConfig(state, config[state]));\n });\n return normalizedConfig;\n}\n\nexport function normalizeStateAnimationConfig(\n state: string,\n config: IAnimationConfig | IAnimationConfig[],\n initialIndex: number = 0\n): Array<IParsedAnimationConfig> {\n const normalizedConfig: Array<IParsedAnimationConfig> = [];\n let index = initialIndex;\n array(config).forEach(animationConfig => {\n const timelineConfig = transformToTimelineConfig(animationConfig);\n if (timelineConfig) {\n normalizedConfig.push({\n state,\n id: timelineConfig.id ?? `${state}-${index}`,\n timeline: timelineConfig,\n originConfig: animationConfig\n });\n index += 1;\n }\n });\n return normalizedConfig;\n}\n\nexport function invokeAnimateSpec<T>(spec: MarkFunctionValueType<T>, element: IElement, parameters: any): T {\n if (isFunction(spec)) {\n return spec.call(null, element.getDatum(), element, parameters);\n }\n return spec;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graph/animation/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AASnE,OAAO,EACL,8BAA8B,EAC9B,qBAAqB,EACrB,0BAA0B,EAC1B,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,cAAc,CAAC;AAEtB,SAAS,yBAAyB,CAAC,eAAiC;;IAClE,IAAI,KAAK,CAAE,eAAsC,CAAC,UAAU,CAAC,EAAE;QAC7D,MAAM,UAAU,GAAG,eAAuC,CAAC;QAE3D,OAAO;YACL,SAAS,EAAE,MAAA,UAAU,CAAC,SAAS,mCAAI,yBAAyB;YAC5D,SAAS,EAAE,UAAU,CAAC,SAAS;YAC/B,QAAQ,EAAE,MAAA,UAAU,CAAC,QAAQ,mCAAI,wBAAwB;YACzD,IAAI,EAAE,MAAA,UAAU,CAAC,IAAI,mCAAI,oBAAoB;YAC7C,cAAc,EAAE,KAAK,CAAC,EAAE,EAAE,8BAA8B,EAAE,MAAA,UAAU,CAAC,cAAc,mCAAI,EAAE,CAAC;YAC1F,UAAU,EAAE;gBACV;oBACE,QAAQ,EAAE,MAAA,UAAU,CAAC,QAAQ,mCAAI,wBAAwB;oBACzD,KAAK,EA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GAAG,YAAY,CAAC;IACzB,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE;;QACtC,MAAM,cAAc,GAAG,yBAAyB,CAAC,eAAe,CAAC,CAAC;QAClE,IAAI,cAAc,EAAE;YAClB,gBAAgB,CAAC,IAAI,CAAC;gBACpB,KAAK;gBACL,EAAE,EAAE,MAAA,cAAc,CAAC,EAAE,mCAAI,GAAG,KAAK,IAAI,KAAK,EAAE;gBAC5C,QAAQ,EAAE,cAAc;gBACxB,YAAY,EAAE,eAAe;aAC9B,CAAC,CAAC;YACH,KAAK,IAAI,CAAC,CAAC;SACZ;IACH,CAAC,CAAC,CAAC;IACH,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAI,IAA8B,EAAE,OAAiB,EAAE,UAAe;IACrG,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;KACjE;IACD,OAAO,IAAI,CAAC;AACd,CAAC","file":"config.js","sourcesContent":["import { array, isFunction, isNil, merge } from '@visactor/vutils';\nimport type { IElement } from '../../types';\nimport type {\n IAnimationConfig,\n IAnimationTimeline,\n IAnimationTypeConfig,\n IParsedAnimationConfig,\n MarkFunctionValueType\n} from '../../types/animate';\nimport {\n DefaultAnimationControlOptions,\n DefaultAnimationDelay,\n DefaultAnimationDelayAfter,\n DefaultAnimationDuration,\n DefaultAnimationEasing,\n DefaultAnimationLoop,\n DefaultAnimationOneByOne,\n DefaultAnimationStartTime\n} from '../constants';\n\nfunction transformToTimelineConfig(animationConfig: IAnimationConfig): IAnimationTimeline {\n if (isNil((animationConfig as IAnimationTimeline).timeSlices)) {\n const typeConfig = animationConfig as IAnimationTypeConfig;\n // transform type animation config into timeline animation config\n return {\n startTime: typeConfig.startTime ?? DefaultAnimationStartTime,\n totalTime: typeConfig.totalTime,\n oneByOne: typeConfig.oneByOne ?? DefaultAnimationOneByOne,\n loop: typeConfig.loop ?? DefaultAnimationLoop,\n controlOptions: merge({}, DefaultAnimationControlOptions, typeConfig.controlOptions ?? {}),\n timeSlices: [\n {\n duration: typeConfig.duration ?? DefaultAnimationDuration,\n delay: typeConfig.delay ?? DefaultAnimationDelay,\n delayAfter: typeConfig.delayAfter ?? DefaultAnimationDelayAfter,\n effects: [\n {\n type: typeConfig.type,\n channel: typeConfig.channel,\n custom: typeConfig.custom,\n easing: typeConfig.easing ?? DefaultAnimationEasing,\n customParameters: typeConfig.customParameters,\n options: typeConfig.options\n }\n ]\n }\n ]\n };\n }\n\n const timeSlices = array((animationConfig as IAnimationTimeline).timeSlices);\n const formattedTimeSlices = timeSlices.filter(timeSlice => {\n return timeSlice.effects && array(timeSlice.effects).filter(effect => effect.channel || effect.type).length;\n });\n\n if (formattedTimeSlices.length) {\n // fill up default animation config\n return {\n startTime: (animationConfig as IAnimationTimeline).startTime ?? DefaultAnimationStartTime,\n totalTime: (animationConfig as IAnimationTimeline).totalTime,\n oneByOne: (animationConfig as IAnimationTimeline).oneByOne ?? DefaultAnimationOneByOne,\n loop: (animationConfig as IAnimationTimeline).loop ?? DefaultAnimationLoop,\n controlOptions: merge({}, DefaultAnimationControlOptions, animationConfig.controlOptions ?? {}),\n timeSlices: formattedTimeSlices.map(timeSlice => {\n return {\n duration: timeSlice.duration,\n delay: timeSlice.delay ?? DefaultAnimationDelay,\n delayAfter: timeSlice.delayAfter ?? DefaultAnimationDelayAfter,\n effects: array(timeSlice.effects)\n .filter(effect => effect.channel || effect.type)\n .map(effect => {\n return {\n type: effect.type,\n channel: effect.channel,\n custom: effect.custom,\n easing: effect.easing ?? DefaultAnimationEasing,\n customParameters: effect.customParameters,\n options: effect.options\n };\n })\n };\n }),\n partitioner: (animationConfig as IAnimationTimeline).partitioner,\n sort: (animationConfig as IAnimationTimeline).sort\n };\n }\n\n return;\n}\n\nexport function normalizeAnimationConfig(\n config: Record<string, IAnimationConfig | IAnimationConfig[]>\n): Array<IParsedAnimationConfig> {\n let normalizedConfig: Array<IParsedAnimationConfig> = [];\n\n Object.keys(config).forEach(state => {\n normalizedConfig = normalizedConfig.concat(normalizeStateAnimationConfig(state, config[state]));\n });\n return normalizedConfig;\n}\n\nexport function normalizeStateAnimationConfig(\n state: string,\n config: IAnimationConfig | IAnimationConfig[],\n initialIndex: number = 0\n): Array<IParsedAnimationConfig> {\n const normalizedConfig: Array<IParsedAnimationConfig> = [];\n let index = initialIndex;\n array(config).forEach(animationConfig => {\n const timelineConfig = transformToTimelineConfig(animationConfig);\n if (timelineConfig) {\n normalizedConfig.push({\n state,\n id: timelineConfig.id ?? `${state}-${index}`,\n timeline: timelineConfig,\n originConfig: animationConfig\n });\n index += 1;\n }\n });\n return normalizedConfig;\n}\n\nexport function invokeAnimateSpec<T>(spec: MarkFunctionValueType<T>, element: IElement, parameters: any): T {\n if (isFunction(spec)) {\n return spec.call(null, element.getDatum(), element, parameters);\n }\n return spec;\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { IElement } from '../../types';
|
|
2
2
|
export declare function getLineSegmentConfigs(items: any[], points: any[], element?: IElement): any[];
|
|
3
3
|
export declare function getLinePointsFromSegments(segments: any[]): any;
|
|
4
|
+
export declare function parseCollectionMarkAttributes(itemNextAttrs: any): {};
|
|
@@ -30,7 +30,7 @@ export function getLineSegmentConfigs(items, points, element) {
|
|
|
30
30
|
startIndex: index
|
|
31
31
|
}));
|
|
32
32
|
})), segments.length >= 2 ? segments.map((entry => {
|
|
33
|
-
const res = transformAttributes(GrammarMarkType.line, entry.attrs, element);
|
|
33
|
+
const res = transformAttributes(GrammarMarkType.line, parseCollectionMarkAttributes(entry.attrs), element);
|
|
34
34
|
return res.points = points.slice(entry.startIndex, isNil(entry.endIndex) ? points.length : entry.endIndex),
|
|
35
35
|
res;
|
|
36
36
|
})) : null;
|
|
@@ -39,4 +39,11 @@ export function getLineSegmentConfigs(items, points, element) {
|
|
|
39
39
|
export function getLinePointsFromSegments(segments) {
|
|
40
40
|
return segments ? segments.reduce(((points, segment) => points.concat(segment.points)), []) : null;
|
|
41
41
|
}
|
|
42
|
+
|
|
43
|
+
export function parseCollectionMarkAttributes(itemNextAttrs) {
|
|
44
|
+
const result = {};
|
|
45
|
+
return itemNextAttrs ? (Object.keys(itemNextAttrs).forEach((key => {
|
|
46
|
+
"x" !== key && "y" !== key && "x1" !== key && "y1" !== key && "defined" !== key && "size" !== key && "width" !== key && "height" !== key && "context" !== key && (result[key] = itemNextAttrs[key]);
|
|
47
|
+
})), result) : result;
|
|
48
|
+
}
|
|
42
49
|
//# sourceMappingURL=line.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/attributes/line.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,MAAM,YAAY,GAAG,CAAC,IAAkB,EAAE,IAAkB,EAAE,EAAE;;IAC9D,IAAI,IAAI,KAAK,IAAI,EAAE;QACjB,OAAO,IAAI,CAAC;KACb;IACD,MAAM,UAAU,GAAG,MAAA,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,mCAAI,CAAC,CAAC;IAC9C,MAAM,UAAU,GAAG,MAAA,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,mCAAI,CAAC,CAAC;IAE9C,IAAI,UAAU,KAAK,UAAU,IAAI,UAAU,KAAK,CAAC,EAAE;QACjD,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;QACzC,OAAO,CACL,CAAC,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,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AO,CAAC,GAAG,CAAC,EAAE;QACvC,IACE,GAAG,KAAK,GAAG;YACX,GAAG,KAAK,GAAG;YACX,GAAG,KAAK,IAAI;YACZ,GAAG,KAAK,IAAI;YACZ,GAAG,KAAK,SAAS;YACjB,GAAG,KAAK,MAAM;YACd,GAAG,KAAK,OAAO;YACf,GAAG,KAAK,QAAQ;YAChB,GAAG,KAAK,SAAS,EACjB;YACA,OAAO;SACR;QACD,MAAM,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","file":"line.js","sourcesContent":["import type { IColor, IColorStop } from '@visactor/vrender-core';\nimport { isNil, isString } from '@visactor/vutils';\nimport { transformAttributes } from './transform';\nimport { GrammarMarkType } from '../enums';\nimport type { IElement } from '../../types';\n\nconst isStopsEqual = (prev: IColorStop[], next: IColorStop[]) => {\n if (prev === next) {\n return true;\n }\n const prevLength = (prev && prev.length) ?? 0;\n const nextLength = (next && next.length) ?? 0;\n\n if (prevLength !== nextLength || prevLength === 0) {\n return false;\n }\n\n return prev.every((prevEntry, prevIndex) => {\n return (\n (!prevEntry && !next[prevIndex]) ||\n (prevEntry &&\n next[prevIndex] &&\n prevEntry.color === next[prevIndex].color &&\n prevEntry.offset === next[prevIndex].offset)\n );\n });\n};\n\nconst isColorAttrEqual = (prev: IColor, next: IColor) => {\n if (prev === next) {\n return true;\n }\n\n if (typeof prev !== typeof next) {\n return false;\n }\n\n if (isString(prev)) {\n return false;\n }\n\n if (prev.gradient !== (next as any).gradient) {\n return false;\n }\n\n const prevKeys = Object.keys(prev);\n const nextKeys = Object.keys(next);\n\n if (prevKeys.length !== nextKeys.length) {\n return false;\n }\n\n return prevKeys.every(key => {\n if (key === 'stops') {\n return isStopsEqual(prev[key], next[key]);\n }\n\n return prev[key] === next[key];\n });\n};\n\nconst isLineDashEqual = (prev: number[], next: number[]) => {\n if (prev.length !== next.length) {\n return false;\n }\n\n if (prev.join('-') === next.join('-')) {\n return true;\n }\n\n return false;\n};\n\nconst isSegmentAttrEqual = (prev: any, next: any, key: string) => {\n if (isNil(prev) && isNil(next)) {\n return true;\n }\n\n if (isNil(prev)) {\n return false;\n }\n\n if (isNil(next)) {\n return false;\n }\n\n if (key === 'lineDash') {\n return isLineDashEqual(prev, next);\n }\n\n if (key === 'stroke' || key === 'fill') {\n return isColorAttrEqual(prev, next);\n }\n\n return prev === next;\n};\n\nconst fillAttrs = ['fill', 'fillOpacity', 'background', 'texture', 'texturePadding', 'textureSize', 'textureColor'];\nconst strokeAttrs = [\n 'stroke',\n 'strokeOpacity',\n 'lineDash',\n 'lineDashOffset',\n 'lineCap',\n 'lineJoin',\n 'lineWidth',\n 'miterLimit'\n];\nconst areaAttrs = fillAttrs.concat(strokeAttrs);\n\n/**\n * 生成用于渲染的点数组\n * @param {*} item\n * @returns {IPointLike[]}\n */\nexport function getLineSegmentConfigs(items: any[], points: any[], element?: IElement) {\n if (!items || items.length <= 1) {\n return null;\n }\n\n const checkAttributes = element?.mark?.markType === 'area' ? areaAttrs : strokeAttrs;\n\n const segments: any[] = [];\n let prevSegmentAttrs: any = null;\n\n items.forEach((item, index) => {\n if (\n !prevSegmentAttrs ||\n !checkAttributes.every(key => {\n return isSegmentAttrEqual(prevSegmentAttrs[key], item[key], key);\n })\n ) {\n if (segments.length) {\n segments[segments.length - 1].endIndex = index;\n }\n\n prevSegmentAttrs = item;\n segments.push({\n attrs: prevSegmentAttrs,\n startIndex: index\n });\n }\n });\n\n if (segments.length >= 2) {\n return segments.map(entry => {\n const res = transformAttributes(GrammarMarkType.line, parseCollectionMarkAttributes(entry.attrs), element) as any;\n\n res.points = points.slice(entry.startIndex, isNil(entry.endIndex) ? points.length : entry.endIndex);\n return res;\n });\n }\n\n return null;\n}\n\nexport function getLinePointsFromSegments(segments: any[]) {\n if (!segments) {\n return null;\n }\n return segments.reduce((points, segment) => {\n return points.concat(segment.points);\n }, []);\n}\n\nexport function parseCollectionMarkAttributes(itemNextAttrs: any) {\n const result = {};\n\n if (!itemNextAttrs) {\n return result;\n }\n\n Object.keys(itemNextAttrs).forEach(key => {\n if (\n key === 'x' ||\n key === 'y' ||\n key === 'x1' ||\n key === 'y1' ||\n key === 'defined' ||\n key === 'size' ||\n key === 'width' ||\n key === 'height' ||\n key === 'context'\n ) {\n return;\n }\n result[key] = itemNextAttrs[key];\n });\n\n return result;\n}\n"]}
|
|
@@ -16,30 +16,6 @@ function storeOriginAttributes(name, channels, graphicAttributes, nextAttrs, ele
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export const transformsByType = {
|
|
19
|
-
[GrammarMarkType.largeRects]: [ {
|
|
20
|
-
channels: [ "x", "y", "y1", "x1", "width", "height" ],
|
|
21
|
-
transform: (graphicAttributes, nextAttrs, storedAttrs) => {
|
|
22
|
-
graphicAttributes.x = 0, graphicAttributes.y = 0;
|
|
23
|
-
}
|
|
24
|
-
} ],
|
|
25
|
-
[GrammarMarkType.largeSymbols]: [ {
|
|
26
|
-
channels: [ "x", "y", "size" ],
|
|
27
|
-
transform: (graphicAttributes, nextAttrs, storedAttrs) => {
|
|
28
|
-
graphicAttributes.x = 0, graphicAttributes.y = 0;
|
|
29
|
-
}
|
|
30
|
-
} ],
|
|
31
|
-
[GrammarMarkType.area]: [ {
|
|
32
|
-
channels: [ "x", "y", "x1", "y1" ],
|
|
33
|
-
transform: (graphicAttributes, nextAttrs, storedAttrs) => {
|
|
34
|
-
graphicAttributes.x = 0, graphicAttributes.y = 0, graphicAttributes.x1 = 0, graphicAttributes.y1 = 0;
|
|
35
|
-
}
|
|
36
|
-
} ],
|
|
37
|
-
[GrammarMarkType.line]: [ {
|
|
38
|
-
channels: [ "x", "y", "defined", "enableSegments" ],
|
|
39
|
-
transform: (graphicAttributes, nextAttrs, storedAttrs) => {
|
|
40
|
-
graphicAttributes.x = 0, graphicAttributes.y = 0;
|
|
41
|
-
}
|
|
42
|
-
} ],
|
|
43
19
|
[GrammarMarkType.rect]: [ {
|
|
44
20
|
channels: [ "x", "y", "x1", "y1", "width", "height" ],
|
|
45
21
|
transform: (graphicAttributes, nextAttrs, storedAttrs) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/attributes/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAEtE,SAAS,qBAAqB,CAC5B,IAAY,EACZ,QAAkB,EAClB,iBAAsB,EACtB,SAAc,EACd,OAAiB,EACjB,QAAgB;;IAEhB,MAAM,eAAe,GAAG,MAAC,OAAyB,CAAC,mBAAmB,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,mCAAI,EAAE,CAAC;IACpG,MAAM,WAAW,GAAG,EAAE,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;;QACzB,WAAW,CAAC,OAAO,CAAC,GAAG,MAAA,SAAS,CAAC,OAAO,CAAC,mCAAI,eAAe,CAAC,OAAO,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;IACH,iBAAiB,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC;IACtC,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAyC;IACpE,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE;QAC5B;YACE,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC;YACnD,SAAS,EAAE,CAAC,iBAAsB,EAAE,SAAc,EAAE,WAAgB,EAAE,EAAE;g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,EAAE;oBAClC,wBAAwB,CAAC,iBAAiB,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;iBAC7D;qBAAM;oBACL,iBAAiB,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;iBACzC;aACF;QACH,CAAC,CAAC,CAAC;KACJ;SAAM;QACL,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACxB,IAAI,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBAClC,wBAAwB,CAAC,iBAAiB,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;aAC7D;iBAAM;gBACL,iBAAiB,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;aACzC;QACH,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC","file":"transform.js","sourcesContent":["import { has, isNil, isPlainObject, isString, isValidNumber } from '@visactor/vutils';\nimport type { IElement, IGlyphElement } from '../../types/element';\nimport type { AttributeTransform, MarkType } from '../../types/mark';\nimport { GrammarMarkType } from '../enums';\nimport { getRulePoints } from './helpers';\nimport { commonAttributes, transformCommonAttribute } from './common';\n\nfunction storeOriginAttributes(\n name: string,\n channels: string[],\n graphicAttributes: any,\n nextAttrs: any,\n element: IElement,\n markName: string\n): Record<string, any> {\n const prevStoredAttrs = (element as IGlyphElement).getGraphicAttribute(name, false, markName) ?? {};\n const storedAttrs = {};\n channels.forEach(channel => {\n storedAttrs[channel] = nextAttrs[channel] ?? prevStoredAttrs[channel];\n });\n graphicAttributes[name] = storedAttrs;\n return storedAttrs;\n}\n\nexport const transformsByType: Record<string, AttributeTransform[]> = {\n [GrammarMarkType.largeRects]: [\n {\n channels: ['x', 'y', 'y1', 'x1', 'width', 'height'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.x = 0;\n graphicAttributes.y = 0;\n }\n }\n ],\n [GrammarMarkType.largeSymbols]: [\n {\n channels: ['x', 'y', 'size'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.x = 0;\n graphicAttributes.y = 0;\n }\n }\n ],\n [GrammarMarkType.area]: [\n {\n channels: ['x', 'y', 'x1', 'y1'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.x = 0;\n graphicAttributes.y = 0;\n graphicAttributes.x1 = 0;\n graphicAttributes.y1 = 0;\n }\n }\n ],\n [GrammarMarkType.line]: [\n {\n channels: ['x', 'y', 'defined', 'enableSegments'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.x = 0;\n graphicAttributes.y = 0;\n }\n }\n ],\n [GrammarMarkType.rect]: [\n {\n channels: ['x', 'y', 'x1', 'y1', 'width', 'height'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n // width\n if (isValidNumber(nextAttrs.width) || (!isValidNumber(nextAttrs.x1) && isValidNumber(storedAttrs.width))) {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n } else if (isValidNumber(nextAttrs.x1) || (!isValidNumber(nextAttrs.width) && isValidNumber(storedAttrs.x1))) {\n graphicAttributes.x = Math.min(storedAttrs.x, storedAttrs.x1);\n graphicAttributes.width = Math.abs(storedAttrs.x1 - storedAttrs.x);\n } else {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n }\n\n // height\n if (isValidNumber(nextAttrs.height) || (!isValidNumber(nextAttrs.y1) && isValidNumber(storedAttrs.height))) {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n } else if (isValidNumber(nextAttrs.y1) || (!isValidNumber(nextAttrs.height) && isValidNumber(storedAttrs.y1))) {\n graphicAttributes.y = Math.min(storedAttrs.y, storedAttrs.y1);\n graphicAttributes.height = Math.abs(storedAttrs.y1 - storedAttrs.y);\n } else {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n }\n },\n storedAttrs: 'sizeAttrs'\n }\n ],\n rect3d: [\n {\n channels: ['x', 'y', 'z', 'x1', 'y1', 'width', 'height', 'length'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n // width\n if (isValidNumber(nextAttrs.width) || (!isValidNumber(nextAttrs.x1) && isValidNumber(storedAttrs.width))) {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n } else if (isValidNumber(nextAttrs.x1) || (!isValidNumber(nextAttrs.width) && isValidNumber(storedAttrs.x1))) {\n graphicAttributes.x = Math.min(storedAttrs.x, storedAttrs.x1);\n graphicAttributes.width = Math.abs(storedAttrs.x1 - storedAttrs.x);\n } else {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n }\n\n // height\n if (isValidNumber(nextAttrs.height) || (!isValidNumber(nextAttrs.y1) && isValidNumber(storedAttrs.height))) {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n } else if (isValidNumber(nextAttrs.y1) || (!isValidNumber(nextAttrs.height) && isValidNumber(storedAttrs.y1))) {\n graphicAttributes.y = Math.min(storedAttrs.y, storedAttrs.y1);\n graphicAttributes.height = Math.abs(storedAttrs.y1 - storedAttrs.y);\n } else {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n }\n\n // length\n if (isValidNumber(nextAttrs.length) || (!isValidNumber(nextAttrs.z1) && isValidNumber(storedAttrs.length))) {\n graphicAttributes.z = Math.min(storedAttrs.z ?? 0, storedAttrs.z1 ?? Infinity);\n graphicAttributes.length = storedAttrs.length;\n } else if (isValidNumber(nextAttrs.z1) || (!isValidNumber(nextAttrs.length) && isValidNumber(storedAttrs.z1))) {\n graphicAttributes.z = Math.min(storedAttrs.z, storedAttrs.z1);\n graphicAttributes.length = Math.abs(storedAttrs.z1 - storedAttrs.z);\n } else {\n graphicAttributes.z = Math.min(storedAttrs.z ?? 0, storedAttrs.z1 ?? Infinity);\n graphicAttributes.length = storedAttrs.length;\n }\n },\n storedAttrs: 'sizeAttrs'\n }\n ],\n [GrammarMarkType.text]: [\n {\n channels: ['text', 'limit', 'autoLimit', 'maxLineWidth'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n const limit = storedAttrs.limit ?? Infinity;\n const autoLimit = storedAttrs.autoLimit ?? Infinity;\n const maxWidth = Math.min(limit, autoLimit);\n const isTextConfig = isPlainObject(storedAttrs.text) && !isNil(storedAttrs.text.text);\n const text = isTextConfig ? storedAttrs.text.text : storedAttrs.text;\n\n if (Array.isArray(text)) {\n graphicAttributes.maxLineWidth = maxWidth === Infinity ? storedAttrs.maxLineWidth : maxWidth;\n } else {\n graphicAttributes.maxLineWidth = maxWidth === Infinity ? storedAttrs.maxLineWidth : maxWidth;\n }\n\n if (isTextConfig) {\n if (storedAttrs.text.type === 'html') {\n graphicAttributes.html = {\n dom: text,\n width: nextAttrs.width ?? maxWidth,\n height: nextAttrs.height ?? nextAttrs.fontSize,\n anchorType: 'position'\n };\n graphicAttributes.text = '';\n } else if (storedAttrs.text.type === 'rich') {\n graphicAttributes.textConfig = text;\n } else {\n graphicAttributes.text = text;\n }\n } else {\n graphicAttributes.text = text;\n }\n },\n storedAttrs: 'limitAttrs'\n }\n ],\n [GrammarMarkType.rule]: [\n {\n channels: ['x', 'y', 'x1', 'y1'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n const points = getRulePoints(storedAttrs);\n graphicAttributes.points = points;\n graphicAttributes.x = 0;\n graphicAttributes.y = 0;\n },\n storedAttrs: 'pointAttrs'\n }\n ],\n [GrammarMarkType.symbol]: [\n {\n channels: ['shape', 'symbolType'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.symbolType = nextAttrs.shape ?? nextAttrs.symbolType;\n }\n },\n {\n channels: ['image', 'fill', 'background'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n if (nextAttrs.image) {\n graphicAttributes.background = nextAttrs.image;\n graphicAttributes.fill = false;\n } else if (storedAttrs.image) {\n graphicAttributes.background = storedAttrs.image;\n graphicAttributes.fill = false;\n } else {\n graphicAttributes.fill = storedAttrs.fill;\n graphicAttributes.background = storedAttrs.background;\n }\n },\n storedAttrs: 'imageAttrs'\n }\n ],\n [GrammarMarkType.richtext]: [\n {\n channels: ['text', 'textConfig'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.text = null;\n\n if (nextAttrs.text?.type === 'rich') {\n graphicAttributes.textConfig = nextAttrs.text.text;\n } else if (nextAttrs.textConfig?.type === 'html') {\n graphicAttributes.html = {\n dom: nextAttrs.textConfig.text,\n width: nextAttrs.width,\n height: nextAttrs.height ?? nextAttrs.fontSize,\n anchorType: 'position'\n };\n graphicAttributes.text = '';\n } else if (nextAttrs.textConfig?.type === 'rich') {\n graphicAttributes.textConfig = nextAttrs.textConfig.text;\n } else {\n graphicAttributes.textConfig = nextAttrs.textConfig;\n }\n }\n }\n ]\n};\n\nexport function cloneTransformAttributes(markType: MarkType, attributes: any) {\n const transforms = transformsByType[markType] ?? [];\n return transforms.reduce((clonedAttributes, transform) => {\n transform.channels.forEach(channel => {\n if (has(attributes, channel)) {\n clonedAttributes[channel] = attributes[channel];\n }\n });\n return clonedAttributes;\n }, {} as any);\n}\n\nexport const transformAttributes = (\n markType: MarkType | AttributeTransform[],\n nextAttrs: any,\n element: IElement,\n markName?: string\n) => {\n const graphicAttributes = {};\n const changedKeys = nextAttrs ? Object.keys(nextAttrs) : [];\n const transforms: AttributeTransform[] = isString(markType)\n ? transformsByType[markType]\n : (markType as AttributeTransform[]);\n\n if (transforms?.length) {\n const tags: boolean[] = [];\n\n changedKeys.forEach(key => {\n let isTransformed = false;\n\n transforms.forEach((transform, index) => {\n if (transform.channels.includes(key)) {\n if (!tags[index]) {\n if (transform.storedAttrs) {\n const storedAttrs = storeOriginAttributes(\n transform.storedAttrs,\n transform.channels,\n graphicAttributes,\n nextAttrs,\n element,\n markName\n );\n transform.transform(graphicAttributes, nextAttrs, storedAttrs);\n } else {\n transform.transform(graphicAttributes, nextAttrs, null);\n }\n }\n // 记录一下,不重复处理\n tags[index] = true;\n isTransformed = true;\n }\n });\n\n if (!isTransformed) {\n if (commonAttributes.includes(key)) {\n transformCommonAttribute(graphicAttributes, key, nextAttrs);\n } else {\n graphicAttributes[key] = nextAttrs[key];\n }\n }\n });\n } else {\n changedKeys.forEach(key => {\n if (commonAttributes.includes(key)) {\n transformCommonAttribute(graphicAttributes, key, nextAttrs);\n } else {\n graphicAttributes[key] = nextAttrs[key];\n }\n });\n }\n\n return graphicAttributes;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graph/attributes/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGtF,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAEtE,SAAS,qBAAqB,CAC5B,IAAY,EACZ,QAAkB,EAClB,iBAAsB,EACtB,SAAc,EACd,OAAiB,EACjB,QAAgB;;IAEhB,MAAM,eAAe,GAAG,MAAC,OAAyB,CAAC,mBAAmB,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,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AG,qBAAqB,CACvC,SAAS,CAAC,WAAW,EACrB,SAAS,CAAC,QAAQ,EAClB,iBAAiB,EACjB,SAAS,EACT,OAAO,EACP,QAAQ,CACT,CAAC;4BACF,SAAS,CAAC,SAAS,CAAC,iBAAiB,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;yBAChE;6BAAM;4BACL,SAAS,CAAC,SAAS,CAAC,iBAAiB,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;yBACzD;qBACF;oBAED,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;oBACnB,aAAa,GAAG,IAAI,CAAC;iBACtB;YACH,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,aAAa,EAAE;gBAClB,IAAI,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;oBAClC,wBAAwB,CAAC,iBAAiB,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;iBAC7D;qBAAM;oBACL,iBAAiB,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;iBACzC;aACF;QACH,CAAC,CAAC,CAAC;KACJ;SAAM;QACL,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACxB,IAAI,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBAClC,wBAAwB,CAAC,iBAAiB,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;aAC7D;iBAAM;gBACL,iBAAiB,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;aACzC;QACH,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC","file":"transform.js","sourcesContent":["import { has, isNil, isPlainObject, isString, isValidNumber } from '@visactor/vutils';\nimport type { IElement, IGlyphElement } from '../../types/element';\nimport type { AttributeTransform, MarkType } from '../../types/mark';\nimport { GrammarMarkType } from '../enums';\nimport { getRulePoints } from './helpers';\nimport { commonAttributes, transformCommonAttribute } from './common';\n\nfunction storeOriginAttributes(\n name: string,\n channels: string[],\n graphicAttributes: any,\n nextAttrs: any,\n element: IElement,\n markName: string\n): Record<string, any> {\n const prevStoredAttrs = (element as IGlyphElement).getGraphicAttribute(name, false, markName) ?? {};\n const storedAttrs = {};\n channels.forEach(channel => {\n storedAttrs[channel] = nextAttrs[channel] ?? prevStoredAttrs[channel];\n });\n graphicAttributes[name] = storedAttrs;\n return storedAttrs;\n}\n\nexport const transformsByType: Record<string, AttributeTransform[]> = {\n [GrammarMarkType.rect]: [\n {\n channels: ['x', 'y', 'x1', 'y1', 'width', 'height'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n // width\n if (isValidNumber(nextAttrs.width) || (!isValidNumber(nextAttrs.x1) && isValidNumber(storedAttrs.width))) {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n } else if (isValidNumber(nextAttrs.x1) || (!isValidNumber(nextAttrs.width) && isValidNumber(storedAttrs.x1))) {\n graphicAttributes.x = Math.min(storedAttrs.x, storedAttrs.x1);\n graphicAttributes.width = Math.abs(storedAttrs.x1 - storedAttrs.x);\n } else {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n }\n\n // height\n if (isValidNumber(nextAttrs.height) || (!isValidNumber(nextAttrs.y1) && isValidNumber(storedAttrs.height))) {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n } else if (isValidNumber(nextAttrs.y1) || (!isValidNumber(nextAttrs.height) && isValidNumber(storedAttrs.y1))) {\n graphicAttributes.y = Math.min(storedAttrs.y, storedAttrs.y1);\n graphicAttributes.height = Math.abs(storedAttrs.y1 - storedAttrs.y);\n } else {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n }\n },\n storedAttrs: 'sizeAttrs'\n }\n ],\n rect3d: [\n {\n channels: ['x', 'y', 'z', 'x1', 'y1', 'width', 'height', 'length'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n // width\n if (isValidNumber(nextAttrs.width) || (!isValidNumber(nextAttrs.x1) && isValidNumber(storedAttrs.width))) {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n } else if (isValidNumber(nextAttrs.x1) || (!isValidNumber(nextAttrs.width) && isValidNumber(storedAttrs.x1))) {\n graphicAttributes.x = Math.min(storedAttrs.x, storedAttrs.x1);\n graphicAttributes.width = Math.abs(storedAttrs.x1 - storedAttrs.x);\n } else {\n graphicAttributes.x = Math.min(storedAttrs.x ?? 0, storedAttrs.x1 ?? Infinity);\n graphicAttributes.width = storedAttrs.width;\n }\n\n // height\n if (isValidNumber(nextAttrs.height) || (!isValidNumber(nextAttrs.y1) && isValidNumber(storedAttrs.height))) {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n } else if (isValidNumber(nextAttrs.y1) || (!isValidNumber(nextAttrs.height) && isValidNumber(storedAttrs.y1))) {\n graphicAttributes.y = Math.min(storedAttrs.y, storedAttrs.y1);\n graphicAttributes.height = Math.abs(storedAttrs.y1 - storedAttrs.y);\n } else {\n graphicAttributes.y = Math.min(storedAttrs.y ?? 0, storedAttrs.y1 ?? Infinity);\n graphicAttributes.height = storedAttrs.height;\n }\n\n // length\n if (isValidNumber(nextAttrs.length) || (!isValidNumber(nextAttrs.z1) && isValidNumber(storedAttrs.length))) {\n graphicAttributes.z = Math.min(storedAttrs.z ?? 0, storedAttrs.z1 ?? Infinity);\n graphicAttributes.length = storedAttrs.length;\n } else if (isValidNumber(nextAttrs.z1) || (!isValidNumber(nextAttrs.length) && isValidNumber(storedAttrs.z1))) {\n graphicAttributes.z = Math.min(storedAttrs.z, storedAttrs.z1);\n graphicAttributes.length = Math.abs(storedAttrs.z1 - storedAttrs.z);\n } else {\n graphicAttributes.z = Math.min(storedAttrs.z ?? 0, storedAttrs.z1 ?? Infinity);\n graphicAttributes.length = storedAttrs.length;\n }\n },\n storedAttrs: 'sizeAttrs'\n }\n ],\n [GrammarMarkType.text]: [\n {\n channels: ['text', 'limit', 'autoLimit', 'maxLineWidth'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n const limit = storedAttrs.limit ?? Infinity;\n const autoLimit = storedAttrs.autoLimit ?? Infinity;\n const maxWidth = Math.min(limit, autoLimit);\n const isTextConfig = isPlainObject(storedAttrs.text) && !isNil(storedAttrs.text.text);\n const text = isTextConfig ? storedAttrs.text.text : storedAttrs.text;\n\n if (Array.isArray(text)) {\n graphicAttributes.maxLineWidth = maxWidth === Infinity ? storedAttrs.maxLineWidth : maxWidth;\n } else {\n graphicAttributes.maxLineWidth = maxWidth === Infinity ? storedAttrs.maxLineWidth : maxWidth;\n }\n\n if (isTextConfig) {\n if (storedAttrs.text.type === 'html') {\n graphicAttributes.html = {\n dom: text,\n width: nextAttrs.width ?? maxWidth,\n height: nextAttrs.height ?? nextAttrs.fontSize,\n anchorType: 'position'\n };\n graphicAttributes.text = '';\n } else if (storedAttrs.text.type === 'rich') {\n graphicAttributes.textConfig = text;\n } else {\n graphicAttributes.text = text;\n }\n } else {\n graphicAttributes.text = text;\n }\n },\n storedAttrs: 'limitAttrs'\n }\n ],\n [GrammarMarkType.rule]: [\n {\n channels: ['x', 'y', 'x1', 'y1'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n const points = getRulePoints(storedAttrs);\n graphicAttributes.points = points;\n graphicAttributes.x = 0;\n graphicAttributes.y = 0;\n },\n storedAttrs: 'pointAttrs'\n }\n ],\n [GrammarMarkType.symbol]: [\n {\n channels: ['shape', 'symbolType'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.symbolType = nextAttrs.shape ?? nextAttrs.symbolType;\n }\n },\n {\n channels: ['image', 'fill', 'background'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n if (nextAttrs.image) {\n graphicAttributes.background = nextAttrs.image;\n graphicAttributes.fill = false;\n } else if (storedAttrs.image) {\n graphicAttributes.background = storedAttrs.image;\n graphicAttributes.fill = false;\n } else {\n graphicAttributes.fill = storedAttrs.fill;\n graphicAttributes.background = storedAttrs.background;\n }\n },\n storedAttrs: 'imageAttrs'\n }\n ],\n [GrammarMarkType.richtext]: [\n {\n channels: ['text', 'textConfig'],\n transform: (graphicAttributes: any, nextAttrs: any, storedAttrs: any) => {\n graphicAttributes.text = null;\n\n if (nextAttrs.text?.type === 'rich') {\n graphicAttributes.textConfig = nextAttrs.text.text;\n } else if (nextAttrs.textConfig?.type === 'html') {\n graphicAttributes.html = {\n dom: nextAttrs.textConfig.text,\n width: nextAttrs.width,\n height: nextAttrs.height ?? nextAttrs.fontSize,\n anchorType: 'position'\n };\n graphicAttributes.text = '';\n } else if (nextAttrs.textConfig?.type === 'rich') {\n graphicAttributes.textConfig = nextAttrs.textConfig.text;\n } else {\n graphicAttributes.textConfig = nextAttrs.textConfig;\n }\n }\n }\n ]\n};\n\nexport function cloneTransformAttributes(markType: MarkType, attributes: any) {\n const transforms = transformsByType[markType] ?? [];\n return transforms.reduce((clonedAttributes, transform) => {\n transform.channels.forEach(channel => {\n if (has(attributes, channel)) {\n clonedAttributes[channel] = attributes[channel];\n }\n });\n return clonedAttributes;\n }, {} as any);\n}\n\nexport const transformAttributes = (\n markType: MarkType | AttributeTransform[],\n nextAttrs: any,\n element: IElement,\n markName?: string\n) => {\n const graphicAttributes = {};\n const changedKeys = nextAttrs ? Object.keys(nextAttrs) : [];\n const transforms: AttributeTransform[] = isString(markType)\n ? transformsByType[markType]\n : (markType as AttributeTransform[]);\n\n if (transforms?.length) {\n const tags: boolean[] = [];\n\n changedKeys.forEach(key => {\n let isTransformed = false;\n\n transforms.forEach((transform, index) => {\n if (transform.channels.includes(key)) {\n if (!tags[index]) {\n if (transform.storedAttrs) {\n const storedAttrs = storeOriginAttributes(\n transform.storedAttrs,\n transform.channels,\n graphicAttributes,\n nextAttrs,\n element,\n markName\n );\n transform.transform(graphicAttributes, nextAttrs, storedAttrs);\n } else {\n transform.transform(graphicAttributes, nextAttrs, null);\n }\n }\n // 记录一下,不重复处理\n tags[index] = true;\n isTransformed = true;\n }\n });\n\n if (!isTransformed) {\n if (commonAttributes.includes(key)) {\n transformCommonAttribute(graphicAttributes, key, nextAttrs);\n } else {\n graphicAttributes[key] = nextAttrs[key];\n }\n }\n });\n } else {\n changedKeys.forEach(key => {\n if (commonAttributes.includes(key)) {\n transformCommonAttribute(graphicAttributes, key, nextAttrs);\n } else {\n graphicAttributes[key] = nextAttrs[key];\n }\n });\n }\n\n return graphicAttributes;\n};\n"]}
|
package/es/graph/constants.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare const ImmediateAnimationState = "VGRAMMAR_IMMEDIATE_ANIMATION";
|
|
|
15
15
|
export declare const DefaultAnimationStartTime = 0;
|
|
16
16
|
export declare const DefaultAnimationDuration = 1000;
|
|
17
17
|
export declare const DefaultAnimationDelay = 0;
|
|
18
|
+
export declare const DefaultAnimationDelayAfter = 0;
|
|
18
19
|
export declare const DefaultAnimationLoop = false;
|
|
19
20
|
export declare const DefaultAnimationOneByOne = false;
|
|
20
21
|
export declare const DefaultAnimationEasing = "quintInOut";
|
package/es/graph/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,yBAAyB,CAAC;AAE1D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;AAE/E,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,MAAM,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;AAErG,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC;AAEhC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAE,CAAC,CAAC;AAEpC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,UAAU,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AACjC,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AACjC,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AACrC,MAAM,CAAC,MAAM,gBAAgB,GAAmB,IAAI,CAAC;AACrD,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAE/C,MAAM,CAAC,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AAGtE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAC3C,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAC7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAC1C,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAC9C,MAAM,CAAC,MAAM,sBAAsB,GAAG,YAAY,CAAC;AACnD,MAAM,CAAC,MAAM,8BAA8B,GAA6B;IACtE,mBAAmB,EAAE,KAAK;IAC1B,gBAAgB,EAAE,IAAI;CACvB,CAAC;AACF,MAAM,CAAC,MAAM,0BAA0B,GAAG,+BAA+B,CAAC","file":"constants.js","sourcesContent":["import type { IAnimationControlOptions } from '../types/animate';\nimport { GrammarMarkType } from './enums';\n\nexport const BridgeElementKey = '__vgrammar_scene_item__';\n\nexport const CollectionMarkType = [GrammarMarkType.line, GrammarMarkType.area];\n\nexport const Mark3DType = [GrammarMarkType.arc3d, GrammarMarkType.rect3d, GrammarMarkType.pyramid3d];\n\nexport const DefaultKey = 'key';\n\nexport const DefaultMarkData = [{}];\n\nexport const DefaultGroupKeys = [DefaultKey];\n\nexport const DefaultReuse = true;\nexport const DefaultMorph = true;\nexport const DefaultMorphAll = false;\nexport const DefaultSplitPath: null | 'clone' = null;\nexport const DefaultEnableExitAnimation = true;\n\nexport const ImmediateAnimationState = 'VGRAMMAR_IMMEDIATE_ANIMATION';\n\n/** default animation configs */\nexport const DefaultAnimationStartTime = 0;\nexport const DefaultAnimationDuration = 1000;\nexport const DefaultAnimationDelay = 0;\nexport const DefaultAnimationLoop = false;\nexport const DefaultAnimationOneByOne = false;\nexport const DefaultAnimationEasing = 'quintInOut';\nexport const DefaultAnimationControlOptions: IAnimationControlOptions = {\n stopWhenStateChange: false,\n immediatelyApply: true\n};\nexport const DefaultAnimationParameters = 'VGRAMMAR_ANIMATION_PARAMETERS';\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graph/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,yBAAyB,CAAC;AAE1D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;AAE/E,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,MAAM,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;AAErG,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC;AAEhC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAE,CAAC,CAAC;AAEpC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,UAAU,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AACjC,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AACjC,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AACrC,MAAM,CAAC,MAAM,gBAAgB,GAAmB,IAAI,CAAC;AACrD,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAE/C,MAAM,CAAC,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AAGtE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAC3C,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAC7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAC5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAC1C,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAC9C,MAAM,CAAC,MAAM,sBAAsB,GAAG,YAAY,CAAC;AACnD,MAAM,CAAC,MAAM,8BAA8B,GAA6B;IACtE,mBAAmB,EAAE,KAAK;IAC1B,gBAAgB,EAAE,IAAI;CACvB,CAAC;AACF,MAAM,CAAC,MAAM,0BAA0B,GAAG,+BAA+B,CAAC","file":"constants.js","sourcesContent":["import type { IAnimationControlOptions } from '../types/animate';\nimport { GrammarMarkType } from './enums';\n\nexport const BridgeElementKey = '__vgrammar_scene_item__';\n\nexport const CollectionMarkType = [GrammarMarkType.line, GrammarMarkType.area];\n\nexport const Mark3DType = [GrammarMarkType.arc3d, GrammarMarkType.rect3d, GrammarMarkType.pyramid3d];\n\nexport const DefaultKey = 'key';\n\nexport const DefaultMarkData = [{}];\n\nexport const DefaultGroupKeys = [DefaultKey];\n\nexport const DefaultReuse = true;\nexport const DefaultMorph = true;\nexport const DefaultMorphAll = false;\nexport const DefaultSplitPath: null | 'clone' = null;\nexport const DefaultEnableExitAnimation = true;\n\nexport const ImmediateAnimationState = 'VGRAMMAR_IMMEDIATE_ANIMATION';\n\n/** default animation configs */\nexport const DefaultAnimationStartTime = 0;\nexport const DefaultAnimationDuration = 1000;\nexport const DefaultAnimationDelay = 0;\nexport const DefaultAnimationDelayAfter = 0;\nexport const DefaultAnimationLoop = false;\nexport const DefaultAnimationOneByOne = false;\nexport const DefaultAnimationEasing = 'quintInOut';\nexport const DefaultAnimationControlOptions: IAnimationControlOptions = {\n stopWhenStateChange: false,\n immediatelyApply: true\n};\nexport const DefaultAnimationParameters = 'VGRAMMAR_ANIMATION_PARAMETERS';\n"]}
|
package/es/graph/element.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export declare class Element implements IElement {
|
|
|
23
23
|
updateData(groupKey: string | null, data: any[], key: MarkKeySpec): MarkElementItem[];
|
|
24
24
|
state(markState: MarkFunctionType<string | string[]>, parameters?: any): void;
|
|
25
25
|
encodeGraphic(attrs?: any): void;
|
|
26
|
-
private
|
|
26
|
+
private _setCustomizedShape;
|
|
27
27
|
encodeItems(items: MarkElementItem[], encoders: BaseEncodeSpec, isReentered?: boolean, parameters?: any): void;
|
|
28
28
|
protected coordinateTransformEncode(items: MarkElementItem[]): void;
|
|
29
29
|
clearStates(hasAnimation?: boolean): void;
|
package/es/graph/element.js
CHANGED
|
@@ -14,7 +14,7 @@ import { transformAttributes } from "./attributes/transform";
|
|
|
14
14
|
|
|
15
15
|
import { getLargeRectsPoints, getLargeSymbolsPoints, getLinePoints, isValidPointsChannel, isPointsMarkType } from "./attributes/helpers";
|
|
16
16
|
|
|
17
|
-
import { getLineSegmentConfigs, getLinePointsFromSegments } from "./attributes/line";
|
|
17
|
+
import { getLineSegmentConfigs, getLinePointsFromSegments, parseCollectionMarkAttributes } from "./attributes/line";
|
|
18
18
|
|
|
19
19
|
import { CustomPath2D } from "@visactor/vrender-core";
|
|
20
20
|
|
|
@@ -41,14 +41,13 @@ export class Element {
|
|
|
41
41
|
}
|
|
42
42
|
initGraphicItem(attributes = {}) {
|
|
43
43
|
if (this.graphicItem) return;
|
|
44
|
-
const
|
|
45
|
-
this.graphicItem = this.mark.addGraphicItem(
|
|
46
|
-
this.
|
|
44
|
+
const attrTransforms = this.mark.getAttributeTransforms();
|
|
45
|
+
this.graphicItem = this.mark.addGraphicItem(attrTransforms ? {} : attributes, this.groupKey),
|
|
46
|
+
this.graphicItem && (this.graphicItem[BridgeElementKey] = this, attrTransforms && (this.graphicItem.onBeforeAttributeUpdate = attributes => {
|
|
47
47
|
if (!this.mark) return attributes;
|
|
48
|
-
return transformAttributes(
|
|
49
|
-
}, this.graphicItem.setAttributes(
|
|
50
|
-
this.
|
|
51
|
-
this.setFinalGraphicAttributes(attributes)));
|
|
48
|
+
return transformAttributes(attrTransforms, attributes, this);
|
|
49
|
+
}, this.graphicItem.setAttributes(attributes)), this.clearGraphicAttributes(), this.mark.needAnimate() && (this.setPrevGraphicAttributes({}),
|
|
50
|
+
this.setNextGraphicAttributes(attributes), this.setFinalGraphicAttributes(attributes)));
|
|
52
51
|
}
|
|
53
52
|
updateGraphicItem(config) {
|
|
54
53
|
if (!this.graphicItem) return;
|
|
@@ -105,8 +104,7 @@ export class Element {
|
|
|
105
104
|
this.states = newStateValues, !isCollectionMark && isStateChanged && this.diffState === DiffState.unChange && (this.diffState = DiffState.update);
|
|
106
105
|
}
|
|
107
106
|
encodeGraphic(attrs) {
|
|
108
|
-
|
|
109
|
-
this.coordinateTransformEncode(this.items), !isNil(null == attrs ? void 0 : attrs.enableSegments) && (null === (_b = null === (_a = this.items) || void 0 === _a ? void 0 : _a[0]) || void 0 === _b ? void 0 : _b.nextAttrs) && (this.items[0].nextAttrs.enableSegments = attrs.enableSegments);
|
|
107
|
+
this.coordinateTransformEncode(this.items);
|
|
110
108
|
const graphicAttributes = this.transformElementItems(this.items, this.mark.markType);
|
|
111
109
|
attrs && Object.assign(graphicAttributes, attrs), this.graphicItem ? (this.graphicItem.clearStates(),
|
|
112
110
|
this.graphicItem.states = {}, this.graphicItem.stateProxy = null, this.applyGraphicAttributes(graphicAttributes)) : this.initGraphicItem(graphicAttributes),
|
|
@@ -114,16 +112,16 @@ export class Element {
|
|
|
114
112
|
this.mark.markType === GrammarMarkType.shape && (this.graphicItem.datum = this.items[0].datum),
|
|
115
113
|
this.items.forEach((item => {
|
|
116
114
|
item.nextAttrs = {};
|
|
117
|
-
})), this.
|
|
115
|
+
})), this._setCustomizedShape();
|
|
118
116
|
}
|
|
119
|
-
|
|
117
|
+
_setCustomizedShape() {
|
|
120
118
|
var _a;
|
|
121
119
|
if (!this.graphicItem) return;
|
|
122
120
|
const setCustomizedShape = null === (_a = this.mark.getSpec()) || void 0 === _a ? void 0 : _a.setCustomizedShape;
|
|
123
121
|
setCustomizedShape && (this.graphicItem.pathProxy = attrs => setCustomizedShape(this.data, attrs, new CustomPath2D));
|
|
124
122
|
}
|
|
125
123
|
encodeItems(items, encoders, isReentered = !1, parameters) {
|
|
126
|
-
const isCollectionMark = this.mark.isCollectionMark(), updateEncoder = encoders[BuiltInEncodeNames.update], enterEncoder = encoders[BuiltInEncodeNames.enter], exitEncoder = encoders[BuiltInEncodeNames.exit], onlyFullEncodeFirst = this.mark.isLargeMode();
|
|
124
|
+
const isCollectionMark = this.mark.isCollectionMark(), updateEncoder = encoders[BuiltInEncodeNames.update], enterEncoder = encoders[BuiltInEncodeNames.enter], exitEncoder = encoders[BuiltInEncodeNames.exit], onlyFullEncodeFirst = this.mark.isLargeMode() || isCollectionMark && !this.mark.getSpec().enableSegments;
|
|
127
125
|
this.diffState === DiffState.enter ? (enterEncoder && invokeEncoderToItems(this, items, enterEncoder, parameters, onlyFullEncodeFirst),
|
|
128
126
|
updateEncoder && invokeEncoderToItems(this, items, updateEncoder, parameters, onlyFullEncodeFirst)) : this.diffState === DiffState.update ? ((isCollectionMark && enterEncoder || isReentered) && invokeEncoderToItems(this, items, enterEncoder, parameters, onlyFullEncodeFirst),
|
|
129
127
|
updateEncoder && invokeEncoderToItems(this, items, updateEncoder, parameters, onlyFullEncodeFirst)) : this.diffState === DiffState.exit && exitEncoder && (isReentered && invokeEncoderToItems(this, items, enterEncoder, parameters, onlyFullEncodeFirst),
|
|
@@ -181,20 +179,19 @@ export class Element {
|
|
|
181
179
|
return diffResult;
|
|
182
180
|
}
|
|
183
181
|
transformElementItems(items, markType, computePoints) {
|
|
184
|
-
var _a, _b, _c, _d
|
|
182
|
+
var _a, _b, _c, _d;
|
|
185
183
|
const item = items[0];
|
|
186
184
|
if (!item.nextAttrs || 0 === Object.keys(item.nextAttrs).length) return {};
|
|
187
185
|
let nextAttrs = null == item ? void 0 : item.nextAttrs;
|
|
188
186
|
if (items && items.length && isNil(null === (_a = item.nextAttrs) || void 0 === _a ? void 0 : _a.points) && (!0 === computePoints || isValidPointsChannel(Object.keys(item.nextAttrs), this.mark.markType)) && isPointsMarkType(markType)) {
|
|
189
|
-
const lastPoints = this.getGraphicAttribute("points", !1), lastSegments = this.getGraphicAttribute("segments", !1), enableSegments =
|
|
190
|
-
if (nextAttrs =
|
|
191
|
-
markType === GrammarMarkType.line || markType === GrammarMarkType.area) {
|
|
187
|
+
const lastPoints = this.getGraphicAttribute("points", !1), lastSegments = this.getGraphicAttribute("segments", !1), enableSegments = this.mark.getSpec().enableSegments, itemNextAttrs = items.map((item => item.nextAttrs)), isProgressive = this.mark.isProgressive();
|
|
188
|
+
if (nextAttrs = parseCollectionMarkAttributes(nextAttrs), markType === GrammarMarkType.line || markType === GrammarMarkType.area) {
|
|
192
189
|
const linePoints = getLinePoints(items, !0, lastPoints, markType === GrammarMarkType.area);
|
|
193
190
|
if (enableSegments && !isProgressive) {
|
|
194
191
|
const points = linePoints && 0 !== linePoints.length ? linePoints : getLinePointsFromSegments(lastSegments), segments = getLineSegmentConfigs(itemNextAttrs, points, this);
|
|
195
192
|
segments ? (nextAttrs.segments = segments, nextAttrs.points = null) : (nextAttrs.segments = null,
|
|
196
193
|
nextAttrs.points = points);
|
|
197
|
-
} else isProgressive ? nextAttrs.segments = (null !== (
|
|
194
|
+
} else isProgressive ? nextAttrs.segments = (null !== (_d = null === (_c = null === (_b = this.graphicItem) || void 0 === _b ? void 0 : _b.attribute) || void 0 === _c ? void 0 : _c.segments) && void 0 !== _d ? _d : []).concat([ {
|
|
198
195
|
points: linePoints
|
|
199
196
|
} ]) : (nextAttrs.points = linePoints, nextAttrs.segments = null);
|
|
200
197
|
} else markType === GrammarMarkType.largeRects ? nextAttrs.points = getLargeRectsPoints(items, !0, lastPoints) : markType === GrammarMarkType.largeSymbols && (nextAttrs.points = getLargeSymbolsPoints(items, !0, lastPoints));
|