@visactor/vgrammar-core 0.10.5 → 0.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/graph/animation/animation/grow-points.js +2 -1
- package/cjs/graph/animation/animation/grow-points.js.map +1 -1
- package/cjs/graph/animation/animator.js +5 -4
- package/cjs/graph/animation/animator.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/interactions/brush-filter.js +2 -1
- package/cjs/interactions/element-highlight-by-group.js +1 -2
- package/cjs/interactions/index.js +2 -1
- package/cjs/interactions/legend-filter.js +1 -1
- package/cjs/interactions/player-filter.js +1 -1
- package/cjs/interactions/roll-up.js +1 -1
- package/cjs/interactions/scrollbar-filter.js +1 -1
- package/cjs/interactions/slider-filter.js +1 -1
- package/cjs/interactions/tooltip.js +1 -1
- package/cjs/interactions/utils.js +1 -1
- package/cjs/parse/coordinate.js +1 -1
- package/cjs/parse/event.js +1 -1
- package/cjs/parse/mark.js +1 -1
- package/cjs/parse/option.js +1 -1
- package/cjs/parse/scale.js +1 -2
- package/cjs/parse/transform.js +1 -1
- package/cjs/parse/util.js +1 -1
- package/cjs/parse/view.js +1 -1
- package/cjs/transforms/mark/mark-overlap.js +12 -8
- package/cjs/transforms/mark/mark-overlap.js.map +1 -1
- package/es/graph/animation/animation/grow-points.js +2 -1
- package/es/graph/animation/animation/grow-points.js.map +1 -1
- package/es/graph/animation/animator.js +4 -3
- package/es/graph/animation/animator.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/drill-down.js +1 -2
- package/es/interactions/element-select.js +1 -1
- package/es/interactions/filter.js +1 -1
- package/es/interactions/fish-eye.js +1 -1
- package/es/interactions/index.js +2 -1
- package/es/interactions/legend-filter.js +1 -1
- package/es/interactions/player-filter.js +1 -1
- package/es/interactions/roll-up.js +1 -1
- package/es/interactions/scrollbar-filter.js +1 -1
- package/es/interactions/slider-filter.js +1 -1
- package/es/interactions/tooltip.js +1 -1
- package/es/interactions/utils.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 +1 -2
- package/es/parse/transform.js +1 -1
- package/es/parse/util.js +1 -1
- package/es/parse/view.js +1 -1
- package/es/semantic-marks/cell.js +1 -1
- package/es/semantic-marks/interval.js +1 -1
- package/es/semantic-marks/text.js +1 -1
- package/es/transforms/mark/mark-overlap.js +13 -7
- package/es/transforms/mark/mark-overlap.js.map +1 -1
- package/package.json +9 -9
|
@@ -13,7 +13,8 @@ const vutils_1 = require("@visactor/vutils"), getCenterPoints = (element, option
|
|
|
13
13
|
center.x += point.x, center.y += point.y;
|
|
14
14
|
})), center.x /= points.length, center.y /= points.length, options && options.center && ((0,
|
|
15
15
|
vutils_1.isValidNumber)(options.center.x) && (center.x = options.center.x), (0,
|
|
16
|
-
vutils_1.isValidNumber)(options.center.y) && (center.y = options.center.y)),
|
|
16
|
+
vutils_1.isValidNumber)(options.center.y) && (center.y = options.center.y)), "area" === element.mark.markType && (center.x1 = center.x,
|
|
17
|
+
center.y1 = center.y), points.map((() => Object.assign(center)));
|
|
17
18
|
}, growPointsIn = (element, options, animationParameters) => ({
|
|
18
19
|
from: {
|
|
19
20
|
points: getCenterPoints(element, options)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/animation/animation/grow-points.ts"],"names":[],"mappings":";;;AAEA,6CAAiD;AASjD,MAAM,eAAe,GAAG,CACtB,OAAiB,EACjB,OAA2C,EAC3C,mBAAyC,EACzC,EAAE;IACF,MAAM,MAAM,GAAiB,OAAO,CAAC,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC1E,MAAM,MAAM,GAAe,EAAE,CAAC,EAAE,CAAC,EAA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,EAAE,EAAE,KAAK,CAAC,EAAE;gBACZ,EAAE,EAAE,WAAW;gBACf,OAAO,EAAE,KAAK,CAAC,OAAO,KAAK,KAAK;aACnB,CAAC;SACjB;QACD,OAAO;YACL,CAAC,EAAE,KAAK,CAAC,CAAC;YACV,CAAC,EAAE,CAAC;YACJ,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,EAAE,EAAE,CAAC;YACL,OAAO,EAAE,KAAK,CAAC,OAAO,KAAK,KAAK;SACnB,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEK,MAAM,aAAa,GAA4B,CACpD,OAAiB,EACjB,OAAoC,EACpC,mBAAyC,EACzC,EAAE;IACF,OAAO;QACL,IAAI,EAAE,EAAE,MAAM,EAAE,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,mBAAmB,CAAC,EAAE;QACtE,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE;KAC7D,CAAC;AACJ,CAAC,CAAC;AATW,QAAA,aAAa,iBASxB;AAEK,MAAM,cAAc,GAA4B,CACrD,OAAiB,EACjB,OAAoC,EACpC,mBAAyC,EACzC,EAAE;IACF,OAAO;QACL,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE;QAC7D,EAAE,EAAE,EAAE,MAAM,EAAE,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,mBAAmB,CAAC,EAAE;KACrE,CAAC;AACJ,CAAC,CAAC;AATW,QAAA,cAAc,kBASzB","file":"grow-points.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { isValidNumber } from '@visactor/vutils';\nimport type {\n IElement,\n IGrowPointsOverallAnimationOptions,\n IAnimationParameters,\n IGrowPointsAnimationOptions,\n TypeAnimation\n} from '../../../types';\n\nconst getCenterPoints = (\n element: IElement,\n options: IGrowPointsOverallAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const points: IPointLike[] = element.getGraphicAttribute('points', false);\n const center: IPointLike = { x: 0, y: 0 };\n points.forEach(point => {\n center.x += point.x;\n center.y += point.y;\n });\n center.x /= points.length;\n center.y /= points.length;\n\n if (options && options.center) {\n if (isValidNumber(options.center.x)) {\n center.x = options.center.x;\n }\n if (isValidNumber(options.center.y)) {\n center.y = options.center.y;\n }\n }\n\n return points.map(() => Object.assign(center));\n};\n\nexport const growPointsIn: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsOverallAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: getCenterPoints(element, options, animationParameters) },\n to: { points: element.getGraphicAttribute('points', false) }\n };\n};\n\nexport const growPointsOut: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsOverallAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: element.getGraphicAttribute('points', true) },\n to: { points: getCenterPoints(element, options, animationParameters) }\n };\n};\n\n// grow points x\n\nconst changePointsX = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const points = element.getGraphicAttribute('points', false);\n return points.map((point: IPointLike) => {\n if (options && options.orient === 'negative') {\n let groupRight = animationParameters.width;\n\n if (animationParameters.group) {\n groupRight = (animationParameters as any).groupWidth ?? animationParameters.group.getBounds().width();\n\n (animationParameters as any).groupWidth = groupRight;\n }\n\n return {\n x: groupRight,\n y: point.y,\n x1: groupRight,\n y1: point.y1,\n defined: point.defined !== false\n } as IPointLike;\n }\n return {\n x: 0,\n y: point.y,\n x1: 0,\n y1: point.y1,\n defined: point.defined !== false\n } as IPointLike;\n });\n};\n\nexport const growPointsXIn: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: changePointsX(element, options, animationParameters) },\n to: { points: element.getGraphicAttribute('points', false) }\n };\n};\n\nexport const growPointsXOut: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: element.getGraphicAttribute('points', true) },\n to: { points: changePointsX(element, options, animationParameters) }\n };\n};\n\n// grow points y\n\nconst changePointsY = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const points = element.getGraphicAttribute('points', false);\n return points.map((point: IPointLike) => {\n if (options && options.orient === 'negative') {\n let groupBottom = animationParameters.height;\n\n if (animationParameters.group) {\n groupBottom = (animationParameters as any).groupHeight ?? animationParameters.group.getBounds().height();\n\n (animationParameters as any).groupHeight = groupBottom;\n }\n\n return {\n x: point.x,\n y: groupBottom,\n x1: point.x1,\n y1: groupBottom,\n defined: point.defined !== false\n } as IPointLike;\n }\n return {\n x: point.x,\n y: 0,\n x1: point.x1,\n y1: 0,\n defined: point.defined !== false\n } as IPointLike;\n });\n};\n\nexport const growPointsYIn: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: changePointsY(element, options, animationParameters) },\n to: { points: element.getGraphicAttribute('points', false) }\n };\n};\n\nexport const growPointsYOut: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: element.getGraphicAttribute('points', true) },\n to: { points: changePointsY(element, options, animationParameters) }\n };\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graph/animation/animation/grow-points.ts"],"names":[],"mappings":";;;AAEA,6CAAiD;AASjD,MAAM,eAAe,GAAG,CACtB,OAAiB,EACjB,OAA2C,EAC3C,mBAAyC,EACzC,EAAE;IACF,MAAM,MAAM,GAAiB,OAAO,CAAC,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC1E,MAAM,MAAM,GAAe,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,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able-next-line no-duplicate-imports\nimport { isValidNumber } from '@visactor/vutils';\nimport type {\n IElement,\n IGrowPointsOverallAnimationOptions,\n IAnimationParameters,\n IGrowPointsAnimationOptions,\n TypeAnimation\n} from '../../../types';\n\nconst getCenterPoints = (\n element: IElement,\n options: IGrowPointsOverallAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const points: IPointLike[] = element.getGraphicAttribute('points', false);\n const center: IPointLike = { x: 0, y: 0 };\n points.forEach(point => {\n center.x += point.x;\n center.y += point.y;\n });\n center.x /= points.length;\n center.y /= points.length;\n\n if (options && options.center) {\n if (isValidNumber(options.center.x)) {\n center.x = options.center.x;\n }\n if (isValidNumber(options.center.y)) {\n center.y = options.center.y;\n }\n }\n\n if (element.mark.markType === 'area') {\n center.x1 = center.x;\n center.y1 = center.y;\n }\n\n return points.map(() => Object.assign(center));\n};\n\nexport const growPointsIn: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsOverallAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: getCenterPoints(element, options, animationParameters) },\n to: { points: element.getGraphicAttribute('points', false) }\n };\n};\n\nexport const growPointsOut: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsOverallAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: element.getGraphicAttribute('points', true) },\n to: { points: getCenterPoints(element, options, animationParameters) }\n };\n};\n\n// grow points x\n\nconst changePointsX = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const points = element.getGraphicAttribute('points', false);\n return points.map((point: IPointLike) => {\n if (options && options.orient === 'negative') {\n let groupRight = animationParameters.width;\n\n if (animationParameters.group) {\n groupRight = (animationParameters as any).groupWidth ?? animationParameters.group.getBounds().width();\n\n (animationParameters as any).groupWidth = groupRight;\n }\n\n return {\n x: groupRight,\n y: point.y,\n x1: groupRight,\n y1: point.y1,\n defined: point.defined !== false\n } as IPointLike;\n }\n return {\n x: 0,\n y: point.y,\n x1: 0,\n y1: point.y1,\n defined: point.defined !== false\n } as IPointLike;\n });\n};\n\nexport const growPointsXIn: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: changePointsX(element, options, animationParameters) },\n to: { points: element.getGraphicAttribute('points', false) }\n };\n};\n\nexport const growPointsXOut: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: element.getGraphicAttribute('points', true) },\n to: { points: changePointsX(element, options, animationParameters) }\n };\n};\n\n// grow points y\n\nconst changePointsY = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const points = element.getGraphicAttribute('points', false);\n return points.map((point: IPointLike) => {\n if (options && options.orient === 'negative') {\n let groupBottom = animationParameters.height;\n\n if (animationParameters.group) {\n groupBottom = (animationParameters as any).groupHeight ?? animationParameters.group.getBounds().height();\n\n (animationParameters as any).groupHeight = groupBottom;\n }\n\n return {\n x: point.x,\n y: groupBottom,\n x1: point.x1,\n y1: groupBottom,\n defined: point.defined !== false\n } as IPointLike;\n }\n return {\n x: point.x,\n y: 0,\n x1: point.x1,\n y1: 0,\n defined: point.defined !== false\n } as IPointLike;\n });\n};\n\nexport const growPointsYIn: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: changePointsY(element, options, animationParameters) },\n to: { points: element.getGraphicAttribute('points', false) }\n };\n};\n\nexport const growPointsYOut: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: element.getGraphicAttribute('points', true) },\n to: { points: changePointsY(element, options, animationParameters) }\n };\n};\n"]}
|
|
@@ -70,9 +70,10 @@ class Animator {
|
|
|
70
70
|
const delay = timeSlice.delay, delayAfter = timeSlice.delayAfter, duration = timeSlice.duration, effects = timeSlice.effects;
|
|
71
71
|
if (delay > 0 && graphicAnimate.wait(delay), effects.length < 0) graphicAnimate.wait(duration); else {
|
|
72
72
|
const customAnimates = effects.map(((effect, index) => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
const attributes = effect.type ? (0, attribute_1.typeAnimationAttributes)(this.element, effect, animationParameters, parameters) : effect.channel ? (0,
|
|
74
|
+
attribute_1.channelAnimationAttributes)(this.element, effect, animationParameters, parameters) : void 0;
|
|
75
|
+
if (!attributes) return null;
|
|
76
|
+
const customOption = (null == attributes ? void 0 : attributes.custom) || (null == effect ? void 0 : effect.custom), customParametersOption = (null == attributes ? void 0 : attributes.customParameters) || (null == effect ? void 0 : effect.customParameters);
|
|
76
77
|
attributes.from && Object.keys(attributes.from).length && this.unit && this.animationOptions.timeline.controlOptions.immediatelyApply && "component" !== this.element.mark.markType && this.element.getGraphicItem().setAttributes(attributes.from);
|
|
77
78
|
const isCustomAnimate = isCustomAnimateCtor(customOption);
|
|
78
79
|
return !(0, vutils_1.isNil)(customOption) && !isCustomAnimateCtor(customOption) ? new attribute_1.CustomInterpolator(attributes.from, attributes.to, duration, effect.easing, {
|
|
@@ -81,7 +82,7 @@ class Animator {
|
|
|
81
82
|
parameters: customParametersOption
|
|
82
83
|
}) : isCustomAnimate ? new customOption(attributes.from, attributes.to, duration, effect.easing, customParametersOption) : attributes.to ? new attribute_1.AttributeAnimate(attributes.from, attributes.to, duration, effect.easing) : void 0;
|
|
83
84
|
})).filter((animate => !(0, vutils_1.isNil)(animate)));
|
|
84
|
-
1 === customAnimates.length ? graphicAnimate.play(customAnimates[0]) : graphicAnimate.play(new vrender_core_1.AnimateGroup(duration, customAnimates));
|
|
85
|
+
1 === customAnimates.length ? graphicAnimate.play(customAnimates[0]) : customAnimates.length > 1 && graphicAnimate.play(new vrender_core_1.AnimateGroup(duration, customAnimates));
|
|
85
86
|
}
|
|
86
87
|
delayAfter > 0 && graphicAnimate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AAC,MAAM,CAAC,CAAC;iBACtF;YACH,CAAC,CAAC;iBACD,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAA,cAAK,EAAC,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,2BAAY,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;AAlMD,4BAkMC","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
|
+
{"version":3,"sources":["../src/graph/animation/animator.ts"],"names":[],"mappings":";;;AAAA,6CAAwD;AAGxD,yDAA4F;AAa5F,2CAAwH;AAExH,sBAAO,CAAC,IAAI,IAAI,0BAAW,CAAC,oBAAoB,CAAC;AAEjD,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAEzB,MAAM,mBAAmB,GAAG,CAAC,MAAoE,EAAE,EAAE;IACnG,OAAO,CAAC,IAAA,cAAK,EAAC,MAAM,CAAC,IAAI,MAAM,CAAC,SAAS,YAAY,6BAAc,CAAC;AACtE,CAAC,CAAC;AAEF,MAAa,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,mBAAmB,EAAE,UAAU,CAAC,CAAC;QAGrD,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,C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AAe,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,4BAAgB,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,IAAA,cAAK,EAAC,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,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;gBACpC,cAAc,CAAC,IAAI,CAAC,IAAI,2BAAY,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;AAvMD,4BAuMC","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 = effect.type\n ? typeAnimationAttributes(this.element, effect, animationParameters, parameters)\n : effect.channel\n ? channelAnimationAttributes(this.element, effect, animationParameters, parameters)\n : undefined;\n\n if (!attributes) {\n return null;\n }\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 if (customAnimates.length > 1) {\n graphicAnimate.play(new AnimateGroup(duration, customAnimates));\n }\n }\n\n if (delayAfter > 0) {\n graphicAnimate.wait(delayAfter);\n }\n }\n}\n"]}
|
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", {
|
|
19
19
|
value: !0
|
|
20
20
|
}), exports.vglobal = exports.ThemeManager = exports.SIGNAL_VIEW_BOX = exports.SIGNAL_WIDTH = exports.SIGNAL_VIEW_WIDTH = exports.SIGNAL_VIEW_HEIGHT = exports.SIGNAL_PADDING = exports.SIGNAL_HEIGHT = exports.SIGNAL_AUTOFIT = exports.Factory = exports.GrammarBase = exports.invokeFunctionType = exports.parseFunctionType = exports.registerCoordinate = exports.Coordinate = exports.registerScale = exports.Scale = exports.View = exports.version = void 0,
|
|
21
|
-
exports.version = "0.10.
|
|
21
|
+
exports.version = "0.10.7", __exportStar(require("./graph"), exports), __exportStar(require("./interactions"), exports);
|
|
22
22
|
|
|
23
23
|
var view_1 = require("./view");
|
|
24
24
|
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,0CAAwB;AAExB,iDAA+B;AAE/B,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,sCAAoD;AAA3C,8FAAA,KAAK,OAAA;AAAE,sGAAA,aAAa,OAAA;AAC7B,gDAAmE;AAA1D,wGAAA,UAAU,OAAA;AAAE,gHAAA,kBAAkB,OAAA;AACvC,qCAAqE;AAA5D,yGAAA,iBAAiB,OAAA;AAAE,0GAAA,kBAAkB,OAAA;AAC9C,oDAAkD;AAAzC,2GAAA,WAAW,OAAA;AACpB,8CAA4B;AAC5B,0CAAwB;AACxB,0CAAyC;AAAhC,kGAAA,OAAO,OAAA;AAChB,8CAQ0B;AAPxB,2GAAA,cAAc,OAAA;AACd,0GAAA,aAAa,OAAA;AACb,2GAAA,cAAc,OAAA;AACd,+GAAA,kBAAkB,OAAA;AAClB,8GAAA,iBAAiB,OAAA;AACjB,yGAAA,YAAY,OAAA;AACZ,4GAAA,eAAe,OAAA;AAGjB,uDAAqD;AAA5C,6GAAA,YAAY,OAAA;AAErB,0CAAwB;AACxB,8CAA4B;AAC5B,+CAA6B;AAC7B,8DAA4C;AAE5C,uDAAiD;AAAxC,uGAAA,OAAO,OAAA;AAChB,wCAAsB;AACtB,iDAA+B;AAC/B,wDAAsC;AACtC,4DAA0C;AAC1C,uDAAqC","file":"index.js","sourcesContent":["// -- Exports -----\nexport const version = \"0.10.
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,0CAAwB;AAExB,iDAA+B;AAE/B,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,sCAAoD;AAA3C,8FAAA,KAAK,OAAA;AAAE,sGAAA,aAAa,OAAA;AAC7B,gDAAmE;AAA1D,wGAAA,UAAU,OAAA;AAAE,gHAAA,kBAAkB,OAAA;AACvC,qCAAqE;AAA5D,yGAAA,iBAAiB,OAAA;AAAE,0GAAA,kBAAkB,OAAA;AAC9C,oDAAkD;AAAzC,2GAAA,WAAW,OAAA;AACpB,8CAA4B;AAC5B,0CAAwB;AACxB,0CAAyC;AAAhC,kGAAA,OAAO,OAAA;AAChB,8CAQ0B;AAPxB,2GAAA,cAAc,OAAA;AACd,0GAAA,aAAa,OAAA;AACb,2GAAA,cAAc,OAAA;AACd,+GAAA,kBAAkB,OAAA;AAClB,8GAAA,iBAAiB,OAAA;AACjB,yGAAA,YAAY,OAAA;AACZ,4GAAA,eAAe,OAAA;AAGjB,uDAAqD;AAA5C,6GAAA,YAAY,OAAA;AAErB,0CAAwB;AACxB,8CAA4B;AAC5B,+CAA6B;AAC7B,8DAA4C;AAE5C,uDAAiD;AAAxC,uGAAA,OAAO,OAAA;AAChB,wCAAsB;AACtB,iDAA+B;AAC/B,wDAAsC;AACtC,4DAA0C;AAC1C,uDAAqC","file":"index.js","sourcesContent":["// -- Exports -----\nexport const version = \"0.10.7\";\n\nexport * from './graph';\n\nexport * from './interactions';\n\nexport { View } from './view';\nexport { Scale, registerScale } from './view/scale';\nexport { Coordinate, registerCoordinate } from './view/coordinate';\nexport { parseFunctionType, invokeFunctionType } from './parse/util';\nexport { GrammarBase } from './view/grammar-base';\nexport * from './util/text';\nexport * from './types';\nexport { Factory } from './core/factory';\nexport {\n SIGNAL_AUTOFIT,\n SIGNAL_HEIGHT,\n SIGNAL_PADDING,\n SIGNAL_VIEW_HEIGHT,\n SIGNAL_VIEW_WIDTH,\n SIGNAL_WIDTH,\n SIGNAL_VIEW_BOX\n} from './view/constants';\n\nexport { ThemeManager } from './theme/theme-manager';\n\nexport * from './glyph';\nexport * from './component';\nexport * from './transforms';\nexport * from './graph/animation/animation';\n\nexport { vglobal } from '@visactor/vrender-core';\nexport * from './env';\nexport * from './interactions';\nexport * from './semantic-marks/cell';\nexport * from './semantic-marks/interval';\nexport * from './graph/mark/graphic';\n"]}
|
|
@@ -31,4 +31,5 @@ class BrushFilter extends brush_base_1.BrushBase {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
exports.BrushFilter = BrushFilter, BrushFilter.type = "brush-filter", BrushFilter.defaultOptions = {};
|
|
34
|
+
exports.BrushFilter = BrushFilter, BrushFilter.type = "brush-filter", BrushFilter.defaultOptions = {};
|
|
35
|
+
//# sourceMappingURL=brush-filter.js.map
|
|
@@ -383,4 +383,5 @@ const registerFishEye = () => {
|
|
|
383
383
|
factory_1.Factory.registerInteraction(fish_eye_1.FishEye.type, fish_eye_1.FishEye);
|
|
384
384
|
};
|
|
385
385
|
|
|
386
|
-
exports.registerFishEye = registerFishEye;
|
|
386
|
+
exports.registerFishEye = registerFishEye;
|
|
387
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -51,4 +51,4 @@ class ScrollbarFilter extends filter_1.Filter {
|
|
|
51
51
|
|
|
52
52
|
exports.ScrollbarFilter = ScrollbarFilter, ScrollbarFilter.type = "scrollbar-filter",
|
|
53
53
|
ScrollbarFilter.defaultOptions = {};
|
|
54
|
-
//# sourceMappingURL=scrollbar-filter.js.map
|
|
54
|
+
//# sourceMappingURL=scrollbar-filter.js.map
|
package/cjs/parse/coordinate.js
CHANGED
|
@@ -67,4 +67,4 @@ function configureCoordinate(spec, coordinate, parameters) {
|
|
|
67
67
|
|
|
68
68
|
exports.createCoordinate = createCoordinate, exports.parseCoordinate = parseCoordinate,
|
|
69
69
|
exports.configureCoordinate = configureCoordinate;
|
|
70
|
-
//# sourceMappingURL=coordinate.js.map
|
|
70
|
+
//# sourceMappingURL=coordinate.js.map
|
package/cjs/parse/event.js
CHANGED
package/cjs/parse/mark.js
CHANGED
package/cjs/parse/option.js
CHANGED
|
@@ -17,4 +17,4 @@ const parseOptions = (options, params) => options ? (0, vutils_1.isObject)(optio
|
|
|
17
17
|
}), {}) : options.map((option => (0, exports.parseOptionValue)(option, params))) : options;
|
|
18
18
|
|
|
19
19
|
exports.parseOptions = parseOptions;
|
|
20
|
-
//# sourceMappingURL=option.js.map
|
|
20
|
+
//# sourceMappingURL=option.js.map
|
package/cjs/parse/scale.js
CHANGED
|
@@ -362,5 +362,4 @@ function configureScale(spec, scale, parameters) {
|
|
|
362
362
|
}
|
|
363
363
|
|
|
364
364
|
exports.createScale = createScale, exports.parseScaleDomainRange = parseScaleDomainRange,
|
|
365
|
-
exports.parseScaleConfig = parseScaleConfig, exports.configureScale = configureScale;
|
|
366
|
-
//# sourceMappingURL=scale.js.map
|
|
365
|
+
exports.parseScaleConfig = parseScaleConfig, exports.configureScale = configureScale;
|
package/cjs/parse/transform.js
CHANGED
package/cjs/parse/util.js
CHANGED
package/cjs/parse/view.js
CHANGED
|
@@ -4,11 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.transform = void 0;
|
|
6
6
|
|
|
7
|
-
const vutils_1 = require("@visactor/vutils");
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), HIDE_KEY = "_mo_hide_";
|
|
8
8
|
|
|
9
9
|
function reset(elements) {
|
|
10
10
|
return elements.forEach((element => {
|
|
11
|
-
element.setGraphicAttribute("visible", !0)
|
|
11
|
+
element.getGraphicAttribute("HIDE_KEY") && (element.setGraphicAttribute("visible", !0),
|
|
12
|
+
element.setGraphicAttribute(HIDE_KEY, !1));
|
|
12
13
|
})), elements;
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -18,9 +19,10 @@ function overlapX(elements, delta, deltaMul, useRadius) {
|
|
|
18
19
|
const useDeltaMul = (0, vutils_1.isNil)(delta);
|
|
19
20
|
let itemDelta = delta;
|
|
20
21
|
elements.forEach((element => {
|
|
22
|
+
if (!1 === element.getGraphicAttribute("visible")) return;
|
|
21
23
|
const r = element.getGraphicAttribute("size") / 2, currentX = element.getGraphicAttribute("x");
|
|
22
|
-
useDeltaMul && (itemDelta = (r + lastR) * deltaMul), Math.abs(currentX - lastX) < itemDelta + lastR + r ? element.getGraphicAttribute("forceShow") || element.setGraphicAttribute(
|
|
23
|
-
lastR = r;
|
|
24
|
+
useDeltaMul && (itemDelta = (r + lastR) * deltaMul), Math.abs(currentX - lastX) < itemDelta + lastR + r ? element.getGraphicAttribute("forceShow") || (element.setGraphicAttribute(HIDE_KEY, !0),
|
|
25
|
+
element.setGraphicAttribute("visible", !1)) : lastX = currentX, lastR = r;
|
|
24
26
|
}));
|
|
25
27
|
}
|
|
26
28
|
}
|
|
@@ -31,9 +33,10 @@ function overlapY(elements, delta, deltaMul, useRadius) {
|
|
|
31
33
|
const useDeltaMul = (0, vutils_1.isNil)(delta);
|
|
32
34
|
let itemDelta = delta;
|
|
33
35
|
elements.forEach((element => {
|
|
36
|
+
if (!1 === element.getGraphicAttribute("visible")) return;
|
|
34
37
|
const r = element.getGraphicAttribute("size") / 2, currentY = element.getGraphicAttribute("y");
|
|
35
|
-
useDeltaMul && (itemDelta = (r + lastR) * deltaMul), Math.abs(currentY - lastY) < itemDelta + lastR + r ? element.getGraphicAttribute("forceShow") || element.setGraphicAttribute(
|
|
36
|
-
lastR = r;
|
|
38
|
+
useDeltaMul && (itemDelta = (r + lastR) * deltaMul), Math.abs(currentY - lastY) < itemDelta + lastR + r ? element.getGraphicAttribute("forceShow") || (element.setGraphicAttribute(HIDE_KEY, !0),
|
|
39
|
+
element.setGraphicAttribute("visible", !1)) : lastY = currentY, lastR = r;
|
|
37
40
|
}));
|
|
38
41
|
}
|
|
39
42
|
}
|
|
@@ -45,10 +48,11 @@ function overlapXY(elements, delta, deltaMul, useRadius) {
|
|
|
45
48
|
const useDeltaMul = (0, vutils_1.isNil)(delta);
|
|
46
49
|
let itemDelta = delta;
|
|
47
50
|
elements.forEach((element => {
|
|
51
|
+
if (!1 === element.getGraphicAttribute("visible")) return;
|
|
48
52
|
const r = element.getGraphicAttribute("size") / 2, currentX = element.getGraphicAttribute("x"), currentY = element.getGraphicAttribute("y");
|
|
49
53
|
useDeltaMul && (itemDelta = (r + lastR) * deltaMul), dis = (lastX - currentX) ** 2 + (lastY - currentY) ** 2,
|
|
50
|
-
dis < (itemDelta + lastR + r) ** 2 ? element.getGraphicAttribute("forceShow") || element.setGraphicAttribute(
|
|
51
|
-
lastR = r;
|
|
54
|
+
dis < (itemDelta + lastR + r) ** 2 ? element.getGraphicAttribute("forceShow") || (element.setGraphicAttribute(HIDE_KEY, !0),
|
|
55
|
+
element.setGraphicAttribute("visible", !1)) : lastY = currentY, lastR = r;
|
|
52
56
|
}));
|
|
53
57
|
}
|
|
54
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/transforms/mark/mark-overlap.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAGzC,SAAS,KAAK,CAAC,QAAoB;IACjC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACzB,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/transforms/mark/mark-overlap.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAGzC,MAAM,QAAQ,GAAG,WAAW,CAAC;AAE7B,SAAS,KAAK,CAAC,QAAoB;IACjC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACzB,MAAM,IAAI,GAAG,OAAO,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAErD,IAAI,IAAI,EAAE;YACR,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAC7C,OAAO,CAAC,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;SAC9C;IACH,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,QAAQ,CAAC,QAAoB,EAAE,KAAa,EAAE,QAAgB,EAAE,SAAkB;IACzF,IAAI,SAAS,EAA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C5B;YAED,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC7B,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAnDW,QAAA,SAAS,aAmDpB","file":"mark-overlap.js","sourcesContent":["import { isNil } from '@visactor/vutils';\nimport type { IElement, MarkOverlapTransformOptions } from '../../types';\n\nconst HIDE_KEY = '_mo_hide_';\n\nfunction reset(elements: IElement[]) {\n elements.forEach(element => {\n const hide = element.getGraphicAttribute('HIDE_KEY');\n\n if (hide) {\n element.setGraphicAttribute('visible', true);\n element.setGraphicAttribute(HIDE_KEY, false);\n }\n });\n return elements;\n}\n\nfunction overlapX(elements: IElement[], delta: number, deltaMul: number, useRadius: boolean) {\n if (useRadius) {\n let lastX = -Infinity;\n let lastR = 0;\n const useDeltaMul = isNil(delta);\n let itemDelta = delta;\n\n elements.forEach(element => {\n if (element.getGraphicAttribute('visible') === false) {\n // skip hidden points\n return;\n }\n\n const r = element.getGraphicAttribute('size') / 2;\n const currentX = element.getGraphicAttribute('x');\n if (useDeltaMul) {\n itemDelta = (r + lastR) * deltaMul;\n }\n if (Math.abs(currentX - lastX) < itemDelta + lastR + r) {\n if (!element.getGraphicAttribute('forceShow')) {\n element.setGraphicAttribute(HIDE_KEY, true);\n element.setGraphicAttribute('visible', false);\n }\n } else {\n lastX = currentX;\n }\n\n lastR = r;\n });\n }\n}\n\nfunction overlapY(elements: IElement[], delta: number, deltaMul: number, useRadius: boolean) {\n if (useRadius) {\n let lastY = -Infinity;\n let lastR = 0;\n const useDeltaMul = isNil(delta);\n let itemDelta = delta;\n\n elements.forEach(element => {\n if (element.getGraphicAttribute('visible') === false) {\n // skip hidden points\n return;\n }\n\n const r = element.getGraphicAttribute('size') / 2;\n const currentY = element.getGraphicAttribute('y');\n if (useDeltaMul) {\n itemDelta = (r + lastR) * deltaMul;\n }\n if (Math.abs(currentY - lastY) < itemDelta + lastR + r) {\n if (!element.getGraphicAttribute('forceShow')) {\n element.setGraphicAttribute(HIDE_KEY, true);\n element.setGraphicAttribute('visible', false);\n }\n } else {\n lastY = currentY;\n }\n\n lastR = r;\n });\n }\n}\n\nfunction overlapXY(elements: IElement[], delta: number, deltaMul: number, useRadius: boolean) {\n if (useRadius) {\n const lastX = -Infinity;\n let lastY = -Infinity;\n let lastR = 0;\n let dis = 0;\n const useDeltaMul = isNil(delta);\n let itemDelta = delta;\n\n elements.forEach(element => {\n if (element.getGraphicAttribute('visible') === false) {\n // skip hidden points\n return;\n }\n\n const r = element.getGraphicAttribute('size') / 2;\n const currentX = element.getGraphicAttribute('x');\n const currentY = element.getGraphicAttribute('y');\n\n if (useDeltaMul) {\n itemDelta = (r + lastR) * deltaMul;\n }\n dis = (lastX - currentX) ** 2 + (lastY - currentY) ** 2;\n if (dis < (itemDelta + lastR + r) ** 2) {\n if (!element.getGraphicAttribute('forceShow')) {\n element.setGraphicAttribute(HIDE_KEY, true);\n element.setGraphicAttribute('visible', false);\n }\n } else {\n lastY = currentY;\n }\n\n lastR = r;\n });\n }\n}\n\n/**\n * 针对mark的防重叠\n * @param {object} options - The parameters for this operator.\n * @param {data} [options.followMark]\n * @constructor\n */\nexport const transform = (options: MarkOverlapTransformOptions, upstreamData: IElement[]) => {\n if (!upstreamData || upstreamData.length === 0) {\n return;\n }\n let { radius } = options;\n if (isNil(radius)) {\n if (upstreamData[0].mark.markType === 'symbol') {\n radius = true;\n }\n }\n\n const { direction, delta, deltaMul = 1, groupBy } = options;\n\n const handleOverlap = (elements: IElement[]) => {\n reset(elements);\n\n const sortedElements = elements.slice().sort((a, b) => {\n return a.getGraphicAttribute('x') - b.getGraphicAttribute('x');\n });\n\n if (direction === 0) {\n overlapXY(sortedElements, delta, deltaMul, radius);\n } else if (direction === 1) {\n overlapX(sortedElements, delta, deltaMul, radius);\n } else {\n overlapY(sortedElements, delta, deltaMul, radius);\n }\n };\n\n if (!groupBy) {\n handleOverlap(upstreamData);\n } else {\n // 分组\n const map = upstreamData.reduce((res: { [key: string]: IElement[] }, element: IElement) => {\n const groupName = element.getDatum()[groupBy];\n\n if (res[groupName]) {\n res[groupName].push(element);\n } else {\n res[groupName] = [element];\n }\n\n return res;\n }, {});\n\n Object.keys(map).forEach(key => {\n handleOverlap(map[key]);\n });\n }\n\n return upstreamData;\n};\n"]}
|
|
@@ -8,7 +8,8 @@ const getCenterPoints = (element, options, animationParameters) => {
|
|
|
8
8
|
return points.forEach((point => {
|
|
9
9
|
center.x += point.x, center.y += point.y;
|
|
10
10
|
})), center.x /= points.length, center.y /= points.length, options && options.center && (isValidNumber(options.center.x) && (center.x = options.center.x),
|
|
11
|
-
isValidNumber(options.center.y) && (center.y = options.center.y)),
|
|
11
|
+
isValidNumber(options.center.y) && (center.y = options.center.y)), "area" === element.mark.markType && (center.x1 = center.x,
|
|
12
|
+
center.y1 = center.y), points.map((() => Object.assign(center)));
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
export const growPointsIn = (element, options, animationParameters) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/animation/animation/grow-points.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AASjD,MAAM,eAAe,GAAG,CACtB,OAAiB,EACjB,OAA2C,EAC3C,mBAAyC,EACzC,EAAE;IACF,MAAM,MAAM,GAAiB,OAAO,CAAC,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC1E,MAAM,MAAM,GAAe,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAC1C,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACrB,MAAM,CAAC,CAAC,IAAI,KAAK,CAAC,CA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C;YACJ,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,EAAE,EAAE,CAAC;YACL,OAAO,EAAE,KAAK,CAAC,OAAO,KAAK,KAAK;SACnB,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAA4B,CACpD,OAAiB,EACjB,OAAoC,EACpC,mBAAyC,EACzC,EAAE;IACF,OAAO;QACL,IAAI,EAAE,EAAE,MAAM,EAAE,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,mBAAmB,CAAC,EAAE;QACtE,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE;KAC7D,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAA4B,CACrD,OAAiB,EACjB,OAAoC,EACpC,mBAAyC,EACzC,EAAE;IACF,OAAO;QACL,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE;QAC7D,EAAE,EAAE,EAAE,MAAM,EAAE,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,mBAAmB,CAAC,EAAE;KACrE,CAAC;AACJ,CAAC,CAAC","file":"grow-points.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { isValidNumber } from '@visactor/vutils';\nimport type {\n IElement,\n IGrowPointsOverallAnimationOptions,\n IAnimationParameters,\n IGrowPointsAnimationOptions,\n TypeAnimation\n} from '../../../types';\n\nconst getCenterPoints = (\n element: IElement,\n options: IGrowPointsOverallAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const points: IPointLike[] = element.getGraphicAttribute('points', false);\n const center: IPointLike = { x: 0, y: 0 };\n points.forEach(point => {\n center.x += point.x;\n center.y += point.y;\n });\n center.x /= points.length;\n center.y /= points.length;\n\n if (options && options.center) {\n if (isValidNumber(options.center.x)) {\n center.x = options.center.x;\n }\n if (isValidNumber(options.center.y)) {\n center.y = options.center.y;\n }\n }\n\n return points.map(() => Object.assign(center));\n};\n\nexport const growPointsIn: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsOverallAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: getCenterPoints(element, options, animationParameters) },\n to: { points: element.getGraphicAttribute('points', false) }\n };\n};\n\nexport const growPointsOut: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsOverallAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: element.getGraphicAttribute('points', true) },\n to: { points: getCenterPoints(element, options, animationParameters) }\n };\n};\n\n// grow points x\n\nconst changePointsX = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const points = element.getGraphicAttribute('points', false);\n return points.map((point: IPointLike) => {\n if (options && options.orient === 'negative') {\n let groupRight = animationParameters.width;\n\n if (animationParameters.group) {\n groupRight = (animationParameters as any).groupWidth ?? animationParameters.group.getBounds().width();\n\n (animationParameters as any).groupWidth = groupRight;\n }\n\n return {\n x: groupRight,\n y: point.y,\n x1: groupRight,\n y1: point.y1,\n defined: point.defined !== false\n } as IPointLike;\n }\n return {\n x: 0,\n y: point.y,\n x1: 0,\n y1: point.y1,\n defined: point.defined !== false\n } as IPointLike;\n });\n};\n\nexport const growPointsXIn: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: changePointsX(element, options, animationParameters) },\n to: { points: element.getGraphicAttribute('points', false) }\n };\n};\n\nexport const growPointsXOut: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: element.getGraphicAttribute('points', true) },\n to: { points: changePointsX(element, options, animationParameters) }\n };\n};\n\n// grow points y\n\nconst changePointsY = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const points = element.getGraphicAttribute('points', false);\n return points.map((point: IPointLike) => {\n if (options && options.orient === 'negative') {\n let groupBottom = animationParameters.height;\n\n if (animationParameters.group) {\n groupBottom = (animationParameters as any).groupHeight ?? animationParameters.group.getBounds().height();\n\n (animationParameters as any).groupHeight = groupBottom;\n }\n\n return {\n x: point.x,\n y: groupBottom,\n x1: point.x1,\n y1: groupBottom,\n defined: point.defined !== false\n } as IPointLike;\n }\n return {\n x: point.x,\n y: 0,\n x1: point.x1,\n y1: 0,\n defined: point.defined !== false\n } as IPointLike;\n });\n};\n\nexport const growPointsYIn: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: changePointsY(element, options, animationParameters) },\n to: { points: element.getGraphicAttribute('points', false) }\n };\n};\n\nexport const growPointsYOut: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: element.getGraphicAttribute('points', true) },\n to: { points: changePointsY(element, options, animationParameters) }\n };\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graph/animation/animation/grow-points.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AASjD,MAAM,eAAe,GAAG,CACtB,OAAiB,EACjB,OAA2C,EAC3C,mBAAyC,EACzC,EAAE;IACF,MAAM,MAAM,GAAiB,OAAO,CAAC,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC1E,MAAM,MAAM,GAAe,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAC1C,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACrB,MAAM,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC;QACpB,MAAM,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAA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AAK,CAAC,OAAO,KAAK,KAAK;aACnB,CAAC;SACjB;QACD,OAAO;YACL,CAAC,EAAE,KAAK,CAAC,CAAC;YACV,CAAC,EAAE,CAAC;YACJ,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,EAAE,EAAE,CAAC;YACL,OAAO,EAAE,KAAK,CAAC,OAAO,KAAK,KAAK;SACnB,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAA4B,CACpD,OAAiB,EACjB,OAAoC,EACpC,mBAAyC,EACzC,EAAE;IACF,OAAO;QACL,IAAI,EAAE,EAAE,MAAM,EAAE,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,mBAAmB,CAAC,EAAE;QACtE,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE;KAC7D,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAA4B,CACrD,OAAiB,EACjB,OAAoC,EACpC,mBAAyC,EACzC,EAAE;IACF,OAAO;QACL,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE;QAC7D,EAAE,EAAE,EAAE,MAAM,EAAE,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,mBAAmB,CAAC,EAAE;KACrE,CAAC;AACJ,CAAC,CAAC","file":"grow-points.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { isValidNumber } from '@visactor/vutils';\nimport type {\n IElement,\n IGrowPointsOverallAnimationOptions,\n IAnimationParameters,\n IGrowPointsAnimationOptions,\n TypeAnimation\n} from '../../../types';\n\nconst getCenterPoints = (\n element: IElement,\n options: IGrowPointsOverallAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const points: IPointLike[] = element.getGraphicAttribute('points', false);\n const center: IPointLike = { x: 0, y: 0 };\n points.forEach(point => {\n center.x += point.x;\n center.y += point.y;\n });\n center.x /= points.length;\n center.y /= points.length;\n\n if (options && options.center) {\n if (isValidNumber(options.center.x)) {\n center.x = options.center.x;\n }\n if (isValidNumber(options.center.y)) {\n center.y = options.center.y;\n }\n }\n\n if (element.mark.markType === 'area') {\n center.x1 = center.x;\n center.y1 = center.y;\n }\n\n return points.map(() => Object.assign(center));\n};\n\nexport const growPointsIn: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsOverallAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: getCenterPoints(element, options, animationParameters) },\n to: { points: element.getGraphicAttribute('points', false) }\n };\n};\n\nexport const growPointsOut: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsOverallAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: element.getGraphicAttribute('points', true) },\n to: { points: getCenterPoints(element, options, animationParameters) }\n };\n};\n\n// grow points x\n\nconst changePointsX = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const points = element.getGraphicAttribute('points', false);\n return points.map((point: IPointLike) => {\n if (options && options.orient === 'negative') {\n let groupRight = animationParameters.width;\n\n if (animationParameters.group) {\n groupRight = (animationParameters as any).groupWidth ?? animationParameters.group.getBounds().width();\n\n (animationParameters as any).groupWidth = groupRight;\n }\n\n return {\n x: groupRight,\n y: point.y,\n x1: groupRight,\n y1: point.y1,\n defined: point.defined !== false\n } as IPointLike;\n }\n return {\n x: 0,\n y: point.y,\n x1: 0,\n y1: point.y1,\n defined: point.defined !== false\n } as IPointLike;\n });\n};\n\nexport const growPointsXIn: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: changePointsX(element, options, animationParameters) },\n to: { points: element.getGraphicAttribute('points', false) }\n };\n};\n\nexport const growPointsXOut: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: element.getGraphicAttribute('points', true) },\n to: { points: changePointsX(element, options, animationParameters) }\n };\n};\n\n// grow points y\n\nconst changePointsY = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const points = element.getGraphicAttribute('points', false);\n return points.map((point: IPointLike) => {\n if (options && options.orient === 'negative') {\n let groupBottom = animationParameters.height;\n\n if (animationParameters.group) {\n groupBottom = (animationParameters as any).groupHeight ?? animationParameters.group.getBounds().height();\n\n (animationParameters as any).groupHeight = groupBottom;\n }\n\n return {\n x: point.x,\n y: groupBottom,\n x1: point.x1,\n y1: groupBottom,\n defined: point.defined !== false\n } as IPointLike;\n }\n return {\n x: point.x,\n y: 0,\n x1: point.x1,\n y1: 0,\n defined: point.defined !== false\n } as IPointLike;\n });\n};\n\nexport const growPointsYIn: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: changePointsY(element, options, animationParameters) },\n to: { points: element.getGraphicAttribute('points', false) }\n };\n};\n\nexport const growPointsYOut: TypeAnimation<IElement> = (\n element: IElement,\n options: IGrowPointsAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n return {\n from: { points: element.getGraphicAttribute('points', true) },\n to: { points: changePointsY(element, options, animationParameters) }\n };\n};\n"]}
|
|
@@ -68,8 +68,9 @@ export class Animator {
|
|
|
68
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
|
-
|
|
72
|
-
|
|
71
|
+
const attributes = effect.type ? typeAnimationAttributes(this.element, effect, animationParameters, parameters) : effect.channel ? channelAnimationAttributes(this.element, effect, animationParameters, parameters) : void 0;
|
|
72
|
+
if (!attributes) return null;
|
|
73
|
+
const customOption = (null == attributes ? void 0 : attributes.custom) || (null == effect ? void 0 : effect.custom), customParametersOption = (null == attributes ? void 0 : attributes.customParameters) || (null == effect ? void 0 : effect.customParameters);
|
|
73
74
|
attributes.from && Object.keys(attributes.from).length && this.unit && this.animationOptions.timeline.controlOptions.immediatelyApply && "component" !== this.element.mark.markType && this.element.getGraphicItem().setAttributes(attributes.from);
|
|
74
75
|
const isCustomAnimate = isCustomAnimateCtor(customOption);
|
|
75
76
|
return !isNil(customOption) && !isCustomAnimateCtor(customOption) ? new CustomInterpolator(attributes.from, attributes.to, duration, effect.easing, {
|
|
@@ -78,7 +79,7 @@ export class Animator {
|
|
|
78
79
|
parameters: customParametersOption
|
|
79
80
|
}) : isCustomAnimate ? new customOption(attributes.from, attributes.to, duration, effect.easing, customParametersOption) : attributes.to ? new AttributeAnimate(attributes.from, attributes.to, duration, effect.easing) : void 0;
|
|
80
81
|
})).filter((animate => !isNil(animate)));
|
|
81
|
-
1 === customAnimates.length ? graphicAnimate.play(customAnimates[0]) : graphicAnimate.play(new AnimateGroup(duration, customAnimates));
|
|
82
|
+
1 === customAnimates.length ? graphicAnimate.play(customAnimates[0]) : customAnimates.length > 1 && graphicAnimate.play(new AnimateGroup(duration, customAnimates));
|
|
82
83
|
}
|
|
83
84
|
delayAfter > 0 && graphicAnimate.wait(delayAfter);
|
|
84
85
|
}
|
|
@@ -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,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AAI,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(delay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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,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;gBACpC,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 = effect.type\n ? typeAnimationAttributes(this.element, effect, animationParameters, parameters)\n : effect.channel\n ? channelAnimationAttributes(this.element, effect, animationParameters, parameters)\n : undefined;\n\n if (!attributes) {\n return null;\n }\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 if (customAnimates.length > 1) {\n graphicAnimate.play(new AnimateGroup(duration, customAnimates));\n }\n }\n\n if (delayAfter > 0) {\n graphicAnimate.wait(delayAfter);\n }\n }\n}\n"]}
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;AAEhC,cAAc,SAAS,CAAC;AAExB,cAAc,gBAAgB,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EACL,cAAc,EACd,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC","file":"index.js","sourcesContent":["// -- Exports -----\nexport const version = \"0.10.
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;AAEhC,cAAc,SAAS,CAAC;AAExB,cAAc,gBAAgB,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EACL,cAAc,EACd,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC","file":"index.js","sourcesContent":["// -- Exports -----\nexport const version = \"0.10.7\";\n\nexport * from './graph';\n\nexport * from './interactions';\n\nexport { View } from './view';\nexport { Scale, registerScale } from './view/scale';\nexport { Coordinate, registerCoordinate } from './view/coordinate';\nexport { parseFunctionType, invokeFunctionType } from './parse/util';\nexport { GrammarBase } from './view/grammar-base';\nexport * from './util/text';\nexport * from './types';\nexport { Factory } from './core/factory';\nexport {\n SIGNAL_AUTOFIT,\n SIGNAL_HEIGHT,\n SIGNAL_PADDING,\n SIGNAL_VIEW_HEIGHT,\n SIGNAL_VIEW_WIDTH,\n SIGNAL_WIDTH,\n SIGNAL_VIEW_BOX\n} from './view/constants';\n\nexport { ThemeManager } from './theme/theme-manager';\n\nexport * from './glyph';\nexport * from './component';\nexport * from './transforms';\nexport * from './graph/animation/animation';\n\nexport { vglobal } from '@visactor/vrender-core';\nexport * from './env';\nexport * from './interactions';\nexport * from './semantic-marks/cell';\nexport * from './semantic-marks/interval';\nexport * from './graph/mark/graphic';\n"]}
|
package/es/interactions/index.js
CHANGED
package/es/interactions/utils.js
CHANGED
|
@@ -2,4 +2,4 @@ export const generateFilterValue = options => options.filterField ? el => {
|
|
|
2
2
|
var _a;
|
|
3
3
|
return null === (_a = el.getDatum()) || void 0 === _a ? void 0 : _a[options.filterField];
|
|
4
4
|
} : el => el[options.filterType];
|
|
5
|
-
//# sourceMappingURL=utils.js.map
|
|
5
|
+
//# sourceMappingURL=utils.js.map
|
package/es/parse/coordinate.js
CHANGED
package/es/parse/event.js
CHANGED
package/es/parse/mark.js
CHANGED
|
@@ -16,4 +16,4 @@ export function parseEncodeType(encoder, view) {
|
|
|
16
16
|
return encoder.scale && (dependencies = isGrammar(encoder.scale) ? [ encoder.scale ] : array(view.getScaleById(encoder.scale))),
|
|
17
17
|
dependencies.concat(parseFunctionType(encoder, view));
|
|
18
18
|
}
|
|
19
|
-
//# sourceMappingURL=mark.js.map
|
|
19
|
+
//# sourceMappingURL=mark.js.map
|
package/es/parse/option.js
CHANGED
|
@@ -8,4 +8,4 @@ export const parseOptions = (options, params) => options ? isObject(options) ? O
|
|
|
8
8
|
const option = options[key];
|
|
9
9
|
return res[key] = parseOptionValue(option, params), res;
|
|
10
10
|
}), {}) : options.map((option => parseOptionValue(option, params))) : options;
|
|
11
|
-
//# sourceMappingURL=option.js.map
|
|
11
|
+
//# sourceMappingURL=option.js.map
|
package/es/parse/scale.js
CHANGED
package/es/parse/transform.js
CHANGED
package/es/parse/util.js
CHANGED
|
@@ -62,4 +62,4 @@ export const isGrammar = el => el && !isNil(el.grammarType);
|
|
|
62
62
|
export const parseField = field => isFunction(field) ? field : datum => datum[field];
|
|
63
63
|
|
|
64
64
|
export const parseColor = color => isString(color) && Color.parseColorString(color) ? color : null;
|
|
65
|
-
//# sourceMappingURL=util.js.map
|
|
65
|
+
//# sourceMappingURL=util.js.map
|
package/es/parse/view.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { isNil } from "@visactor/vutils";
|
|
2
2
|
|
|
3
|
+
const HIDE_KEY = "_mo_hide_";
|
|
4
|
+
|
|
3
5
|
function reset(elements) {
|
|
4
6
|
return elements.forEach((element => {
|
|
5
|
-
element.setGraphicAttribute("visible", !0)
|
|
7
|
+
element.getGraphicAttribute("HIDE_KEY") && (element.setGraphicAttribute("visible", !0),
|
|
8
|
+
element.setGraphicAttribute(HIDE_KEY, !1));
|
|
6
9
|
})), elements;
|
|
7
10
|
}
|
|
8
11
|
|
|
@@ -12,9 +15,10 @@ function overlapX(elements, delta, deltaMul, useRadius) {
|
|
|
12
15
|
const useDeltaMul = isNil(delta);
|
|
13
16
|
let itemDelta = delta;
|
|
14
17
|
elements.forEach((element => {
|
|
18
|
+
if (!1 === element.getGraphicAttribute("visible")) return;
|
|
15
19
|
const r = element.getGraphicAttribute("size") / 2, currentX = element.getGraphicAttribute("x");
|
|
16
|
-
useDeltaMul && (itemDelta = (r + lastR) * deltaMul), Math.abs(currentX - lastX) < itemDelta + lastR + r ? element.getGraphicAttribute("forceShow") || element.setGraphicAttribute(
|
|
17
|
-
lastR = r;
|
|
20
|
+
useDeltaMul && (itemDelta = (r + lastR) * deltaMul), Math.abs(currentX - lastX) < itemDelta + lastR + r ? element.getGraphicAttribute("forceShow") || (element.setGraphicAttribute(HIDE_KEY, !0),
|
|
21
|
+
element.setGraphicAttribute("visible", !1)) : lastX = currentX, lastR = r;
|
|
18
22
|
}));
|
|
19
23
|
}
|
|
20
24
|
}
|
|
@@ -25,9 +29,10 @@ function overlapY(elements, delta, deltaMul, useRadius) {
|
|
|
25
29
|
const useDeltaMul = isNil(delta);
|
|
26
30
|
let itemDelta = delta;
|
|
27
31
|
elements.forEach((element => {
|
|
32
|
+
if (!1 === element.getGraphicAttribute("visible")) return;
|
|
28
33
|
const r = element.getGraphicAttribute("size") / 2, currentY = element.getGraphicAttribute("y");
|
|
29
|
-
useDeltaMul && (itemDelta = (r + lastR) * deltaMul), Math.abs(currentY - lastY) < itemDelta + lastR + r ? element.getGraphicAttribute("forceShow") || element.setGraphicAttribute(
|
|
30
|
-
lastR = r;
|
|
34
|
+
useDeltaMul && (itemDelta = (r + lastR) * deltaMul), Math.abs(currentY - lastY) < itemDelta + lastR + r ? element.getGraphicAttribute("forceShow") || (element.setGraphicAttribute(HIDE_KEY, !0),
|
|
35
|
+
element.setGraphicAttribute("visible", !1)) : lastY = currentY, lastR = r;
|
|
31
36
|
}));
|
|
32
37
|
}
|
|
33
38
|
}
|
|
@@ -39,10 +44,11 @@ function overlapXY(elements, delta, deltaMul, useRadius) {
|
|
|
39
44
|
const useDeltaMul = isNil(delta);
|
|
40
45
|
let itemDelta = delta;
|
|
41
46
|
elements.forEach((element => {
|
|
47
|
+
if (!1 === element.getGraphicAttribute("visible")) return;
|
|
42
48
|
const r = element.getGraphicAttribute("size") / 2, currentX = element.getGraphicAttribute("x"), currentY = element.getGraphicAttribute("y");
|
|
43
49
|
useDeltaMul && (itemDelta = (r + lastR) * deltaMul), dis = (lastX - currentX) ** 2 + (lastY - currentY) ** 2,
|
|
44
|
-
dis < (itemDelta + lastR + r) ** 2 ? element.getGraphicAttribute("forceShow") || element.setGraphicAttribute(
|
|
45
|
-
lastR = r;
|
|
50
|
+
dis < (itemDelta + lastR + r) ** 2 ? element.getGraphicAttribute("forceShow") || (element.setGraphicAttribute(HIDE_KEY, !0),
|
|
51
|
+
element.setGraphicAttribute("visible", !1)) : lastY = currentY, lastR = r;
|
|
46
52
|
}));
|
|
47
53
|
}
|
|
48
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/transforms/mark/mark-overlap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,SAAS,KAAK,CAAC,QAAoB;IACjC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACzB,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/transforms/mark/mark-overlap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,MAAM,QAAQ,GAAG,WAAW,CAAC;AAE7B,SAAS,KAAK,CAAC,QAAoB;IACjC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACzB,MAAM,IAAI,GAAG,OAAO,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAErD,IAAI,IAAI,EAAE;YACR,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAC7C,OAAO,CAAC,mBAAmB,CAAC,QAAQ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AG,CAAC,SAAS,CAAC,EAAE;gBAClB,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aAC9B;iBAAM;gBACL,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;aAC5B;YAED,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC7B,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC","file":"mark-overlap.js","sourcesContent":["import { isNil } from '@visactor/vutils';\nimport type { IElement, MarkOverlapTransformOptions } from '../../types';\n\nconst HIDE_KEY = '_mo_hide_';\n\nfunction reset(elements: IElement[]) {\n elements.forEach(element => {\n const hide = element.getGraphicAttribute('HIDE_KEY');\n\n if (hide) {\n element.setGraphicAttribute('visible', true);\n element.setGraphicAttribute(HIDE_KEY, false);\n }\n });\n return elements;\n}\n\nfunction overlapX(elements: IElement[], delta: number, deltaMul: number, useRadius: boolean) {\n if (useRadius) {\n let lastX = -Infinity;\n let lastR = 0;\n const useDeltaMul = isNil(delta);\n let itemDelta = delta;\n\n elements.forEach(element => {\n if (element.getGraphicAttribute('visible') === false) {\n // skip hidden points\n return;\n }\n\n const r = element.getGraphicAttribute('size') / 2;\n const currentX = element.getGraphicAttribute('x');\n if (useDeltaMul) {\n itemDelta = (r + lastR) * deltaMul;\n }\n if (Math.abs(currentX - lastX) < itemDelta + lastR + r) {\n if (!element.getGraphicAttribute('forceShow')) {\n element.setGraphicAttribute(HIDE_KEY, true);\n element.setGraphicAttribute('visible', false);\n }\n } else {\n lastX = currentX;\n }\n\n lastR = r;\n });\n }\n}\n\nfunction overlapY(elements: IElement[], delta: number, deltaMul: number, useRadius: boolean) {\n if (useRadius) {\n let lastY = -Infinity;\n let lastR = 0;\n const useDeltaMul = isNil(delta);\n let itemDelta = delta;\n\n elements.forEach(element => {\n if (element.getGraphicAttribute('visible') === false) {\n // skip hidden points\n return;\n }\n\n const r = element.getGraphicAttribute('size') / 2;\n const currentY = element.getGraphicAttribute('y');\n if (useDeltaMul) {\n itemDelta = (r + lastR) * deltaMul;\n }\n if (Math.abs(currentY - lastY) < itemDelta + lastR + r) {\n if (!element.getGraphicAttribute('forceShow')) {\n element.setGraphicAttribute(HIDE_KEY, true);\n element.setGraphicAttribute('visible', false);\n }\n } else {\n lastY = currentY;\n }\n\n lastR = r;\n });\n }\n}\n\nfunction overlapXY(elements: IElement[], delta: number, deltaMul: number, useRadius: boolean) {\n if (useRadius) {\n const lastX = -Infinity;\n let lastY = -Infinity;\n let lastR = 0;\n let dis = 0;\n const useDeltaMul = isNil(delta);\n let itemDelta = delta;\n\n elements.forEach(element => {\n if (element.getGraphicAttribute('visible') === false) {\n // skip hidden points\n return;\n }\n\n const r = element.getGraphicAttribute('size') / 2;\n const currentX = element.getGraphicAttribute('x');\n const currentY = element.getGraphicAttribute('y');\n\n if (useDeltaMul) {\n itemDelta = (r + lastR) * deltaMul;\n }\n dis = (lastX - currentX) ** 2 + (lastY - currentY) ** 2;\n if (dis < (itemDelta + lastR + r) ** 2) {\n if (!element.getGraphicAttribute('forceShow')) {\n element.setGraphicAttribute(HIDE_KEY, true);\n element.setGraphicAttribute('visible', false);\n }\n } else {\n lastY = currentY;\n }\n\n lastR = r;\n });\n }\n}\n\n/**\n * 针对mark的防重叠\n * @param {object} options - The parameters for this operator.\n * @param {data} [options.followMark]\n * @constructor\n */\nexport const transform = (options: MarkOverlapTransformOptions, upstreamData: IElement[]) => {\n if (!upstreamData || upstreamData.length === 0) {\n return;\n }\n let { radius } = options;\n if (isNil(radius)) {\n if (upstreamData[0].mark.markType === 'symbol') {\n radius = true;\n }\n }\n\n const { direction, delta, deltaMul = 1, groupBy } = options;\n\n const handleOverlap = (elements: IElement[]) => {\n reset(elements);\n\n const sortedElements = elements.slice().sort((a, b) => {\n return a.getGraphicAttribute('x') - b.getGraphicAttribute('x');\n });\n\n if (direction === 0) {\n overlapXY(sortedElements, delta, deltaMul, radius);\n } else if (direction === 1) {\n overlapX(sortedElements, delta, deltaMul, radius);\n } else {\n overlapY(sortedElements, delta, deltaMul, radius);\n }\n };\n\n if (!groupBy) {\n handleOverlap(upstreamData);\n } else {\n // 分组\n const map = upstreamData.reduce((res: { [key: string]: IElement[] }, element: IElement) => {\n const groupName = element.getDatum()[groupBy];\n\n if (res[groupName]) {\n res[groupName].push(element);\n } else {\n res[groupName] = [element];\n }\n\n return res;\n }, {});\n\n Object.keys(map).forEach(key => {\n handleOverlap(map[key]);\n });\n }\n\n return upstreamData;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visactor/vgrammar-core",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.7",
|
|
4
4
|
"description": "VGrammar is a visual grammar library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"grammar",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"dist"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@visactor/vgrammar-coordinate": "0.10.
|
|
28
|
-
"@visactor/vgrammar-util": "0.10.
|
|
27
|
+
"@visactor/vgrammar-coordinate": "0.10.7",
|
|
28
|
+
"@visactor/vgrammar-util": "0.10.7",
|
|
29
29
|
"@visactor/vscale": "~0.17.3",
|
|
30
|
-
"@visactor/vrender-core": "~0.17.
|
|
31
|
-
"@visactor/vrender-kits": "~0.17.
|
|
32
|
-
"@visactor/vrender-components": "~0.17.
|
|
30
|
+
"@visactor/vrender-core": "~0.17.11",
|
|
31
|
+
"@visactor/vrender-kits": "~0.17.11",
|
|
32
|
+
"@visactor/vrender-components": "~0.17.11",
|
|
33
33
|
"@visactor/vutils": "~0.17.3",
|
|
34
34
|
"@visactor/vdataset": "~0.17.3"
|
|
35
35
|
},
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"ts-jest": "~29.1.0",
|
|
45
45
|
"@types/jest": "~29.5.0",
|
|
46
46
|
"typescript": "4.9.5",
|
|
47
|
-
"@internal/
|
|
47
|
+
"@internal/ts-config": "0.0.1",
|
|
48
48
|
"@internal/eslint-config": "0.0.1",
|
|
49
|
-
"@internal/
|
|
50
|
-
"@internal/
|
|
49
|
+
"@internal/bundler": "0.0.1",
|
|
50
|
+
"@internal/jest-config": "0.0.1"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public",
|