@visactor/vchart
Version:
charts lib based @visactor/VGrammar
55 lines (46 loc) • 1.67 kB
JavaScript
import { Factory } from "../../core/factory";
function barGrowOption(barParams, isOverall = !0) {
return (datum, element, params) => {
const field = "vertical" === barParams.direction ? barParams.yField : barParams.xField, data = null == datum ? void 0 : datum[field];
return "vertical" === barParams.direction ? {
overall: isOverall ? barParams.growFrom() : isOverall,
orient: data > 0 ? "negative" : "positive"
} : {
overall: !!isOverall && barParams.growFrom(),
orient: data > 0 ? "positive" : "negative"
};
};
}
export const barGrowIn = (params, isOverall = !0) => ({
type: "horizontal" === params.direction ? "growWidthIn" : "growHeightIn",
options: barGrowOption(params, isOverall)
});
export const barGrowOut = (params, isOverall = !0) => ({
type: "horizontal" === params.direction ? "growWidthOut" : "growHeightOut",
options: barGrowOption(params, isOverall)
});
const Appear_FadeIn = {
type: "fadeIn"
}, Appear_ScaleIn = {
type: "growCenterIn"
};
export function barPresetAnimation(params, preset) {
if (!1 === preset) return {};
switch (preset) {
case "fadeIn":
return Appear_FadeIn;
case "scaleIn":
return Appear_ScaleIn;
default:
return barGrowIn(params);
}
}
export const registerBarAnimation = () => {
Factory.registerAnimation("bar", ((params, preset) => ({
appear: barPresetAnimation(params, preset),
enter: barGrowIn(params, !1),
exit: barGrowOut(params, !1),
disappear: barGrowOut(params)
})));
};
//# sourceMappingURL=animation.js.map