UNPKG

@visactor/vtable

Version:

canvas table width high performance

200 lines (194 loc) 7.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.getAxisAttributes = exports.getCommonAxis = exports.commonAxis = exports.THEME_CONSTANTS = exports.DEFAULT_TEXT_FONT_SIZE = exports.DEFAULT_TEXT_FONT_FAMILY = void 0; const vutils_1 = require("@visactor/vutils"), transform_1 = require("../util/transform"), DEFAULT_TITLE_STYLE = { left: { textAlign: "center", textBaseline: "bottom" }, right: { textAlign: "center", textBaseline: "bottom" }, radius: {}, angle: {} }; function getCommonAxis(theme) { var _a, _b; return (null === (_b = null === (_a = null == theme ? void 0 : theme.colorScheme) || void 0 === _a ? void 0 : _a.default) || void 0 === _b ? void 0 : _b.palette) ? (0, vutils_1.merge)({}, exports.commonAxis, { tick: { style: { stroke: theme.colorScheme.default.palette.axisDomainColor || "#D9DDE4" } }, subTick: { style: { stroke: theme.colorScheme.default.palette.axisDomainColor || "#D9DDE4" } }, label: { style: { fill: theme.colorScheme.default.palette.axisLabelFontColor || "#89909D" } }, title: { style: { fill: theme.colorScheme.default.palette.secondaryFontColor || "#333333" } } }) : exports.commonAxis; } function getAxisAttributes(option) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; const spec = (0, vutils_1.merge)({}, option); let titleTextStyle, titleAngle = null !== (_b = null === (_a = spec.title) || void 0 === _a ? void 0 : _a.angle) && void 0 !== _b ? _b : 0; "left" !== spec.orient && "right" !== spec.orient || (null === (_c = spec.title) || void 0 === _c ? void 0 : _c.autoRotate) && (0, vutils_1.isNil)(spec.title.angle) && (titleAngle = "left" === spec.orient ? -90 : 90, titleTextStyle = DEFAULT_TITLE_STYLE[spec.orient]); const labelSpec = (0, vutils_1.pickWithout)(spec.label, [ "style", "formatMethod", "state" ]); return { orient: spec.orient, select: spec.select, hover: spec.hover, line: (0, transform_1.transformAxisLineStyle)(spec.domainLine), label: Object.assign({ style: (0, transform_1.transformToGraphic)(spec.label.style), formatMethod: spec.label.formatMethod ? (value, datum, index) => spec.label.formatMethod(datum.rawValue, datum) : null, state: (0, transform_1.transformStateStyle)(spec.label.state) }, labelSpec), tick: { visible: spec.tick.visible, length: spec.tick.tickSize, inside: spec.tick.inside, alignWithLabel: spec.tick.alignWithLabel, style: (0, transform_1.transformToGraphic)(spec.tick.style), state: (0, transform_1.transformStateStyle)(spec.tick.state), dataFilter: spec.tick.dataFilter }, subTick: { visible: spec.subTick.visible, length: spec.subTick.tickSize, inside: spec.subTick.inside, count: spec.subTick.tickCount, style: (0, transform_1.transformToGraphic)(spec.subTick.style), state: (0, transform_1.transformStateStyle)(spec.subTick.state) }, grid: { type: "line", visible: spec.grid.visible, alternateColor: spec.grid.alternateColor, alignWithLabel: spec.grid.alignWithLabel, style: (0, transform_1.transformToGraphic)(spec.grid.style) }, subGrid: { type: "line", visible: spec.subGrid.visible, alternateColor: spec.subGrid.alternateColor, style: (0, transform_1.transformToGraphic)(spec.subGrid.style) }, title: { visible: spec.title.visible, position: spec.title.position, space: spec.title.space, autoRotate: !1, angle: titleAngle ? (0, vutils_1.degreeToRadian)(titleAngle) : null, textStyle: (0, vutils_1.merge)({}, titleTextStyle, (0, transform_1.transformToGraphic)(spec.title.style)), padding: spec.title.padding, shape: { visible: null === (_d = spec.title.shape) || void 0 === _d ? void 0 : _d.visible, space: null === (_e = spec.title.shape) || void 0 === _e ? void 0 : _e.space, style: (0, transform_1.transformToGraphic)(null === (_f = spec.title.shape) || void 0 === _f ? void 0 : _f.style) }, background: { visible: null === (_g = spec.title.background) || void 0 === _g ? void 0 : _g.visible, style: (0, transform_1.transformToGraphic)(null === (_h = spec.title.background) || void 0 === _h ? void 0 : _h.style) }, state: { text: (0, transform_1.transformStateStyle)(spec.title.state), shape: (0, transform_1.transformStateStyle)(null === (_j = spec.title.shape) || void 0 === _j ? void 0 : _j.state), background: (0, transform_1.transformStateStyle)(null === (_k = spec.title.background) || void 0 === _k ? void 0 : _k.state) } }, panel: { visible: null === (_l = spec.background) || void 0 === _l ? void 0 : _l.visible, style: (0, transform_1.transformToGraphic)(null === (_m = spec.background) || void 0 === _m ? void 0 : _m.style), state: (0, transform_1.transformStateStyle)(null === (_o = spec.background) || void 0 === _o ? void 0 : _o.state) } }; } exports.DEFAULT_TEXT_FONT_FAMILY = "PingFang SC,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif, apple color emoji,segoe ui emoji,segoe ui symbol", exports.DEFAULT_TEXT_FONT_SIZE = 14, exports.THEME_CONSTANTS = { FONT_FAMILY: exports.DEFAULT_TEXT_FONT_FAMILY, LABEL_FONT_SIZE: exports.DEFAULT_TEXT_FONT_SIZE, MAP_LABEL_FONT_SIZE: 10, TITLE_FONT_SIZE: 18, AXIS_TICK_SIZE: 4 }, exports.commonAxis = { domainLine: { visible: !0, style: { lineWidth: 1, stroke: "#D9DDE4", strokeOpacity: 1 } }, grid: { visible: !0, style: { lineWidth: 1, stroke: "#EBEDF2", strokeOpacity: 1, lineDash: [] } }, subGrid: { visible: !1, style: { lineWidth: 1, stroke: "#EBEDF2", strokeOpacity: 1, lineDash: [ 4, 4 ] } }, tick: { visible: !0, tickSize: exports.THEME_CONSTANTS.AXIS_TICK_SIZE, style: { lineWidth: 1, stroke: "#D9DDE4", strokeOpacity: 1 } }, subTick: { visible: !1, tickSize: exports.THEME_CONSTANTS.AXIS_TICK_SIZE / 2, style: { lineWidth: 1, stroke: "#D9DDE4", strokeOpacity: 1 } }, label: { visible: !0, space: 1, style: { fontSize: exports.THEME_CONSTANTS.LABEL_FONT_SIZE, fill: "#89909D", fontWeight: "normal", fillOpacity: 1 }, autoLimit: !0 }, title: { space: 10, style: { fontSize: exports.THEME_CONSTANTS.LABEL_FONT_SIZE, fill: "#333333", fontWeight: "normal", fillOpacity: 1 } } }, exports.getCommonAxis = getCommonAxis, exports.getAxisAttributes = getAxisAttributes; //# sourceMappingURL=get-axis-attributes.js.map