@visactor/vchart
Version:
charts lib based @visactor/VGrammar
53 lines (45 loc) • 2.08 kB
JavaScript
import { array, isNumber, isString } from "@visactor/vutils";
import { getDatumOfGraphic } from "../../util";
import { STATE_VALUE_ENUM } from "../../compile/mark/interface";
export const parseTriggerOffOfSelect = triggerOff => {
const triggerOffArray = array(triggerOff), resetType = [], eventNames = [];
return triggerOffArray.forEach((off => {
"empty" === off ? resetType.push("view") : isString(off) && "none" !== off ? off.includes("view:") ? (eventNames.push(off.replace("view:", "")),
resetType.push("view")) : (eventNames.push(off), resetType.push("self")) : isNumber(off) && resetType.push("timeout");
})), {
eventNames: eventNames,
resetType: resetType
};
};
export const groupMarksByState = (marks, states) => {
if (!states || !marks) return null;
const res = {};
return marks.forEach((mark => {
const stateStyle = mark.stateStyle;
stateStyle && states.forEach((state => {
state && stateStyle[state] && (res[state] || (res[state] = []), res[state].push(mark.id));
}));
})), res;
};
export const filterMarksOfInteraction = (interactionSpec, marks) => {
if (!marks || !marks.length) return [];
const selector = [];
return interactionSpec.markIds ? marks.filter((mark => {
interactionSpec.markIds.includes(mark.getProductId()) && selector.push(mark);
})) : interactionSpec.markNames ? marks.forEach((mark => {
interactionSpec.markNames.includes(mark.name) && selector.push(mark);
})) : marks.forEach((mark => {
selector.push(mark);
})), selector;
};
export const generateFilterValue = options => options.filterField ? g => {
var _a;
return null === (_a = getDatumOfGraphic(g)) || void 0 === _a ? void 0 : _a[options.filterField];
} : el => el.context[options.filterType];
export const highlightDefaultOptions = {
highlightState: STATE_VALUE_ENUM.STATE_HIGHLIGHT,
blurState: STATE_VALUE_ENUM.STATE_BLUR,
trigger: "pointerover",
triggerOff: "pointerout"
};
//# sourceMappingURL=util.js.map