UNPKG

@visactor/vchart

Version:

charts lib based @visactor/VGrammar

37 lines (27 loc) 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.getDiffAttributesOfGraphic = exports.findMarkGraphic = exports.getDatumOfGraphic = exports.isCollectionMark = void 0; const isCollectionMark = type => "line" === type || "area" === type; exports.isCollectionMark = isCollectionMark; const getDatumOfGraphic = g => { if (!g || !g.context) return null; const {data: data, markType: markType} = g.context; return (0, exports.isCollectionMark)(markType) ? data : null == data ? void 0 : data[0]; }; exports.getDatumOfGraphic = getDatumOfGraphic; const findMarkGraphic = (rootGroup, target) => { let g = target; for (;(null == g ? void 0 : g.parent) && g.parent !== rootGroup; ) if (g = g.parent, g.context) return g; return null; }; exports.findMarkGraphic = findMarkGraphic; const getDiffAttributesOfGraphic = (g, newAttrs) => { const prevAttrs = g.getAttributes(!0), diffAttrs = {}; return Object.keys(newAttrs).forEach((key => { prevAttrs[key] !== newAttrs[key] && (diffAttrs[key] = newAttrs[key]); })), diffAttrs; }; exports.getDiffAttributesOfGraphic = getDiffAttributesOfGraphic; //# sourceMappingURL=mark.js.map