UNPKG

victory-axis

Version:
1,336 lines (1,225 loc) 804 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("react")); else if(typeof define === 'function' && define.amd) define(["react"], factory); else if(typeof exports === 'object') exports["VictoryAxis"] = factory(require("react")); else root["VictoryAxis"] = factory(root["React"]); })(self, function(__WEBPACK_EXTERNAL_MODULE_react__) { return /******/ (function() { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ "./helper-methods.tsx": /*!****************************!*\ !*** ./helper-methods.tsx ***! \****************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "getBaseProps": function() { return /* binding */ getBaseProps; }, /* harmony export */ "getStyles": function() { return /* binding */ getStyles; } /* harmony export */ }); /* harmony import */ var lodash_defaults__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash/defaults */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/defaults.js"); /* harmony import */ var lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_defaults__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/axis.js"); /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/scale.js"); /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/helpers.js"); const orientationSign = { top: -1, left: -1, right: 1, bottom: 1 }; const exists = val => val !== null && val !== undefined; const getCurrentAxis = (props, axis) => { const { orientation, horizontal } = props; if (orientation) { const dimensions = { top: "x", bottom: "x", left: "y", right: "y" }; return dimensions[orientation]; } const otherAxis = axis === "x" ? "y" : "x"; return horizontal ? otherAxis : axis; }; const getScale = props => { const axis = victory_core__WEBPACK_IMPORTED_MODULE_1__.getAxis(props); const currentAxis = getCurrentAxis(props, axis); const scale = victory_core__WEBPACK_IMPORTED_MODULE_2__.getBaseScale(props, axis); const propsDomain = props.domain && props.domain[axis]; const domain = propsDomain || victory_core__WEBPACK_IMPORTED_MODULE_1__.getDomain(props) || scale.domain(); scale.range(victory_core__WEBPACK_IMPORTED_MODULE_3__.getRange(props, currentAxis)); scale.domain(domain); return scale; }; const getStyleObject = props => { const { theme, dependentAxis } = props; const generalAxisStyle = theme && theme.axis && theme.axis.style; const axisType = dependentAxis ? "dependentAxis" : "independentAxis"; const specificAxisStyle = theme && theme[axisType] && theme[axisType].style; const mergeStyles = () => { const styleNamespaces = ["axis", "axisLabel", "grid", "parent", "tickLabels", "ticks"]; return styleNamespaces.reduce((memo, curr) => { memo[curr] = lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, specificAxisStyle[curr], generalAxisStyle[curr]); return memo; }, {}); }; return generalAxisStyle && specificAxisStyle ? mergeStyles() : specificAxisStyle || generalAxisStyle; }; const getStyles = function (props, styleObject) { if (styleObject === void 0) { styleObject = {}; } const style = props.style || {}; const parentStyleProps = { height: "100%", width: "100%" }; return { parent: lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()(style.parent, styleObject.parent, parentStyleProps), axis: lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.axis, styleObject.axis), axisLabel: lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.axisLabel, styleObject.axisLabel), grid: lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.grid, styleObject.grid), ticks: lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.ticks, styleObject.ticks), tickLabels: lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.tickLabels, styleObject.tickLabels) }; }; const getTickProps = (layout, style, datum) => { const { position, transform } = layout; return { x1: transform.x, y1: transform.y, x2: transform.x + position.x2, y2: transform.y + position.y2, style, datum }; }; // eslint-disable-next-line max-params const getTickLabelProps = (layout, style, anchors, datum, text) => { const { position, transform } = layout; return { style, x: transform.x + position.x, y: transform.y + position.y, verticalAnchor: anchors.verticalAnchor, textAnchor: anchors.textAnchor, angle: style.angle, text, datum }; }; const getGridProps = (layout, style, datum) => { const { edge, transform } = layout; return { x1: transform.x, y1: transform.y, x2: edge.x + transform.x, y2: edge.y + transform.y, style, datum }; }; const getAxisProps = (modifiedProps, calculatedValues, globalTransform) => { const { style, padding, isVertical } = calculatedValues; const { width, height } = modifiedProps; return { style: style.axis, x1: isVertical ? globalTransform.x : padding.left + globalTransform.x, x2: isVertical ? globalTransform.x : width - padding.right + globalTransform.x, y1: isVertical ? padding.top + globalTransform.y : globalTransform.y, y2: isVertical ? height - padding.bottom + globalTransform.y : globalTransform.y }; }; const getEvaluatedStyles = (style, props) => { return { tickStyle: victory_core__WEBPACK_IMPORTED_MODULE_3__.evaluateStyle(style.ticks, props), labelStyle: victory_core__WEBPACK_IMPORTED_MODULE_3__.evaluateStyle(style.tickLabels, props), gridStyle: victory_core__WEBPACK_IMPORTED_MODULE_3__.evaluateStyle(style.grid, props) }; }; const getAxisLabelProps = (props, calculatedValues, globalTransform) => { const { style, orientation, padding, labelPadding, isVertical } = calculatedValues; const sign = orientationSign[orientation]; const hPadding = padding.left + padding.right; const vPadding = padding.top + padding.bottom; const verticalAnchor = sign < 0 ? "end" : "start"; const labelStyle = style.axisLabel; const angle = isVertical ? -90 : 0; // eslint-disable-line no-magic-numbers const x = isVertical ? globalTransform.x + sign * labelPadding : (props.width - hPadding) / 2 + padding.left + globalTransform.x; const y = isVertical ? (props.height - vPadding) / 2 + padding.top + globalTransform.y : sign * labelPadding + globalTransform.y; return { x, y, verticalAnchor: labelStyle.verticalAnchor || verticalAnchor, textAnchor: labelStyle.textAnchor || "middle", angle: labelStyle.angle === undefined ? angle : labelStyle.angle, style: labelStyle, text: props.label }; }; const getAnchors = (orientation, isVertical) => { const anchorOrientation = { top: "end", left: "end", right: "start", bottom: "start" }; const anchor = anchorOrientation[orientation]; return { textAnchor: isVertical ? anchor : "middle", verticalAnchor: isVertical ? "middle" : anchor }; }; const getLabelPadding = (props, style) => { const labelStyle = style.axisLabel || {}; if (labelStyle.padding !== undefined && labelStyle.padding !== null) { return labelStyle.padding; } const isVertical = victory_core__WEBPACK_IMPORTED_MODULE_1__.isVertical(props); // TODO: magic numbers /* eslint-disable no-magic-numbers*/ const fontSize = labelStyle.fontSize || 14; return props.label ? fontSize * (isVertical ? 2.3 : 1.6) : 0; /* eslint-enable no-magic-numbers*/ }; const getDefaultOrientations = (axis, originSign, horizontal) => { const sign = originSign || "positive"; const orientations = { positive: { x: "bottom", y: "left" }, negative: { x: "top", y: "right" } }; const horizontalOrientations = { positive: { x: "left", y: "bottom" }, negative: { x: "right", y: "top" } }; return horizontal ? horizontalOrientations[sign][axis] : orientations[sign][axis]; }; const getStandaloneOffset = (props, calculatedValues) => { const { style, scale, orientation, padding, axis, ticks, stringTicks, isVertical, labelPadding } = calculatedValues; const { polar, horizontal } = props; const sharedProps = { scale: { [axis]: scale }, polar, horizontal, ticks, stringTicks }; const xPadding = orientation === "right" ? padding.right : padding.left; const yPadding = orientation === "top" ? padding.top : padding.bottom; const offsetX = props.offsetX !== null && props.offsetX !== undefined ? props.offsetX : xPadding; const offsetY = props.offsetY !== null && props.offsetY !== undefined ? props.offsetY : yPadding; const fontSize = style.axisLabel.fontSize || 14; // eslint-disable-line no-magic-numbers const tickSizes = ticks.map((data, index) => { const tick = stringTicks ? props.tickValues[data - 1] : data; const tickStyle = victory_core__WEBPACK_IMPORTED_MODULE_3__.evaluateStyle(style.ticks, Object.assign({}, sharedProps, { tick, index })); return tickStyle.size || 0; }); const totalPadding = fontSize + 2 * Math.max(...tickSizes) + labelPadding; const minimumPadding = 1.2 * fontSize; // eslint-disable-line no-magic-numbers const x = isVertical ? totalPadding : minimumPadding; const y = isVertical ? minimumPadding : totalPadding; return { x: offsetX !== null && offsetX !== undefined ? offsetX : x, y: offsetY !== null && offsetY !== undefined ? offsetY : y }; }; const isEqual = (a, b) => { if (a instanceof Date && b instanceof Date) { return a.getTime() === b.getTime(); } return a === b; }; const getOffset = (props, calculatedValues) => { const { scale, origin, orientation, orientations, domain, padding } = calculatedValues; const { top, bottom, left, right } = padding; const calculatedOrientation = { x: orientation === "bottom" || orientation === "top" ? orientation : orientations.x, y: orientation === "left" || orientation === "right" ? orientation : orientations.y }; // make the axes line up, and cross when appropriate const orientationOffset = { x: calculatedOrientation.y === "left" ? left : right, y: calculatedOrientation.x === "bottom" ? bottom : top }; const originOffset = { x: calculatedOrientation.y === "left" ? 0 : props.width, y: calculatedOrientation.x === "bottom" ? props.height : 0 }; const originPosition = { x: isEqual(origin.x, domain.x[0]) || isEqual(origin.x, domain.x[1]) ? 0 : scale.x(origin.x), y: isEqual(origin.y, domain.y[0]) || isEqual(origin.y, domain.y[1]) ? 0 : scale.y(origin.y) }; const x = originPosition.x ? Math.abs(originOffset.x - originPosition.x) : orientationOffset.x; const y = originPosition.y ? Math.abs(originOffset.y - originPosition.y) : orientationOffset.y; const offsetX = exists(props.offsetX) ? props.offsetX : x; const offsetY = exists(props.offsetY) ? props.offsetY : y; return { x: offsetX, y: offsetY }; }; const getHorizontalOffset = (props, calculatedValues) => { const { scale, origin, orientation, orientations, domain, padding } = calculatedValues; const { top, bottom, left, right } = padding; const calculatedOrientation = { y: orientation === "bottom" || orientation === "top" ? orientation : orientations.x, x: orientation === "left" || orientation === "right" ? orientation : orientations.y }; // make the axes line up, and cross when appropriate const orientationOffset = { x: calculatedOrientation.y === "bottom" ? bottom : top, y: calculatedOrientation.x === "left" ? left : right }; const originOffset = { y: calculatedOrientation.x === "left" ? 0 : props.width, x: calculatedOrientation.y === "bottom" ? props.height : 0 }; const originPosition = { x: isEqual(origin.x, domain.x[0]) || isEqual(origin.x, domain.x[1]) ? 0 : scale.x(origin.x), y: isEqual(origin.y, domain.y[0]) || isEqual(origin.y, domain.y[1]) ? 0 : scale.y(origin.y) }; const y = originPosition.x ? Math.abs(originOffset.x - originPosition.x) : orientationOffset.x; const x = originPosition.y ? Math.abs(originOffset.y - originPosition.y) : orientationOffset.y; const offsetX = exists(props.offsetX) ? props.offsetX : x; const offsetY = exists(props.offsetY) ? props.offsetY : y; return { x: offsetX, y: offsetY }; }; const getTransform = (props, calculatedValues, offset) => { const { orientation, axis } = calculatedValues; const axisValue = victory_core__WEBPACK_IMPORTED_MODULE_1__.getAxisValue(props, axis); return { top: { x: 0, y: axisValue !== undefined ? axisValue : offset.y }, bottom: { x: 0, y: axisValue !== undefined ? axisValue : props.height - offset.y }, left: { x: axisValue !== undefined ? axisValue : offset.x, y: 0 }, right: { x: axisValue !== undefined ? axisValue : props.width - offset.x, y: 0 } }[orientation]; }; const getTickPosition = (style, orientation, isVertical) => { const { tickStyle, labelStyle } = style; const size = tickStyle.size || 0; const tickPadding = tickStyle.padding || 0; const labelPadding = labelStyle.padding || 0; const tickSpacing = size + tickPadding + labelPadding; const sign = orientationSign[orientation]; return { x: isVertical ? sign * tickSpacing : 0, x2: isVertical ? sign * size : 0, y: isVertical ? 0 : sign * tickSpacing, y2: isVertical ? 0 : sign * size }; }; const getTickTransform = (tick, globalTransform, isVertical) => { return { x: isVertical ? globalTransform.x : tick + globalTransform.x, y: isVertical ? tick + globalTransform.y : globalTransform.y }; }; const getGridEdge = (props, calculatedValues) => { const { orientation, padding, isVertical } = calculatedValues; const sign = -orientationSign[orientation]; const x = isVertical ? sign * (props.width - (padding.left + padding.right)) : 0; const y = isVertical ? 0 : sign * (props.height - (padding.top + padding.bottom)); return { x, y }; }; const getGridOffset = (calculatedValues, offset) => { const { padding, orientation, crossAxis } = calculatedValues; const xPadding = orientation === "right" ? padding.right : padding.left; const yPadding = orientation === "top" ? padding.top : padding.bottom; return { x: crossAxis ? offset.x - xPadding : 0, y: crossAxis ? offset.y - yPadding : 0 }; }; const getLayoutProps = (modifiedProps, calculatedValues) => { let offset; if (calculatedValues.domain.x && calculatedValues.domain.y) { offset = modifiedProps.horizontal ? getHorizontalOffset(modifiedProps, calculatedValues) : getOffset(modifiedProps, calculatedValues); } else { offset = getStandaloneOffset(modifiedProps, calculatedValues); } return { globalTransform: getTransform(modifiedProps, calculatedValues, offset), gridOffset: getGridOffset(calculatedValues, offset), gridEdge: getGridEdge(modifiedProps, calculatedValues) }; }; const getOrientation = props => { if (props.orientation) { return props.orientation; } const defaultOrientations = { dependent: props.horizontal ? "bottom" : "left", independent: props.horizontal ? "left" : "bottom" }; return props.dependentAxis ? defaultOrientations.dependent : defaultOrientations.independent; }; const getCalculatedValues = props => { const defaultStyles = getStyleObject(props); const style = getStyles(props, defaultStyles); const padding = victory_core__WEBPACK_IMPORTED_MODULE_3__.getPadding(props.padding); const labelPadding = getLabelPadding(props, style); const stringTicks = victory_core__WEBPACK_IMPORTED_MODULE_1__.stringTicks(props) ? props.tickValues : undefined; const axis = victory_core__WEBPACK_IMPORTED_MODULE_1__.getAxis(props); const axisDomain = victory_core__WEBPACK_IMPORTED_MODULE_1__.getDomain(props); const axisScale = getScale(props); const xAxisDomain = axis === "x" ? axisDomain : undefined; const yAxisDomain = axis === "y" ? axisDomain : undefined; const xAxisScale = axis === "x" ? axisScale : undefined; const yAxisScale = axis === "y" ? axisScale : undefined; const crossAxis = !(props.crossAxis === false || props.standalone === true); const ticks = victory_core__WEBPACK_IMPORTED_MODULE_1__.getTicks(props, axisScale, crossAxis); const tickFormat = victory_core__WEBPACK_IMPORTED_MODULE_1__.getTickFormat(props, axisScale); const range = { x: victory_core__WEBPACK_IMPORTED_MODULE_3__.getRange(props, "x"), y: victory_core__WEBPACK_IMPORTED_MODULE_3__.getRange(props, "y") }; // use full domain if passed in from parent, // otherwise use the just the one axis available const domain = { x: props.domain && props.domain.x ? props.domain.x : xAxisDomain, y: props.domain && props.domain.y ? props.domain.y : yAxisDomain }; // use full scale if passed in from parent, // otherwise use the just the one axis available const scale = { x: props.domain && props.domain.x ? victory_core__WEBPACK_IMPORTED_MODULE_2__.getBaseScale(props, "x").domain(props.domain.x).range(props.horizontal ? range.y : range.x) : xAxisScale, y: props.domain && props.domain.y ? victory_core__WEBPACK_IMPORTED_MODULE_2__.getBaseScale(props, "y").domain(props.domain.y).range(props.horizontal ? range.x : range.y) : yAxisScale }; const origin = domain.x && domain.y ? victory_core__WEBPACK_IMPORTED_MODULE_1__.getOrigin(domain) : undefined; const originSign = origin ? { x: victory_core__WEBPACK_IMPORTED_MODULE_1__.getOriginSign(origin.x, domain.x), y: victory_core__WEBPACK_IMPORTED_MODULE_1__.getOriginSign(origin.y, domain.y) } : undefined; const orientations = originSign ? { x: getDefaultOrientations("x", originSign.y, props.horizontal), y: getDefaultOrientations("y", originSign.x, props.horizontal) } : undefined; const orientation = orientations ? props.orientation || orientations[axis] : getOrientation(props); const isVertical = victory_core__WEBPACK_IMPORTED_MODULE_1__.isVertical(Object.assign({}, props, { orientation })); const anchors = getAnchors(orientation, isVertical); return { anchors, axis, crossAxis, domain, isVertical, labelPadding, orientation, orientations, origin, padding, scale, stringTicks, style, tickFormat, ticks }; }; const getBaseProps = (initialProps, fallbackProps) => { const props = victory_core__WEBPACK_IMPORTED_MODULE_1__.modifyProps(initialProps, fallbackProps); const calculatedValues = getCalculatedValues(props); const { axis, style, orientation, isVertical, scale, ticks, tickFormat, anchors, domain, stringTicks } = calculatedValues; const otherAxis = axis === "x" ? "y" : "x"; const { width, height, standalone, theme, polar, padding, horizontal } = props; const { globalTransform, gridOffset, gridEdge } = getLayoutProps(props, calculatedValues); const sharedProps = { scale: { [axis]: scale[axis] }, polar, horizontal, ticks, stringTicks }; const axisProps = getAxisProps(props, calculatedValues, globalTransform); const axisLabelProps = getAxisLabelProps(props, calculatedValues, globalTransform); const initialChildProps = { parent: Object.assign({ style: style.parent, ticks, standalone, theme, width, height, padding, domain }, sharedProps) }; const gridProps = { dimension: otherAxis, range: { [otherAxis]: victory_core__WEBPACK_IMPORTED_MODULE_3__.getRange(props, otherAxis) }, scale: props.scale && props.scale[otherAxis] ? { [otherAxis]: props.scale[otherAxis] } : undefined }; return ticks.reduce((childProps, tickValue, index) => { const tick = stringTicks ? stringTicks[index] : tickValue; const text = tickFormat(tickValue, index, ticks); const styles = getEvaluatedStyles(style, Object.assign({}, sharedProps, { tick, tickValue, index, text })); const tickLayout = { position: getTickPosition(styles, orientation, isVertical), transform: getTickTransform(scale[axis]?.(tickValue), globalTransform, isVertical) }; const gridLayout = { edge: gridEdge, transform: { x: isVertical ? -gridOffset.x + globalTransform.x : scale[axis]?.(tickValue) + globalTransform.x, y: isVertical ? scale[axis]?.(tickValue) + globalTransform.y : gridOffset.y + globalTransform.y } }; childProps[index] = { axis: Object.assign({ dimension: axis }, sharedProps, axisProps), axisLabel: Object.assign({}, sharedProps, axisLabelProps), ticks: Object.assign({}, sharedProps, getTickProps(tickLayout, styles.tickStyle, tickValue)), tickLabels: Object.assign({}, sharedProps, getTickLabelProps(tickLayout, styles.labelStyle, anchors, tickValue, text)), grid: Object.assign({}, sharedProps, gridProps, getGridProps(gridLayout, styles.gridStyle, tickValue)) }; return childProps; }, initialChildProps); }; /***/ }), /***/ "./victory-axis.tsx": /*!**************************!*\ !*** ./victory-axis.tsx ***! \**************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "VictoryAxis": function() { return /* binding */ VictoryAxis; } /* harmony export */ }); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var lodash_isEmpty__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash/isEmpty */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isEmpty.js"); /* harmony import */ var lodash_isEmpty__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_isEmpty__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-primitives/line-segment.js"); /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-label/victory-label.js"); /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-theme/victory-theme.js"); /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-container/victory-container.js"); /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/axis.js"); /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/textsize.js"); /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/user-props.js"); /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/add-events.js"); /* harmony import */ var _helper_methods__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./helper-methods */ "./helper-methods.tsx"); const fallbackProps = { width: 450, height: 300, padding: 50 }; const options = { components: [{ name: "axis", index: 0 }, { name: "axisLabel", index: 0 }, { name: "grid" }, { name: "parent", index: "parent" }, { name: "ticks" }, { name: "tickLabels" }] }; // eslint-disable-next-line @typescript-eslint/no-empty-object-type class VictoryAxisBase extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component) { static animationWhitelist = ["style", "domain", "range", "tickCount", "tickValues", "offsetX", "offsetY", "padding", "width", "height"]; static displayName = "VictoryAxis"; static role = "axis"; static defaultTransitions = { onExit: { duration: 500 }, onEnter: { duration: 500 } }; static defaultProps = { axisComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_2__.LineSegment, null), axisLabelComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_3__.VictoryLabel, null), tickLabelComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_3__.VictoryLabel, null), tickComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_2__.LineSegment, null), gridComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_2__.LineSegment, null), standalone: true, theme: victory_core__WEBPACK_IMPORTED_MODULE_4__.VictoryTheme.grayscale, containerComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_5__.VictoryContainer, null), groupComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("g", { role: "presentation" }), fixLabelOverlap: false }; static getDomain = victory_core__WEBPACK_IMPORTED_MODULE_6__.getDomain; static getAxis = victory_core__WEBPACK_IMPORTED_MODULE_6__.getAxis; static getStyles(props) { return (0,_helper_methods__WEBPACK_IMPORTED_MODULE_7__.getStyles)(props); } static getBaseProps(props) { return (0,_helper_methods__WEBPACK_IMPORTED_MODULE_7__.getBaseProps)(props, fallbackProps); } static expectedComponents = ["axisComponent", "axisLabelComponent", "groupComponent", "containerComponent", "tickComponent", "tickLabelComponent", "gridComponent"]; renderLine(props) { const { axisComponent } = props; const axisProps = this.getComponentProps(axisComponent, "axis", 0); return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(axisComponent, axisProps); } renderLabel(props) { const { axisLabelComponent, label } = props; if (!label) { return null; } const axisLabelProps = this.getComponentProps(axisLabelComponent, "axisLabel", 0); return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(axisLabelComponent, axisLabelProps); } renderGridAndTicks(props) { const { tickComponent, tickLabelComponent, gridComponent, name } = props; const shouldRender = componentProps => { const { style = {}, events = {} } = componentProps; const visible = style.stroke !== "transparent" && style.stroke !== "none" && style.strokeWidth !== 0; return visible || !lodash_isEmpty__WEBPACK_IMPORTED_MODULE_1___default()(events); }; return this.dataKeys.map((key, index) => { const tickProps = this.getComponentProps(tickComponent, "ticks", index); const BaseTickComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(tickComponent, tickProps); const TickComponent = shouldRender(BaseTickComponent.props) ? BaseTickComponent : undefined; const gridProps = this.getComponentProps(gridComponent, "grid", index); const BaseGridComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(gridComponent, gridProps); const GridComponent = shouldRender(BaseGridComponent.props) ? BaseGridComponent : undefined; const tickLabelProps = this.getComponentProps(tickLabelComponent, "tickLabels", index); const TickLabel = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(tickLabelComponent, tickLabelProps); const children = [GridComponent, TickComponent, TickLabel].filter(Boolean); return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(props.groupComponent, { key: `${name}-tick-group-${key}` }, children); }); } fixLabelOverlap(gridAndTicks, props) { const isVertical = victory_core__WEBPACK_IMPORTED_MODULE_6__.isVertical(props); const size = isVertical ? props.height : props.width; const isVictoryLabel = child => child.type && child.type.role === "label"; const labels = gridAndTicks.map(gridAndTick => gridAndTick.props.children).reduce((accumulator, childArr) => accumulator.concat(childArr), []).filter(isVictoryLabel).map(child => child.props); const paddingToObject = padding => typeof padding === "object" ? Object.assign({}, { top: 0, right: 0, bottom: 0, left: 0 }, padding) : { top: padding, right: padding, bottom: padding, left: padding }; const labelsSumSize = labels.reduce((sum, label) => { const padding = paddingToObject(label.style.padding); const labelSize = victory_core__WEBPACK_IMPORTED_MODULE_8__.approximateTextSize(label.text, { angle: label.angle, fontSize: label.style.fontSize, letterSpacing: label.style.letterSpacing, fontFamily: label.style.fontFamily }); return sum + (isVertical ? labelSize.height + padding.top + padding.bottom : labelSize.width + padding.right + padding.left); }, 0); const availiableLabelCount = Math.floor(size * gridAndTicks.length / labelsSumSize); const divider = Math.ceil(gridAndTicks.length / availiableLabelCount) || 1; const getLabelCoord = gridAndTick => gridAndTick.props.children.filter(isVictoryLabel).reduce((prev, child) => (isVertical ? child.props.y : child.props.x) || 0, 0); const sorted = gridAndTicks.sort((a, b) => isVertical ? getLabelCoord(b) - getLabelCoord(a) // ordinary axis has top-bottom orientation : getLabelCoord(a) - getLabelCoord(b) // ordinary axis has left-right orientation ); return sorted.filter((gridAndTick, index) => index % divider === 0); } // Overridden in native versions shouldAnimate() { return !!this.props.animate; } render() { const { animationWhitelist } = VictoryAxis; const props = victory_core__WEBPACK_IMPORTED_MODULE_6__.modifyProps(this.props, fallbackProps); const userProps = victory_core__WEBPACK_IMPORTED_MODULE_9__.getSafeUserProps(this.props); if (this.shouldAnimate()) { return this.animateComponent(props, animationWhitelist); } const gridAndTicks = this.renderGridAndTicks(props); const modifiedGridAndTicks = props.fixLabelOverlap ? this.fixLabelOverlap(gridAndTicks, props) : gridAndTicks; const children = [this.renderLine(props), this.renderLabel(props), ...modifiedGridAndTicks]; const container = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(props.containerComponent, userProps); return props.standalone ? this.renderContainer(container, children) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(props.groupComponent, userProps, children); } } const VictoryAxis = (0,victory_core__WEBPACK_IMPORTED_MODULE_10__.addEvents)(VictoryAxisBase, options); /***/ }), /***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_MapCache.js": /*!***********************************************************************************!*\ !*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_MapCache.js ***! \***********************************************************************************/ /***/ (function(module, __unused_webpack_exports, __webpack_require__) { var listCacheClear = __webpack_require__(/*! ./_listCacheClear */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheClear.js"), listCacheDelete = __webpack_require__(/*! ./_listCacheDelete */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheDelete.js"), listCacheGet = __webpack_require__(/*! ./_listCacheGet */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheGet.js"), listCacheHas = __webpack_require__(/*! ./_listCacheHas */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheHas.js"), listCacheSet = __webpack_require__(/*! ./_listCacheSet */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheSet.js"); /** * Creates an list cache object. * * @private * @constructor * @param {Array} [entries] The key-value pairs to cache. */ function ListCache(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } // Add methods to `ListCache`. ListCache.prototype.clear = listCacheClear; ListCache.prototype['delete'] = listCacheDelete; ListCache.prototype.get = listCacheGet; ListCache.prototype.has = listCacheHas; ListCache.prototype.set = listCacheSet; module.exports = ListCache; /***/ }), /***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_SetCache.js": /*!***********************************************************************************!*\ !*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_SetCache.js ***! \***********************************************************************************/ /***/ (function(module, __unused_webpack_exports, __webpack_require__) { var isArray = __webpack_require__(/*! ./isArray */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isArray.js"); /** * Casts `value` as an array if it's not one. * * @static * @memberOf _ * @since 4.4.0 * @category Lang * @param {*} value The value to inspect. * @returns {Array} Returns the cast array. * @example * * _.castArray(1); * // => [1] * * _.castArray({ 'a': 1 }); * // => [{ 'a': 1 }] * * _.castArray('abc'); * // => ['abc'] * * _.castArray(null); * // => [null] * * _.castArray(undefined); * // => [undefined] * * _.castArray(); * // => [] * * var array = [1, 2, 3]; * console.log(_.castArray(array) === array); * // => true */ function castArray() { if (!arguments.length) { return []; } var value = arguments[0]; return isArray(value) ? value : [value]; } module.exports = castArray; /***/ }), /***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Stack.js": /*!********************************************************************************!*\ !*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Stack.js ***! \********************************************************************************/ /***/ (function(module, __unused_webpack_exports, __webpack_require__) { var listCacheClear = __webpack_require__(/*! ./_listCacheClear */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheClear.js"), listCacheDelete = __webpack_require__(/*! ./_listCacheDelete */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheDelete.js"), listCacheGet = __webpack_require__(/*! ./_listCacheGet */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheGet.js"), listCacheHas = __webpack_require__(/*! ./_listCacheHas */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheHas.js"), listCacheSet = __webpack_require__(/*! ./_listCacheSet */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheSet.js"); /** * Creates an list cache object. * * @private * @constructor * @param {Array} [entries] The key-value pairs to cache. */ function ListCache(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } // Add methods to `ListCache`. ListCache.prototype.clear = listCacheClear; ListCache.prototype['delete'] = listCacheDelete; ListCache.prototype.get = listCacheGet; ListCache.prototype.has = listCacheHas; ListCache.prototype.set = listCacheSet; module.exports = ListCache; /***/ }), /***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Symbol.js": /*!*********************************************************************************!*\ !*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Symbol.js ***! \*********************************************************************************/ /***/ (function(module, __unused_webpack_exports, __webpack_require__) { var root = __webpack_require__(/*! ./_root */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_root.js"); /** Built-in value references. */ var Symbol = root.Symbol; module.exports = Symbol; /***/ }), /***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_apply.js": /*!********************************************************************************!*\ !*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_apply.js ***! \********************************************************************************/ /***/ (function(module) { /** * A faster alternative to `Function#apply`, this function invokes `func` * with the `this` binding of `thisArg` and the arguments of `args`. * * @private * @param {Function} func The function to invoke. * @param {*} thisArg The `this` binding of `func`. * @param {Array} args The arguments to invoke `func` with. * @returns {*} Returns the result of `func`. */ function apply(func, thisArg, args) { switch (args.length) { case 0: return func.call(thisArg); case 1: return func.call(thisArg, args[0]); case 2: return func.call(thisArg, args[0], args[1]); case 3: return func.call(thisArg, args[0], args[1], args[2]); } return func.apply(thisArg, args); } module.exports = apply; /***/ }), /***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayIncludes.js": /*!****************************************************************************************!*\ !*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayIncludes.js ***! \****************************************************************************************/ /***/ (function(module, __unused_webpack_exports, __webpack_require__) { var baseIndexOf = __webpack_require__(/*! ./_baseIndexOf */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseIndexOf.js"); /** * A specialized version of `_.includes` for arrays without support for * specifying an index to search from. * * @private * @param {Array} [array] The array to inspect. * @param {*} target The value to search for. * @returns {boolean} Returns `true` if `target` is found, else `false`. */ function arrayIncludes(array, value) { var length = array == null ? 0 : array.length; return !!length && baseIndexOf(array, value, 0) > -1; } module.exports = arrayIncludes; /***/ }), /***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayIncludesWith.js": /*!********************************************************************************************!*\ !*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayIncludesWith.js ***! \********************************************************************************************/ /***/ (function(module) { /** * This function is like `arrayIncludes` except that it accepts a comparator. * * @private * @param {Array} [array] The array to inspect. * @param {*} target The value to search for. * @param {Function} comparator The comparator invoked per element. * @returns {boolean} Returns `true` if `target` is found, else `false`. */ function arrayIncludesWith(array, value, comparator) { var index = -1, length = array == null ? 0 : array.length; while (++index < length) { if (comparator(value, array[index])) { return true; } } return false; } module.exports = arrayIncludesWith; /***/ }), /***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayMap.js": /*!***********************************************************************************!*\ !*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayMap.js ***! \***********************************************************************************/ /***/ (function(module) { /** * A specialized version of `_.map` for arrays without support for iteratee * shorthands. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Array} Returns the new mapped array. */ function arrayMap(array, iteratee) { var index = -1, length = array == null ? 0 : array.length, result = Array(length); while (++index < length) { result[index] = iteratee(array[index], index, array); } return result; } module.exports = arrayMap; /***/ }), /***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayPush.js": /*!************************************************************************************!*\ !*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayPush.js ***! \************************************************************************************/ /***/ (function(module) { /** * Appends the elements of `values` to `array`. * * @private * @param {Array} array The array to modify. * @param {Array} values The values to append. * @returns {Array} Returns `array`. */ function arrayPush(array, values) { var index = -1, length = values.length, offset = array.length; while (++index < length) { array[offset + index] = values[index]; } return array; } module.exports = arrayPush; /***/ }), /***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arraySome.js": /*!************************************************************************************!*\ !*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arraySome.js ***! \************************************************************************************/ /***/ (function(module) { /** * A specialized version of `_.some` for arrays without support for iteratee * shorthands. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} predicate The function invoked per iteration. * @returns {boolean} Returns `true` if any element passes the predicate check, * else `false`. */ function arraySome(array, predicate) { var index = -1, length = array == null ? 0 : array.length; while (++index < length) { if (predicate(array[index], index, array)) { return true; } } return false; } module.exports = arraySome; /***/ }), /***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_assignValue.js": /*!**************************************************************************************!*\ !*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_assignValue.js ***! \**************************************************************************************/ /***/ (function(module, __unused_webpack_exports, __webpack_require__) { var baseAssignValue = __webpack_require__(/*! ./_baseAssignValue */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseAssignValue.js"), eq = __webpack_require__(/*! ./eq */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/eq.js"); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Assigns `value` to `key` of `object` if the existing value is not equivalent * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. * * @private * @param {Object} object The object to modify. * @param {string} key The key of the property to assign. * @param {*} value The value to assign. */ function assignValue(object, key, value) { var objValue = object[key]; if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || (value === undefined && !(key in object))) { baseAssignValue(object, key, value); } } module.exports = assignValue; /***/ }), /***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_assocIndexOf.js": /*!***************************************************************************************!*\ !*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_assocIndexOf.js ***! \***************************************************************************************/ /***/ (function(module, __unused_webpack_exports, __webpack_require__) { var eq = __webpack_require__(/*! ./eq */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/eq.js"); /** * Gets the index at which the `key` is found in `array` of key-value pairs. * * @private * @param {Array} array The array to inspect. * @param {*} key The key to search for. * @returns {number} Returns the index of the matched value, else `-1`. */ function assocIndexOf(array, key) { var length = array.length; while (length--) { if (eq(array[length][0], key)) { return length; } } return -1; } module.exports = assocIndexOf; /***/ }), /***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseAssignValue.js": /*!******************************************************************************************!*\ !*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseAssignValue.js ***! \******************************************************************************************/ /***/ (function(module, __unused_webpack_exports, __webpack_require__) { var defineProperty = __webpack_require__(/*! ./_defineProperty */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_defineProperty.js"); /** * The base implementation of `assignValue` and `assignMergeValue` without * value checks. * * @private * @param {Object} object The object to modify. * @param {string} key The key of the property to assign. * @param {*} value The value to assign. */ function baseAssignValue(object, key, value) { if (key == '__proto__' && defineProperty) { defineProperty(object, key, { 'configurable': true, 'enumerable': true, 'value': value, 'writable': true }); } else { object[key] = value; } } module.exports = baseAssignValue; /***/ }), /***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseFlatten.js": /*!**************************************************************************************!*\ !*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseFlatten.js ***! \**************************************************************************************/ /***/ (function(module, __unused_webpack_exports, __webpack_require__) { var arrayPush = __webpack_require__(/*! ./_arrayPush */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayPush.js"), isFlattenable = __webpack_require__(/*! ./_isFlattenable */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_isFlattenable.js"); /** * The base implementation of `_.flatten` with support for restricting flattening. * * @private * @param {Array} array The array to flatten. * @param {number} depth The maximum recursion depth. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. * @param {Array} [result=[]] The initial result value. * @returns {Array} Returns the new flattened array. */ function baseFlatten(array, depth, predicate, isStrict, result) { var index = -1, length = array.length; predicate || (predicate = isFlattenable); result || (result = []); while (++index < length) { var value = array[index]; if (depth > 0 && predicate(value)) { if (depth > 1) { // Recursively flatten arrays (susceptible to call stack limits). baseFlatten(value, depth - 1, predicate, isStrict, result); } else { arrayPush(result, value); } } else if (!isStrict) { result[result.length] = value; } } return result; } module.exports = baseFlatten; /***/ }), /***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseGet.js": /*!**********************************************************************************!*\ !*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseGet.js ***! \**********************************************************************************/ /***/ (function(module, __unused_webpack_exports, __webpack_require__) { var castPath = __webpack_