UNPKG

victory-native

Version:

A charting library for React Native with a focus on performance and customization.

20 lines (19 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getRotatedYAxisTitleBaselineY = exports.getAxisTitleLayout = exports.DEFAULT_AXIS_TITLE_OFFSET = void 0; const textLayout_1 = require("../../utils/textLayout"); exports.DEFAULT_AXIS_TITLE_OFFSET = 4; const DEFAULT_AXIS_TITLE_POSITION = "center"; const getAxisTitleLayout = ({ title, font, }) => { var _a, _b, _c; const titleFont = (title === null || title === void 0 ? void 0 : title.font) !== undefined ? title.font : font; const text = (_a = title === null || title === void 0 ? void 0 : title.text) !== null && _a !== void 0 ? _a : ""; const layout = (0, textLayout_1.getTextLayout)(text, titleFont); return Object.assign(Object.assign({}, layout), { text, font: titleFont, color: title === null || title === void 0 ? void 0 : title.color, offset: (_b = title === null || title === void 0 ? void 0 : title.offset) !== null && _b !== void 0 ? _b : exports.DEFAULT_AXIS_TITLE_OFFSET, position: (_c = title === null || title === void 0 ? void 0 : title.position) !== null && _c !== void 0 ? _c : DEFAULT_AXIS_TITLE_POSITION, hasContent: Boolean(titleFont && text && layout.width > 0) }); }; exports.getAxisTitleLayout = getAxisTitleLayout; const getRotatedYAxisTitleBaselineY = ({ height, fontSize, }) => { const multilineOffset = height - fontSize; return multilineOffset > 0 ? -multilineOffset : 0; }; exports.getRotatedYAxisTitleBaselineY = getRotatedYAxisTitleBaselineY;