UNPKG

@visactor/vchart

Version:

charts lib based @visactor/VGrammar

15 lines (12 loc) 664 B
import { DEFAULT_DATA_INDEX, DEFAULT_MAP_LOOK_UP_KEY } from "../../constant/data"; import { isFunction } from "@visactor/vutils"; export const map = (data, opt) => { const options = isFunction(opt) ? opt() : opt, features = data.features; return features && features.forEach(((f, index) => { var _a, _b; f[DEFAULT_DATA_INDEX] = index; const name = null === (_a = f.properties) || void 0 === _a ? void 0 : _a[options.nameProperty], mappedName = null === (_b = options.nameMap) || void 0 === _b ? void 0 : _b[`${name}`]; f[DEFAULT_MAP_LOOK_UP_KEY] = mappedName || name; })), features; }; //# sourceMappingURL=map.js.map