Socket
Socket
Sign inDemoInstall

recharts

Package Overview
Dependencies
Maintainers
3
Versions
241
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

recharts - npm Package Compare versions

Comparing version 2.4.3 to 2.5.0

es6/cartesian/getTicks.js

2

CHANGELOG.md

@@ -0,1 +1,3 @@

## ⚠️ Next versions change notes are available only on the [GitHub Releases](https://github.com/recharts/recharts/releases) page ⚠️
## 2.2.0 (Dec 8, 2022)

@@ -2,0 +4,0 @@ ### feat

213

es6/cartesian/CartesianAxis.js

@@ -0,3 +1,3 @@

import _isFunction from "lodash/isFunction";
import _get from "lodash/get";
import _isFunction from "lodash/isFunction";
var _excluded = ["viewBox"],

@@ -31,10 +31,9 @@ _excluded2 = ["viewBox"],

import { shallowEqual } from '../util/ShallowEqual';
import { getStringSize } from '../util/DOMUtils';
import { Layer } from '../container/Layer';
import { Text } from '../component/Text';
import { Label } from '../component/Label';
import { Global } from '../util/Global';
import { isNumber, mathSign } from '../util/DataUtils';
import { isNumber } from '../util/DataUtils';
import { adaptEventsOfChild } from '../util/types';
import { filterProps } from '../util/ReactUtils';
import { getTicks } from './getTicks';
export var CartesianAxis = /*#__PURE__*/function (_Component) {

@@ -53,4 +52,2 @@ _inherits(CartesianAxis, _Component);

}
// todo Array<Tick>
_createClass(CartesianAxis, [{

@@ -241,3 +238,3 @@ key: "shouldComponentUpdate",

unit = _this$props6.unit;
var finalTicks = CartesianAxis.getTicks(_objectSpread(_objectSpread({}, this.props), {}, {
var finalTicks = getTicks(_objectSpread(_objectSpread({}, this.props), {}, {
ticks: ticks

@@ -311,204 +308,2 @@ }), fontSize, letterSpacing);

}], [{
key: "getTicks",
value: function getTicks(props, fontSize, letterSpacing) {
var tick = props.tick,
ticks = props.ticks,
viewBox = props.viewBox,
minTickGap = props.minTickGap,
orientation = props.orientation,
interval = props.interval,
tickFormatter = props.tickFormatter,
unit = props.unit;
if (!ticks || !ticks.length || !tick) {
return [];
}
if (isNumber(interval) || Global.isSsr) {
return CartesianAxis.getNumberIntervalTicks(ticks, typeof interval === 'number' && isNumber(interval) ? interval : 0);
}
if (interval === 'preserveStartEnd') {
return CartesianAxis.getTicksStart({
ticks: ticks,
tickFormatter: tickFormatter,
viewBox: viewBox,
orientation: orientation,
minTickGap: minTickGap,
unit: unit,
fontSize: fontSize,
letterSpacing: letterSpacing
}, true);
}
if (interval === 'preserveStart') {
return CartesianAxis.getTicksStart({
ticks: ticks,
tickFormatter: tickFormatter,
viewBox: viewBox,
orientation: orientation,
minTickGap: minTickGap,
unit: unit,
fontSize: fontSize,
letterSpacing: letterSpacing
});
}
return CartesianAxis.getTicksEnd({
ticks: ticks,
tickFormatter: tickFormatter,
viewBox: viewBox,
orientation: orientation,
minTickGap: minTickGap,
unit: unit,
fontSize: fontSize,
letterSpacing: letterSpacing
});
}
}, {
key: "getNumberIntervalTicks",
value: function getNumberIntervalTicks(ticks, interval) {
return ticks.filter(function (entry, i) {
return i % (interval + 1) === 0;
});
}
}, {
key: "getTicksStart",
value: function getTicksStart(_ref3, preserveEnd) {
var ticks = _ref3.ticks,
tickFormatter = _ref3.tickFormatter,
viewBox = _ref3.viewBox,
orientation = _ref3.orientation,
minTickGap = _ref3.minTickGap,
unit = _ref3.unit,
fontSize = _ref3.fontSize,
letterSpacing = _ref3.letterSpacing;
var x = viewBox.x,
y = viewBox.y,
width = viewBox.width,
height = viewBox.height;
var sizeKey = orientation === 'top' || orientation === 'bottom' ? 'width' : 'height';
var result = (ticks || []).slice();
// we need add the width of 'unit' only when sizeKey === 'width'
var unitSize = unit && sizeKey === 'width' ? getStringSize(unit, {
fontSize: fontSize,
letterSpacing: letterSpacing
})[sizeKey] : 0;
var len = result.length;
var sign = len >= 2 ? mathSign(result[1].coordinate - result[0].coordinate) : 1;
var start, end;
if (sign === 1) {
start = sizeKey === 'width' ? x : y;
end = sizeKey === 'width' ? x + width : y + height;
} else {
start = sizeKey === 'width' ? x + width : y + height;
end = sizeKey === 'width' ? x : y;
}
if (preserveEnd) {
// Try to guarantee the tail to be displayed
var tail = ticks[len - 1];
var tailContent = _isFunction(tickFormatter) ? tickFormatter(tail.value, len - 1) : tail.value;
var tailSize = getStringSize(tailContent, {
fontSize: fontSize,
letterSpacing: letterSpacing
})[sizeKey] + unitSize;
var tailGap = sign * (tail.coordinate + sign * tailSize / 2 - end);
result[len - 1] = tail = _objectSpread(_objectSpread({}, tail), {}, {
tickCoord: tailGap > 0 ? tail.coordinate - tailGap * sign : tail.coordinate
});
var isTailShow = sign * (tail.tickCoord - sign * tailSize / 2 - start) >= 0 && sign * (tail.tickCoord + sign * tailSize / 2 - end) <= 0;
if (isTailShow) {
end = tail.tickCoord - sign * (tailSize / 2 + minTickGap);
result[len - 1] = _objectSpread(_objectSpread({}, tail), {}, {
isShow: true
});
}
}
var count = preserveEnd ? len - 1 : len;
for (var i = 0; i < count; i++) {
var entry = result[i];
var content = _isFunction(tickFormatter) ? tickFormatter(entry.value, i) : entry.value;
var size = getStringSize(content, {
fontSize: fontSize,
letterSpacing: letterSpacing
})[sizeKey] + unitSize;
if (i === 0) {
var gap = sign * (entry.coordinate - sign * size / 2 - start);
result[i] = entry = _objectSpread(_objectSpread({}, entry), {}, {
tickCoord: gap < 0 ? entry.coordinate - gap * sign : entry.coordinate
});
} else {
result[i] = entry = _objectSpread(_objectSpread({}, entry), {}, {
tickCoord: entry.coordinate
});
}
var isShow = sign * (entry.tickCoord - sign * size / 2 - start) >= 0 && sign * (entry.tickCoord + sign * size / 2 - end) <= 0;
if (isShow) {
start = entry.tickCoord + sign * (size / 2 + minTickGap);
result[i] = _objectSpread(_objectSpread({}, entry), {}, {
isShow: true
});
}
}
return result.filter(function (entry) {
return entry.isShow;
});
}
}, {
key: "getTicksEnd",
value: function getTicksEnd(_ref4) {
var ticks = _ref4.ticks,
tickFormatter = _ref4.tickFormatter,
viewBox = _ref4.viewBox,
orientation = _ref4.orientation,
minTickGap = _ref4.minTickGap,
unit = _ref4.unit,
fontSize = _ref4.fontSize,
letterSpacing = _ref4.letterSpacing;
var x = viewBox.x,
y = viewBox.y,
width = viewBox.width,
height = viewBox.height;
var sizeKey = orientation === 'top' || orientation === 'bottom' ? 'width' : 'height';
// we need add the width of 'unit' only when sizeKey === 'width'
var unitSize = unit && sizeKey === 'width' ? getStringSize(unit, {
fontSize: fontSize,
letterSpacing: letterSpacing
})[sizeKey] : 0;
var result = (ticks || []).slice();
var len = result.length;
var sign = len >= 2 ? mathSign(result[1].coordinate - result[0].coordinate) : 1;
var start, end;
if (sign === 1) {
start = sizeKey === 'width' ? x : y;
end = sizeKey === 'width' ? x + width : y + height;
} else {
start = sizeKey === 'width' ? x + width : y + height;
end = sizeKey === 'width' ? x : y;
}
for (var i = len - 1; i >= 0; i--) {
var entry = result[i];
var content = _isFunction(tickFormatter) ? tickFormatter(entry.value, len - i - 1) : entry.value;
var size = getStringSize(content, {
fontSize: fontSize,
letterSpacing: letterSpacing
})[sizeKey] + unitSize;
if (i === len - 1) {
var gap = sign * (entry.coordinate + sign * size / 2 - end);
result[i] = entry = _objectSpread(_objectSpread({}, entry), {}, {
tickCoord: gap > 0 ? entry.coordinate - gap * sign : entry.coordinate
});
} else {
result[i] = entry = _objectSpread(_objectSpread({}, entry), {}, {
tickCoord: entry.coordinate
});
}
var isShow = sign * (entry.tickCoord - sign * size / 2 - start) >= 0 && sign * (entry.tickCoord + sign * size / 2 - end) <= 0;
if (isShow) {
end = entry.tickCoord - sign * (size / 2 + minTickGap);
result[i] = _objectSpread(_objectSpread({}, entry), {}, {
isShow: true
});
}
}
return result.filter(function (entry) {
return entry.isShow;
});
}
}, {
key: "renderTickItem",

@@ -515,0 +310,0 @@ value: function renderTickItem(option, props, value) {

@@ -0,4 +1,3 @@

import _isFunction from "lodash/isFunction";
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
import _isFunction from "lodash/isFunction";
var _excluded = ["isFront", "ifOverflow", "xAxisId", "yAxisId", "r", "fill", "fillOpacity", "stroke", "strokeWidth"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

@@ -10,4 +9,2 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
/**

@@ -59,34 +56,3 @@ * @fileOverview Reference Line

};
export function ReferenceArea(_ref) {
var _ref$isFront = _ref.isFront,
isFront = _ref$isFront === void 0 ? false : _ref$isFront,
_ref$ifOverflow = _ref.ifOverflow,
ifOverflow = _ref$ifOverflow === void 0 ? 'discard' : _ref$ifOverflow,
_ref$xAxisId = _ref.xAxisId,
xAxisId = _ref$xAxisId === void 0 ? 0 : _ref$xAxisId,
_ref$yAxisId = _ref.yAxisId,
yAxisId = _ref$yAxisId === void 0 ? 0 : _ref$yAxisId,
_ref$r = _ref.r,
r = _ref$r === void 0 ? 10 : _ref$r,
_ref$fill = _ref.fill,
fill = _ref$fill === void 0 ? '#ccc' : _ref$fill,
_ref$fillOpacity = _ref.fillOpacity,
fillOpacity = _ref$fillOpacity === void 0 ? 0.5 : _ref$fillOpacity,
_ref$stroke = _ref.stroke,
stroke = _ref$stroke === void 0 ? 'none' : _ref$stroke,
_ref$strokeWidth = _ref.strokeWidth,
strokeWidth = _ref$strokeWidth === void 0 ? 1 : _ref$strokeWidth,
restProps = _objectWithoutProperties(_ref, _excluded);
// Props with default values added.
var props = _objectSpread({
isFront: isFront,
ifOverflow: ifOverflow,
xAxisId: xAxisId,
yAxisId: yAxisId,
r: r,
fill: fill,
fillOpacity: fillOpacity,
stroke: stroke,
strokeWidth: strokeWidth
}, restProps);
export function ReferenceArea(props) {
var x1 = props.x1,

@@ -120,2 +86,13 @@ x2 = props.x2,

ReferenceArea.displayName = 'ReferenceArea';
ReferenceArea.defaultProps = {
isFront: false,
ifOverflow: 'discard',
xAxisId: 0,
yAxisId: 0,
r: 10,
fill: '#ccc',
fillOpacity: 0.5,
stroke: 'none',
strokeWidth: 1
};
ReferenceArea.renderRect = function (option, props) {

@@ -122,0 +99,0 @@ var rect;

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
import _some from "lodash/some";
import _isFunction from "lodash/isFunction";
var _excluded = ["isFront", "ifOverflow", "xAxisId", "yAxisId", "position", "fill", "fillOpacity", "stroke", "strokeWidth"];
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

@@ -11,9 +15,2 @@ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

@@ -106,34 +103,3 @@ /**

};
export function ReferenceLine(_ref) {
var _ref$isFront = _ref.isFront,
isFront = _ref$isFront === void 0 ? false : _ref$isFront,
_ref$ifOverflow = _ref.ifOverflow,
ifOverflow = _ref$ifOverflow === void 0 ? 'discard' : _ref$ifOverflow,
_ref$xAxisId = _ref.xAxisId,
xAxisId = _ref$xAxisId === void 0 ? 0 : _ref$xAxisId,
_ref$yAxisId = _ref.yAxisId,
yAxisId = _ref$yAxisId === void 0 ? 0 : _ref$yAxisId,
_ref$position = _ref.position,
position = _ref$position === void 0 ? 'middle' : _ref$position,
_ref$fill = _ref.fill,
fill = _ref$fill === void 0 ? 'none' : _ref$fill,
_ref$fillOpacity = _ref.fillOpacity,
fillOpacity = _ref$fillOpacity === void 0 ? 1 : _ref$fillOpacity,
_ref$stroke = _ref.stroke,
stroke = _ref$stroke === void 0 ? '#ccc' : _ref$stroke,
_ref$strokeWidth = _ref.strokeWidth,
strokeWidth = _ref$strokeWidth === void 0 ? 1 : _ref$strokeWidth,
restProps = _objectWithoutProperties(_ref, _excluded);
// Props with default values added.
var props = _objectSpread({
isFront: isFront,
ifOverflow: ifOverflow,
xAxisId: xAxisId,
yAxisId: yAxisId,
fill: fill,
stroke: stroke,
fillOpacity: fillOpacity,
strokeWidth: strokeWidth,
position: position
}, restProps);
export function ReferenceLine(props) {
var fixedX = props.x,

@@ -185,2 +151,13 @@ fixedY = props.y,

}
ReferenceLine.displayName = 'ReferenceLine';
ReferenceLine.displayName = 'ReferenceLine';
ReferenceLine.defaultProps = {
isFront: false,
ifOverflow: 'discard',
xAxisId: 0,
yAxisId: 0,
fill: 'none',
stroke: '#ccc',
fillOpacity: 1,
strokeWidth: 1,
position: 'middle'
};

@@ -22,3 +22,4 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

height = _ref$height === void 0 ? '100%' : _ref$height,
minWidth = _ref.minWidth,
_ref$minWidth = _ref.minWidth,
minWidth = _ref$minWidth === void 0 ? 0 : _ref$minWidth,
minHeight = _ref.minHeight,

@@ -30,3 +31,4 @@ maxHeight = _ref.maxHeight,

id = _ref.id,
className = _ref.className;
className = _ref.className,
onResize = _ref.onResize;
var _useState = useState({

@@ -57,2 +59,3 @@ containerWidth: -1,

containerHeight = newSize.containerHeight;
if (onResize) onResize(containerWidth, containerHeight);
setSizes(function (currentSizes) {

@@ -59,0 +62,0 @@ var oldWidth = currentSizes.containerWidth,

import _isEqual from "lodash/isEqual";
import _sortBy from "lodash/sortBy";
import _isNaN from "lodash/isNaN";
import _upperFirst from "lodash/upperFirst";
import _isString from "lodash/isString";
import _isNaN from "lodash/isNaN";
import _isArray from "lodash/isArray";

@@ -501,9 +501,11 @@ import _max from "lodash/max";

var offset = (isGrid || isAll) && type === 'category' && scale.bandwidth ? scale.bandwidth() / offsetForBand : 0;
offset = axis.axisType === 'angleAxis' ? mathSign(range[0] - range[1]) * 2 * offset : offset;
offset = axis.axisType === 'angleAxis' && (range === null || range === void 0 ? void 0 : range.length) >= 2 ? mathSign(range[0] - range[1]) * 2 * offset : offset;
// The ticks setted by user should only affect the ticks adjacent to axis line
// The ticks set by user should only affect the ticks adjacent to axis line
if (isGrid && (axis.ticks || axis.niceTicks)) {
return (axis.ticks || axis.niceTicks).map(function (entry) {
var result = (axis.ticks || axis.niceTicks).map(function (entry) {
var scaleContent = duplicateDomain ? duplicateDomain.indexOf(entry) : entry;
return {
// If the scaleContent is not a number, the coordinate will be NaN.
// That could be the case for example with a PointScale and a string as domain.
coordinate: scale(scaleContent) + offset,

@@ -514,2 +516,5 @@ value: entry,

});
return result.filter(function (row) {
return !_isNaN(row.coordinate);
});
}

@@ -516,0 +521,0 @@

@@ -7,15 +7,14 @@ "use strict";

exports.CartesianAxis = void 0;
var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
var _get2 = _interopRequireDefault(require("lodash/get"));
var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
var _react = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _ShallowEqual = require("../util/ShallowEqual");
var _DOMUtils = require("../util/DOMUtils");
var _Layer = require("../container/Layer");
var _Text = require("../component/Text");
var _Label = require("../component/Label");
var _Global = require("../util/Global");
var _DataUtils = require("../util/DataUtils");
var _types = require("../util/types");
var _ReactUtils = require("../util/ReactUtils");
var _getTicks = require("./getTicks");
var _excluded = ["viewBox"],

@@ -59,4 +58,2 @@ _excluded2 = ["viewBox"],

}
// todo Array<Tick>
_createClass(CartesianAxis, [{

@@ -247,3 +244,3 @@ key: "shouldComponentUpdate",

unit = _this$props6.unit;
var finalTicks = CartesianAxis.getTicks(_objectSpread(_objectSpread({}, this.props), {}, {
var finalTicks = (0, _getTicks.getTicks)(_objectSpread(_objectSpread({}, this.props), {}, {
ticks: ticks

@@ -317,204 +314,2 @@ }), fontSize, letterSpacing);

}], [{
key: "getTicks",
value: function getTicks(props, fontSize, letterSpacing) {
var tick = props.tick,
ticks = props.ticks,
viewBox = props.viewBox,
minTickGap = props.minTickGap,
orientation = props.orientation,
interval = props.interval,
tickFormatter = props.tickFormatter,
unit = props.unit;
if (!ticks || !ticks.length || !tick) {
return [];
}
if ((0, _DataUtils.isNumber)(interval) || _Global.Global.isSsr) {
return CartesianAxis.getNumberIntervalTicks(ticks, typeof interval === 'number' && (0, _DataUtils.isNumber)(interval) ? interval : 0);
}
if (interval === 'preserveStartEnd') {
return CartesianAxis.getTicksStart({
ticks: ticks,
tickFormatter: tickFormatter,
viewBox: viewBox,
orientation: orientation,
minTickGap: minTickGap,
unit: unit,
fontSize: fontSize,
letterSpacing: letterSpacing
}, true);
}
if (interval === 'preserveStart') {
return CartesianAxis.getTicksStart({
ticks: ticks,
tickFormatter: tickFormatter,
viewBox: viewBox,
orientation: orientation,
minTickGap: minTickGap,
unit: unit,
fontSize: fontSize,
letterSpacing: letterSpacing
});
}
return CartesianAxis.getTicksEnd({
ticks: ticks,
tickFormatter: tickFormatter,
viewBox: viewBox,
orientation: orientation,
minTickGap: minTickGap,
unit: unit,
fontSize: fontSize,
letterSpacing: letterSpacing
});
}
}, {
key: "getNumberIntervalTicks",
value: function getNumberIntervalTicks(ticks, interval) {
return ticks.filter(function (entry, i) {
return i % (interval + 1) === 0;
});
}
}, {
key: "getTicksStart",
value: function getTicksStart(_ref3, preserveEnd) {
var ticks = _ref3.ticks,
tickFormatter = _ref3.tickFormatter,
viewBox = _ref3.viewBox,
orientation = _ref3.orientation,
minTickGap = _ref3.minTickGap,
unit = _ref3.unit,
fontSize = _ref3.fontSize,
letterSpacing = _ref3.letterSpacing;
var x = viewBox.x,
y = viewBox.y,
width = viewBox.width,
height = viewBox.height;
var sizeKey = orientation === 'top' || orientation === 'bottom' ? 'width' : 'height';
var result = (ticks || []).slice();
// we need add the width of 'unit' only when sizeKey === 'width'
var unitSize = unit && sizeKey === 'width' ? (0, _DOMUtils.getStringSize)(unit, {
fontSize: fontSize,
letterSpacing: letterSpacing
})[sizeKey] : 0;
var len = result.length;
var sign = len >= 2 ? (0, _DataUtils.mathSign)(result[1].coordinate - result[0].coordinate) : 1;
var start, end;
if (sign === 1) {
start = sizeKey === 'width' ? x : y;
end = sizeKey === 'width' ? x + width : y + height;
} else {
start = sizeKey === 'width' ? x + width : y + height;
end = sizeKey === 'width' ? x : y;
}
if (preserveEnd) {
// Try to guarantee the tail to be displayed
var tail = ticks[len - 1];
var tailContent = (0, _isFunction2["default"])(tickFormatter) ? tickFormatter(tail.value, len - 1) : tail.value;
var tailSize = (0, _DOMUtils.getStringSize)(tailContent, {
fontSize: fontSize,
letterSpacing: letterSpacing
})[sizeKey] + unitSize;
var tailGap = sign * (tail.coordinate + sign * tailSize / 2 - end);
result[len - 1] = tail = _objectSpread(_objectSpread({}, tail), {}, {
tickCoord: tailGap > 0 ? tail.coordinate - tailGap * sign : tail.coordinate
});
var isTailShow = sign * (tail.tickCoord - sign * tailSize / 2 - start) >= 0 && sign * (tail.tickCoord + sign * tailSize / 2 - end) <= 0;
if (isTailShow) {
end = tail.tickCoord - sign * (tailSize / 2 + minTickGap);
result[len - 1] = _objectSpread(_objectSpread({}, tail), {}, {
isShow: true
});
}
}
var count = preserveEnd ? len - 1 : len;
for (var i = 0; i < count; i++) {
var entry = result[i];
var content = (0, _isFunction2["default"])(tickFormatter) ? tickFormatter(entry.value, i) : entry.value;
var size = (0, _DOMUtils.getStringSize)(content, {
fontSize: fontSize,
letterSpacing: letterSpacing
})[sizeKey] + unitSize;
if (i === 0) {
var gap = sign * (entry.coordinate - sign * size / 2 - start);
result[i] = entry = _objectSpread(_objectSpread({}, entry), {}, {
tickCoord: gap < 0 ? entry.coordinate - gap * sign : entry.coordinate
});
} else {
result[i] = entry = _objectSpread(_objectSpread({}, entry), {}, {
tickCoord: entry.coordinate
});
}
var isShow = sign * (entry.tickCoord - sign * size / 2 - start) >= 0 && sign * (entry.tickCoord + sign * size / 2 - end) <= 0;
if (isShow) {
start = entry.tickCoord + sign * (size / 2 + minTickGap);
result[i] = _objectSpread(_objectSpread({}, entry), {}, {
isShow: true
});
}
}
return result.filter(function (entry) {
return entry.isShow;
});
}
}, {
key: "getTicksEnd",
value: function getTicksEnd(_ref4) {
var ticks = _ref4.ticks,
tickFormatter = _ref4.tickFormatter,
viewBox = _ref4.viewBox,
orientation = _ref4.orientation,
minTickGap = _ref4.minTickGap,
unit = _ref4.unit,
fontSize = _ref4.fontSize,
letterSpacing = _ref4.letterSpacing;
var x = viewBox.x,
y = viewBox.y,
width = viewBox.width,
height = viewBox.height;
var sizeKey = orientation === 'top' || orientation === 'bottom' ? 'width' : 'height';
// we need add the width of 'unit' only when sizeKey === 'width'
var unitSize = unit && sizeKey === 'width' ? (0, _DOMUtils.getStringSize)(unit, {
fontSize: fontSize,
letterSpacing: letterSpacing
})[sizeKey] : 0;
var result = (ticks || []).slice();
var len = result.length;
var sign = len >= 2 ? (0, _DataUtils.mathSign)(result[1].coordinate - result[0].coordinate) : 1;
var start, end;
if (sign === 1) {
start = sizeKey === 'width' ? x : y;
end = sizeKey === 'width' ? x + width : y + height;
} else {
start = sizeKey === 'width' ? x + width : y + height;
end = sizeKey === 'width' ? x : y;
}
for (var i = len - 1; i >= 0; i--) {
var entry = result[i];
var content = (0, _isFunction2["default"])(tickFormatter) ? tickFormatter(entry.value, len - i - 1) : entry.value;
var size = (0, _DOMUtils.getStringSize)(content, {
fontSize: fontSize,
letterSpacing: letterSpacing
})[sizeKey] + unitSize;
if (i === len - 1) {
var gap = sign * (entry.coordinate + sign * size / 2 - end);
result[i] = entry = _objectSpread(_objectSpread({}, entry), {}, {
tickCoord: gap > 0 ? entry.coordinate - gap * sign : entry.coordinate
});
} else {
result[i] = entry = _objectSpread(_objectSpread({}, entry), {}, {
tickCoord: entry.coordinate
});
}
var isShow = sign * (entry.tickCoord - sign * size / 2 - start) >= 0 && sign * (entry.tickCoord + sign * size / 2 - end) <= 0;
if (isShow) {
end = entry.tickCoord - sign * (size / 2 + minTickGap);
result[i] = _objectSpread(_objectSpread({}, entry), {}, {
isShow: true
});
}
}
return result.filter(function (entry) {
return entry.isShow;
});
}
}, {
key: "renderTickItem",

@@ -521,0 +316,0 @@ value: function renderTickItem(option, props, value) {

"use strict";
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
Object.defineProperty(exports, "__esModule", {

@@ -19,4 +18,4 @@ value: true

var _ReactUtils = require("../util/ReactUtils");
var _excluded = ["isFront", "ifOverflow", "xAxisId", "yAxisId", "r", "fill", "fillOpacity", "stroke", "strokeWidth"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

@@ -28,4 +27,2 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
var getRect = function getRect(hasX1, hasX2, hasY1, hasY2, props) {

@@ -64,34 +61,3 @@ var xValue1 = props.x1,

};
function ReferenceArea(_ref) {
var _ref$isFront = _ref.isFront,
isFront = _ref$isFront === void 0 ? false : _ref$isFront,
_ref$ifOverflow = _ref.ifOverflow,
ifOverflow = _ref$ifOverflow === void 0 ? 'discard' : _ref$ifOverflow,
_ref$xAxisId = _ref.xAxisId,
xAxisId = _ref$xAxisId === void 0 ? 0 : _ref$xAxisId,
_ref$yAxisId = _ref.yAxisId,
yAxisId = _ref$yAxisId === void 0 ? 0 : _ref$yAxisId,
_ref$r = _ref.r,
r = _ref$r === void 0 ? 10 : _ref$r,
_ref$fill = _ref.fill,
fill = _ref$fill === void 0 ? '#ccc' : _ref$fill,
_ref$fillOpacity = _ref.fillOpacity,
fillOpacity = _ref$fillOpacity === void 0 ? 0.5 : _ref$fillOpacity,
_ref$stroke = _ref.stroke,
stroke = _ref$stroke === void 0 ? 'none' : _ref$stroke,
_ref$strokeWidth = _ref.strokeWidth,
strokeWidth = _ref$strokeWidth === void 0 ? 1 : _ref$strokeWidth,
restProps = _objectWithoutProperties(_ref, _excluded);
// Props with default values added.
var props = _objectSpread({
isFront: isFront,
ifOverflow: ifOverflow,
xAxisId: xAxisId,
yAxisId: yAxisId,
r: r,
fill: fill,
fillOpacity: fillOpacity,
stroke: stroke,
strokeWidth: strokeWidth
}, restProps);
function ReferenceArea(props) {
var x1 = props.x1,

@@ -125,2 +91,13 @@ x2 = props.x2,

ReferenceArea.displayName = 'ReferenceArea';
ReferenceArea.defaultProps = {
isFront: false,
ifOverflow: 'discard',
xAxisId: 0,
yAxisId: 0,
r: 10,
fill: '#ccc',
fillOpacity: 0.5,
stroke: 'none',
strokeWidth: 1
};
ReferenceArea.renderRect = function (option, props) {

@@ -127,0 +104,0 @@ var rect;

@@ -19,4 +19,8 @@ "use strict";

var _ReactUtils = require("../util/ReactUtils");
var _excluded = ["isFront", "ifOverflow", "xAxisId", "yAxisId", "position", "fill", "fillOpacity", "stroke", "strokeWidth"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

@@ -28,9 +32,2 @@ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

@@ -111,34 +108,3 @@ var renderLine = function renderLine(option, props) {

};
function ReferenceLine(_ref) {
var _ref$isFront = _ref.isFront,
isFront = _ref$isFront === void 0 ? false : _ref$isFront,
_ref$ifOverflow = _ref.ifOverflow,
ifOverflow = _ref$ifOverflow === void 0 ? 'discard' : _ref$ifOverflow,
_ref$xAxisId = _ref.xAxisId,
xAxisId = _ref$xAxisId === void 0 ? 0 : _ref$xAxisId,
_ref$yAxisId = _ref.yAxisId,
yAxisId = _ref$yAxisId === void 0 ? 0 : _ref$yAxisId,
_ref$position = _ref.position,
position = _ref$position === void 0 ? 'middle' : _ref$position,
_ref$fill = _ref.fill,
fill = _ref$fill === void 0 ? 'none' : _ref$fill,
_ref$fillOpacity = _ref.fillOpacity,
fillOpacity = _ref$fillOpacity === void 0 ? 1 : _ref$fillOpacity,
_ref$stroke = _ref.stroke,
stroke = _ref$stroke === void 0 ? '#ccc' : _ref$stroke,
_ref$strokeWidth = _ref.strokeWidth,
strokeWidth = _ref$strokeWidth === void 0 ? 1 : _ref$strokeWidth,
restProps = _objectWithoutProperties(_ref, _excluded);
// Props with default values added.
var props = _objectSpread({
isFront: isFront,
ifOverflow: ifOverflow,
xAxisId: xAxisId,
yAxisId: yAxisId,
fill: fill,
stroke: stroke,
fillOpacity: fillOpacity,
strokeWidth: strokeWidth,
position: position
}, restProps);
function ReferenceLine(props) {
var fixedX = props.x,

@@ -190,2 +156,13 @@ fixedY = props.y,

}
ReferenceLine.displayName = 'ReferenceLine';
ReferenceLine.displayName = 'ReferenceLine';
ReferenceLine.defaultProps = {
isFront: false,
ifOverflow: 'discard',
xAxisId: 0,
yAxisId: 0,
fill: 'none',
stroke: '#ccc',
fillOpacity: 1,
strokeWidth: 1,
position: 'middle'
};

@@ -29,3 +29,4 @@ "use strict";

height = _ref$height === void 0 ? '100%' : _ref$height,
minWidth = _ref.minWidth,
_ref$minWidth = _ref.minWidth,
minWidth = _ref$minWidth === void 0 ? 0 : _ref$minWidth,
minHeight = _ref.minHeight,

@@ -37,3 +38,4 @@ maxHeight = _ref.maxHeight,

id = _ref.id,
className = _ref.className;
className = _ref.className,
onResize = _ref.onResize;
var _useState = (0, _react.useState)({

@@ -64,2 +66,3 @@ containerWidth: -1,

containerHeight = newSize.containerHeight;
if (onResize) onResize(containerWidth, containerHeight);
setSizes(function (currentSizes) {

@@ -66,0 +69,0 @@ var oldWidth = currentSizes.containerWidth,

@@ -13,5 +13,5 @@ "use strict";

var _sortBy2 = _interopRequireDefault(require("lodash/sortBy"));
var _isNaN2 = _interopRequireDefault(require("lodash/isNaN"));
var _upperFirst2 = _interopRequireDefault(require("lodash/upperFirst"));
var _isString2 = _interopRequireDefault(require("lodash/isString"));
var _isNaN2 = _interopRequireDefault(require("lodash/isNaN"));
var _isArray2 = _interopRequireDefault(require("lodash/isArray"));

@@ -523,9 +523,11 @@ var _max2 = _interopRequireDefault(require("lodash/max"));

var offset = (isGrid || isAll) && type === 'category' && scale.bandwidth ? scale.bandwidth() / offsetForBand : 0;
offset = axis.axisType === 'angleAxis' ? (0, _DataUtils.mathSign)(range[0] - range[1]) * 2 * offset : offset;
offset = axis.axisType === 'angleAxis' && (range === null || range === void 0 ? void 0 : range.length) >= 2 ? (0, _DataUtils.mathSign)(range[0] - range[1]) * 2 * offset : offset;
// The ticks setted by user should only affect the ticks adjacent to axis line
// The ticks set by user should only affect the ticks adjacent to axis line
if (isGrid && (axis.ticks || axis.niceTicks)) {
return (axis.ticks || axis.niceTicks).map(function (entry) {
var result = (axis.ticks || axis.niceTicks).map(function (entry) {
var scaleContent = duplicateDomain ? duplicateDomain.indexOf(entry) : entry;
return {
// If the scaleContent is not a number, the coordinate will be NaN.
// That could be the case for example with a PointScale and a string as domain.
coordinate: scale(scaleContent) + offset,

@@ -536,2 +538,5 @@ value: entry,

});
return result.filter(function (row) {
return !(0, _isNaN2["default"])(row.coordinate);
});
}

@@ -538,0 +543,0 @@

{
"name": "recharts",
"version": "2.4.3",
"version": "2.5.0",
"description": "React charts",

@@ -39,3 +39,6 @@ "main": "lib/index",

"build-storybook": "npx storybook build -o storybook/public -c storybook",
"chromatic": "npx chromatic"
"chromatic": "npx chromatic",
"test-storybook": "test-storybook --config-dir storybook",
"test-storybook:url": "test-storybook --url http://127.0.0.1:9009 --config-dir storybook",
"test-storybook:ci": "concurrently -k -s first -n \"SB,TEST\" -c \"magenta,blue\" \"npm run build-storybook --quiet && npx http-server storybook/public --port 9009 --silent\" \"wait-on tcp:127.0.0.1:9009 && npm run test-storybook:url --maxWorkers=2\""
},

@@ -69,4 +72,4 @@ "lint-staged": {

"react-is": "^16.10.2",
"react-resize-detector": "^7.1.2",
"react-smooth": "^2.0.1",
"react-resize-detector": "^8.0.4",
"react-smooth": "^2.0.2",
"recharts-scale": "^0.4.4",

@@ -88,8 +91,11 @@ "reduce-css-calc": "^2.1.8",

"@babel/runtime": "^7.6.3",
"@storybook/addon-essentials": "^7.0.0-beta.39",
"@storybook/addon-interactions": "^7.0.0-beta.39",
"@storybook/addon-links": "^7.0.0-beta.39",
"@storybook/react": "^7.0.0-beta.39",
"@storybook/react-webpack5": "^7.0.0-beta.39",
"@storybook/testing-library": "^0.0.13",
"@storybook/addon-docs": "^7.0.0-beta.47",
"@storybook/addon-essentials": "^7.0.0-beta.47",
"@storybook/addon-interactions": "^7.0.0-beta.47",
"@storybook/addon-links": "^7.0.0-beta.47",
"@storybook/jest": "^0.0.11-next.0",
"@storybook/react": "^7.0.0-beta.47",
"@storybook/react-webpack5": "^7.0.0-beta.47",
"@storybook/test-runner": "^0.9.4",
"@storybook/testing-library": "^0.0.14-next.1",
"@testing-library/jest-dom": "^5.16.5",

@@ -102,2 +108,3 @@ "@testing-library/react": "^12.1.5",

"@types/d3-shape": "^3.1.0",
"@types/d3-time-format": "^4.0.0",
"@types/jest": "^27.5.1",

@@ -116,4 +123,7 @@ "@types/lodash": "^4.14.144",

"chromatic": "^6.15.0",
"concurrently": "^7.6.0",
"cross-env": "^7.0.3",
"d3-scale-chromatic": "^3.0.0",
"d3-time": "^3.1.0",
"d3-time-format": "^4.1.0",
"eslint": "^7.32.0",

@@ -138,3 +148,3 @@ "eslint-config-airbnb": "^18.2.1",

"rimraf": "^3.0.2",
"storybook": "^7.0.0-beta.39",
"storybook": "^7.0.0-beta.47",
"terser-webpack-plugin": "^5.1.1",

@@ -141,0 +151,0 @@ "ts-jest": "^27.1.5",

@@ -29,2 +29,3 @@ import { PureComponent, ReactElement, SVGProps } from 'react';

dataKey: DataKey<any>;
data?: any[];
type?: CurveType;

@@ -31,0 +32,0 @@ unit?: string | number;

import { ReactElement, ReactNode, Component, SVGProps } from 'react';
import { CartesianViewBox, TickItem, PresentationAttributesAdaptChildEvent } from '../util/types';
interface CartesianTickItem extends TickItem {
tickCoord?: number;
tickSize?: number;
isShow?: boolean;
}
import { CartesianViewBox, PresentationAttributesAdaptChildEvent, CartesianTickItem } from '../util/types';
export interface CartesianAxisProps {

@@ -29,3 +24,3 @@ className?: string;

ticksGenerator?: (props?: CartesianAxisProps) => CartesianTickItem[];
interval?: number | 'preserveStart' | 'preserveEnd' | 'preserveStartEnd';
interval?: number | 'preserveStart' | 'preserveEnd' | 'preserveStartEnd' | 'equidistantPreserveStart';
}

@@ -64,6 +59,2 @@ interface IState {

constructor(props: Props);
static getTicks(props: Props, fontSize?: string, letterSpacing?: string): any[];
static getNumberIntervalTicks(ticks: CartesianTickItem[], interval: number): CartesianTickItem[];
static getTicksStart({ ticks, tickFormatter, viewBox, orientation, minTickGap, unit, fontSize, letterSpacing, }: Omit<Props, 'tickMargin'>, preserveEnd?: boolean): CartesianTickItem[];
static getTicksEnd({ ticks, tickFormatter, viewBox, orientation, minTickGap, unit, fontSize, letterSpacing, }: Omit<Props, 'tickMargin'>): CartesianTickItem[];
shouldComponentUpdate({ viewBox, ...restProps }: Props, nextState: IState): boolean;

@@ -70,0 +61,0 @@ componentDidMount(): void;

@@ -32,7 +32,18 @@ import React, { ReactElement } from 'react';

export declare type Props = RectangleProps & ReferenceAreaProps;
export declare function ReferenceArea({ isFront, ifOverflow, xAxisId, yAxisId, r, fill, fillOpacity, stroke, strokeWidth, ...restProps }: Props): JSX.Element;
export declare function ReferenceArea(props: Props): JSX.Element;
export declare namespace ReferenceArea {
var displayName: string;
var defaultProps: {
isFront: boolean;
ifOverflow: string;
xAxisId: number;
yAxisId: number;
r: number;
fill: string;
fillOpacity: number;
stroke: string;
strokeWidth: number;
};
var renderRect: (option: React.ReactElement<SVGElement, string | ((props: any) => React.ReactElement<any, any>) | (new (props: any) => React.Component<any, any, any>)> | ((props: any) => React.ReactElement<SVGElement, string | ((props: any) => React.ReactElement<any, any>) | (new (props: any) => React.Component<any, any, any>)>), props: any) => JSX.Element;
}
export {};

@@ -34,6 +34,17 @@ import { ReactElement, SVGProps } from 'react';

export declare type Props = SVGProps<SVGLineElement> & ReferenceLineProps;
export declare function ReferenceLine({ isFront, ifOverflow, xAxisId, yAxisId, position, fill, fillOpacity, stroke, strokeWidth, ...restProps }: Props): JSX.Element;
export declare function ReferenceLine(props: Props): JSX.Element;
export declare namespace ReferenceLine {
var displayName: string;
var defaultProps: {
isFront: boolean;
ifOverflow: string;
xAxisId: number;
yAxisId: number;
fill: string;
stroke: string;
fillOpacity: number;
strokeWidth: number;
position: string;
};
}
export {};

@@ -75,2 +75,3 @@ /// <reference types="react" />

domain?: import("../util/types").AxisDomain;
includeHidden?: boolean;
name?: string;

@@ -77,0 +78,0 @@ unit?: string | number;

@@ -75,2 +75,3 @@ /// <reference types="react" />

domain?: import("../util/types").AxisDomain;
includeHidden?: boolean;
name?: string;

@@ -77,0 +78,0 @@ unit?: string | number;

@@ -75,2 +75,3 @@ /// <reference types="react" />

domain?: import("../util/types").AxisDomain;
includeHidden?: boolean;
name?: string;

@@ -77,0 +78,0 @@ unit?: string | number;

@@ -75,2 +75,3 @@ /// <reference types="react" />

domain?: import("../util/types").AxisDomain;
includeHidden?: boolean;
name?: string;

@@ -77,0 +78,0 @@ unit?: string | number;

@@ -152,2 +152,3 @@ import React from 'react';

domain?: AxisDomain;
includeHidden?: boolean;
name?: string;

@@ -154,0 +155,0 @@ unit?: string | number;

@@ -75,2 +75,3 @@ /// <reference types="react" />

domain?: import("../util/types").AxisDomain;
includeHidden?: boolean;
name?: string;

@@ -77,0 +78,0 @@ unit?: string | number;

@@ -75,2 +75,3 @@ /// <reference types="react" />

domain?: import("../util/types").AxisDomain;
includeHidden?: boolean;
name?: string;

@@ -77,0 +78,0 @@ unit?: string | number;

@@ -75,2 +75,3 @@ /// <reference types="react" />

domain?: import("../util/types").AxisDomain;
includeHidden?: boolean;
name?: string;

@@ -77,0 +78,0 @@ unit?: string | number;

@@ -75,2 +75,3 @@ /// <reference types="react" />

domain?: import("../util/types").AxisDomain;
includeHidden?: boolean;
name?: string;

@@ -77,0 +78,0 @@ unit?: string | number;

@@ -75,2 +75,3 @@ /// <reference types="react" />

domain?: import("../util/types").AxisDomain;
includeHidden?: boolean;
name?: string;

@@ -77,0 +78,0 @@ unit?: string | number;

@@ -13,3 +13,4 @@ import React, { ReactElement } from 'react';

className?: string | number;
onResize?: (width: number, height: number) => void;
}
export declare const ResponsiveContainer: React.ForwardRefExoticComponent<Props & React.RefAttributes<unknown>>;

@@ -448,2 +448,3 @@ import { AriaAttributes, SVGProps, SyntheticEvent, ClipboardEvent, CompositionEvent, DragEvent, FocusEvent, FormEvent, KeyboardEvent, MouseEvent, TouchEvent, PointerEvent, UIEvent, WheelEvent, AnimationEvent, TransitionEvent, ReactNode, Component, FunctionComponent, ReactElement } from 'react';

domain?: AxisDomain;
includeHidden?: boolean;
name?: string;

@@ -462,2 +463,7 @@ unit?: string | number;

}
export interface CartesianTickItem extends TickItem {
tickCoord?: number;
tickSize?: number;
isShow?: boolean;
}
export interface Margin {

@@ -464,0 +470,0 @@ top?: number;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc