UNPKG

@visactor/vchart

Version:

charts lib based @visactor/VGrammar

63 lines (52 loc) 2.27 kB
import { get } from "@visactor/vutils"; import { transformComponentStyle } from "../../util/style"; export const DEFAULT_TITLE_STYLE = { left: { textAlign: "center", textBaseline: "bottom" }, right: { textAlign: "center", textBaseline: "bottom" }, radius: {}, angle: {} }; export function transformAxisLineStyle(lineCfg) { return (lineCfg = transformComponentStyle(lineCfg)).startSymbol = transformComponentStyle(lineCfg.startSymbol), lineCfg.endSymbol = transformComponentStyle(lineCfg.endSymbol), lineCfg; } export function getAxisLabelOffset(axisSpec) { let labelOffset = 0; return get(axisSpec, "tick.visible") && (labelOffset += get(axisSpec, "tick.tickSize")), get(axisSpec, "label.visible") && (labelOffset += get(axisSpec, "label.space")), labelOffset; } export function getLinearAxisSpecDomain(axisSpec, defaultDomain) { var _a, _b, _c, _d, _e, _f; return { min: null !== (_c = null !== (_a = axisSpec.min) && void 0 !== _a ? _a : null === (_b = axisSpec.range) || void 0 === _b ? void 0 : _b.min) && void 0 !== _c ? _c : null == defaultDomain ? void 0 : defaultDomain.min, max: null !== (_f = null !== (_d = axisSpec.max) && void 0 !== _d ? _d : null === (_e = axisSpec.range) || void 0 === _e ? void 0 : _e.max) && void 0 !== _f ? _f : null == defaultDomain ? void 0 : defaultDomain.max }; } export function isValidCartesianAxis(spec) { const orient = null == spec ? void 0 : spec.orient; return "top" === orient || "bottom" === orient || "left" === orient || "right" === orient || "z" === orient; } export function isValidPolarAxis(spec) { const orient = null == spec ? void 0 : spec.orient; return "angle" === orient || "radius" === orient; } export const isDiscreteAxis = axisType => "band" === axisType || "ordinal" === axisType || "point" === axisType; export function getAxisItem(value, normalizedValue) { return { id: value, label: value, value: normalizedValue, rawValue: value }; } export function shouldUpdateAxis(preHelper, curHelper, forceUpdate) { return forceUpdate || !preHelper || preHelper.getAxisId() === curHelper.getAxisId(); } //# sourceMappingURL=util.js.map