UNPKG

victory-chart

Version:
53 lines (50 loc) 2.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _victoryCore = require("victory-core"); exports.default = { getAxisType: function getAxisType(component) { if (!component.type || component.type.role !== "axis") { return undefined; } return component.props.dependentAxis ? "dependent" : "independent"; }, getAxisComponent: function getAxisComponent(childComponents, axis) { var getAxis = function getAxis(component) { var flipped = childComponents.some(function (child) { return child.props.horizontal; }); return component.type.getAxis(component.props, flipped); }; var axisComponents = childComponents.filter(function (component) { return component.type.role === "axis" && getAxis(component) === axis; }); return axisComponents[0]; }, getOrientation: function getOrientation(component, axis) { var typicalOrientations = { x: "bottom", y: "left" }; var flippedOrientations = { x: "left", y: "bottom" }; if (!component) { return typicalOrientations[axis]; } else if (component.props && component.props.orientation) { return component.props.orientation; } var dependent = component.props.dependentAxis; return dependent && axis === "y" || !dependent && axis === "x" ? typicalOrientations[axis] : flippedOrientations[axis]; }, getAxisOrientations: function getAxisOrientations(childComponents) { return { x: this.getOrientation(this.getAxisComponent(childComponents, "x"), "x"), y: this.getOrientation(this.getAxisComponent(childComponents, "y"), "y") }; }, isVertical: function isVertical(props) { var orientation = props.orientation || (props.dependentAxis ? "left" : "bottom"); var vertical = { top: false, bottom: false, left: true, right: true }; return vertical[orientation]; }, stringTicks: function stringTicks(props) { return props.tickValues !== undefined && _victoryCore.Collection.containsStrings(props.tickValues); } };