UNPKG

@visactor/vchart

Version:

charts lib based @visactor/VGrammar

67 lines (55 loc) 2.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.registerWordCloud3dAnimation = exports.registerWordCloudAnimation = exports.wordcloudPresetAnimation = exports.WordCloudScaleInAnimation = exports.WordCloud3dAnimation = void 0; const vrender_core_1 = require("@visactor/vrender-core"), config_1 = require("../../animation/config"), factory_1 = require("../../core/factory"), WordCloud3dAnimation = params => ({ custom: vrender_core_1.RotateBySphereAnimate, customParameters: (datum, element) => params, easing: "linear", loop: 1 / 0, duration: 6e3 }); function computeWordDelay(duration, totalTime, wordCount) { return duration * wordCount < totalTime ? duration + (totalTime - wordCount * duration) / (wordCount - 1) : (totalTime - duration) / (wordCount - 1); } exports.WordCloud3dAnimation = WordCloud3dAnimation; const WordCloudScaleInAnimation = params => ({ channel: { fontSize: { from: 0 } }, duration: 200, delay: (datum, element, vgrammarParams) => { const animationConfig = params.animationConfig(), duration = (null == animationConfig ? void 0 : animationConfig.duration) || 200, totalTime = (null == animationConfig ? void 0 : animationConfig.totalTime) || config_1.DEFAULT_ANIMATION_CONFIG.appear.duration, count = vgrammarParams.VGRAMMAR_ANIMATION_PARAMETERS.elementCount; return vgrammarParams.VGRAMMAR_ANIMATION_PARAMETERS.elementIndex * computeWordDelay(duration, totalTime, count); } }); function wordcloudPresetAnimation(params, preset) { return !1 === preset ? {} : "fadeIn" === preset ? { type: "fadeIn" } : (0, exports.WordCloudScaleInAnimation)(params); } exports.WordCloudScaleInAnimation = WordCloudScaleInAnimation, exports.wordcloudPresetAnimation = wordcloudPresetAnimation; const registerWordCloudAnimation = () => { factory_1.Factory.registerAnimation("wordCloud", ((params, preset) => ({ appear: wordcloudPresetAnimation(params, preset), enter: { type: "fadeIn" }, exit: { type: "fadeOut" }, disappear: { type: "fadeOut" } }))); }; exports.registerWordCloudAnimation = registerWordCloudAnimation; const registerWordCloud3dAnimation = () => { factory_1.Factory.registerAnimation("wordCloud3d", (params => ({ enter: (0, exports.WordCloud3dAnimation)(params) }))); }; exports.registerWordCloud3dAnimation = registerWordCloud3dAnimation; //# sourceMappingURL=animation.js.map