UNPKG

victory-native

Version:

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

30 lines (29 loc) 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCategoryYAxisLabelPosition = void 0; const getCategoryYAxisLabelPosition = ({ axisSide, labelPosition, labelOffset, labelWidth, lineCount, lineHeight, fontSize, tickPosition, chartBounds, }) => { const y = tickPosition + fontSize / 3 - Math.max(0, lineCount * lineHeight - fontSize) / 2; const x = (() => { if (axisSide === "left" && labelPosition === "outset") { return chartBounds.left - (labelWidth + labelOffset); } if (axisSide === "left" && labelPosition === "inset") { return chartBounds.left + labelOffset; } if (axisSide === "right" && labelPosition === "outset") { return chartBounds.right + labelOffset; } return chartBounds.right - (labelWidth + labelOffset); })(); const lastLineY = y + (lineCount - 1) * lineHeight; const canFitContent = y > chartBounds.top + fontSize / 2 && lastLineY < chartBounds.bottom + fontSize / 2; return { x, y, canFitContent, }; }; exports.getCategoryYAxisLabelPosition = getCategoryYAxisLabelPosition;