recharts
Version:
React charts
668 lines (659 loc) • 25.7 kB
JavaScript
var _excluded = ["id"],
_excluded2 = ["activeDot", "animationBegin", "animationDuration", "animationEasing", "connectNulls", "dot", "fill", "fillOpacity", "hide", "isAnimationActive", "legendType", "stroke", "xAxisId", "yAxisId"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import * as React from 'react';
import { PureComponent, useMemo, useRef } from 'react';
import { clsx } from 'clsx';
import { Layer } from '../container/Layer';
import { CartesianLabelListContextProvider, LabelListFromLabelProp } from '../component/LabelList';
import { Dots } from '../component/Dots';
import { interpolate, isNan, isNullish, isNumber, noop } from '../util/DataUtils';
import { getCateCoordinateOfLine, getNormalizedStackId, getTooltipNameProp, getValueByDataKey } from '../util/ChartUtils';
import { isClipDot } from '../util/ReactUtils';
import { ActivePoints } from '../component/ActivePoints';
import { SetTooltipEntrySettings } from '../state/SetTooltipEntrySettings';
import { GraphicalItemClipPath, useNeedsClip } from './GraphicalItemClipPath';
import { selectArea } from '../state/selectors/areaSelectors';
import { useIsPanorama } from '../context/PanoramaContext';
import { useCartesianChartLayout, useChartLayout } from '../context/chartLayoutContext';
import { useChartName } from '../state/selectors/selectors';
import { SetLegendPayload } from '../state/SetLegendPayload';
import { useAppSelector } from '../state/hooks';
import { AnimatedItems, useAnimationCallbacks } from '../animation/AnimatedItems';
import { matchAnimationItems, matchByIndex } from '../animation/matchBy';
import { useAnimationStartSnapshot } from '../animation/useAnimationStartSnapshot';
import { resolveDefaultProps } from '../util/resolveDefaultProps';
import { usePlotArea } from '../hooks';
import { RegisterGraphicalItemId } from '../context/RegisterGraphicalItemId';
import { SetCartesianGraphicalItem } from '../state/SetGraphicalItem';
import { svgPropertiesNoEvents } from '../util/svgPropertiesNoEvents';
import { getRadiusAndStrokeWidthFromDot } from '../util/getRadiusAndStrokeWidthFromDot';
import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents';
import { Shape } from '../util/ActiveShapeUtils';
import { ZIndexLayer } from '../zIndex/ZIndexLayer';
import { DefaultZIndexes } from '../zIndex/DefaultZIndexes';
import { propsAreEqual } from '../util/propsAreEqual';
import { AreaRevealShape } from './AreaRevealShape';
/**
* @inline
*/
/**
* Our base value array has payload in it, and we expose it externally too.
*/
/**
* Internal props, combination of external props + defaultProps + private Recharts state
*/
/**
* External props, intended for end users to fill in
*/
var defaultAreaAnimateItems = (items, animationElapsedTime) => {
if (items == null) {
// First render: return items as-is, clip-path animation handles the reveal
return [];
}
if (animationElapsedTime === 1) {
return items.flatMap(item => item.status === 'removed' ? [] : [item.next]);
}
return items.flatMap(item => {
if (item.status === 'matched') {
return [_objectSpread(_objectSpread({}, item.next), {}, {
x: interpolate(item.prev.x, item.next.x, animationElapsedTime),
y: interpolate(item.prev.y, item.next.y, animationElapsedTime)
})];
}
if (item.status === 'added') {
/*
* Here we just return the final position without interpolating
* so that we can allow the default initial animation that is done by clipPath in AreaRevealShape.
* If you want your own custom animations then you may want to interpolate this one as well.
*/
return [item.next];
}
// removed: drop
return [];
});
};
export var defaultAreaProps = {
activeDot: true,
animationBegin: 0,
animationDuration: 1500,
animationEasing: 'ease',
animationMatchBy: matchByIndex,
animationInterpolateFn: defaultAreaAnimateItems,
connectNulls: false,
dot: false,
fill: '#3182bd',
fillOpacity: 0.6,
hide: false,
isAnimationActive: 'auto',
legendType: 'line',
stroke: '#3182bd',
strokeWidth: 1,
type: 'linear',
label: false,
shape: AreaRevealShape,
xAxisId: 0,
yAxisId: 0,
zIndex: DefaultZIndexes.area
};
/**
* Because of naming conflict, we are forced to ignore certain (valid) SVG attributes.
*/
function getLegendItemColor(stroke, fill) {
return stroke && stroke !== 'none' ? stroke : fill;
}
var computeLegendPayloadFromAreaData = props => {
var dataKey = props.dataKey,
name = props.name,
stroke = props.stroke,
fill = props.fill,
legendType = props.legendType,
hide = props.hide;
return [{
inactive: hide,
dataKey,
type: legendType,
color: getLegendItemColor(stroke, fill),
value: getTooltipNameProp(name, dataKey),
payload: props
}];
};
var SetAreaTooltipEntrySettings = /*#__PURE__*/React.memo(_ref => {
var dataKey = _ref.dataKey,
data = _ref.data,
stroke = _ref.stroke,
strokeWidth = _ref.strokeWidth,
fill = _ref.fill,
name = _ref.name,
hide = _ref.hide,
unit = _ref.unit,
formatter = _ref.formatter,
tooltipType = _ref.tooltipType,
id = _ref.id;
var tooltipEntrySettings = {
dataDefinedOnItem: data,
getPosition: noop,
settings: {
stroke,
strokeWidth,
fill,
dataKey,
nameKey: undefined,
name: getTooltipNameProp(name, dataKey),
hide,
type: tooltipType,
color: getLegendItemColor(stroke, fill),
unit,
formatter,
graphicalItemId: id
}
};
return /*#__PURE__*/React.createElement(SetTooltipEntrySettings, {
tooltipEntrySettings: tooltipEntrySettings
});
});
function AreaDotsWrapper(_ref2) {
var clipPathId = _ref2.clipPathId,
points = _ref2.points,
props = _ref2.props;
var needClip = props.needClip,
dot = props.dot,
dataKey = props.dataKey;
var areaProps = svgPropertiesNoEvents(props);
return /*#__PURE__*/React.createElement(Dots, {
points: points,
dot: dot,
className: "recharts-area-dots",
dotClassName: "recharts-area-dot",
dataKey: dataKey,
baseProps: areaProps,
needClip: needClip,
clipPathId: clipPathId
});
}
function AreaLabelListProvider(_ref3) {
var showLabels = _ref3.showLabels,
children = _ref3.children,
points = _ref3.points;
var labelListEntries = points.map(point => {
var _point$x, _point$y;
var viewBox = {
x: (_point$x = point.x) !== null && _point$x !== void 0 ? _point$x : 0,
y: (_point$y = point.y) !== null && _point$y !== void 0 ? _point$y : 0,
width: 0,
lowerWidth: 0,
upperWidth: 0,
height: 0
};
return _objectSpread(_objectSpread({}, viewBox), {}, {
value: point.value,
payload: point.payload,
parentViewBox: undefined,
viewBox,
fill: undefined
});
});
return /*#__PURE__*/React.createElement(CartesianLabelListContextProvider, {
value: showLabels ? labelListEntries : undefined
}, children);
}
function StaticArea(_ref4) {
var points = _ref4.points,
baseLine = _ref4.baseLine,
needClip = _ref4.needClip,
clipPathId = _ref4.clipPathId,
props = _ref4.props,
animationElapsedTime = _ref4.animationElapsedTime,
isAnimating = _ref4.isAnimating,
isEntrance = _ref4.isEntrance;
var layout = props.layout,
type = props.type,
stroke = props.stroke,
connectNulls = props.connectNulls,
isRange = props.isRange,
shape = props.shape;
var id = props.id,
propsWithoutId = _objectWithoutProperties(props, _excluded);
var propsWithEvents = svgPropertiesAndEvents(propsWithoutId);
var curveProps = _objectSpread(_objectSpread({}, propsWithEvents), {}, {
id,
points,
connectNulls,
type,
baseLine,
layout,
stroke,
isRange,
animationElapsedTime,
isAnimating,
isEntrance
});
return /*#__PURE__*/React.createElement(React.Fragment, null, (points === null || points === void 0 ? void 0 : points.length) > 1 && /*#__PURE__*/React.createElement(Layer, {
clipPath: needClip ? "url(#clipPath-".concat(clipPathId, ")") : undefined
}, /*#__PURE__*/React.createElement(Shape, {
option: shape,
DefaultShape: defaultAreaProps.shape,
shapeProps: curveProps
})), /*#__PURE__*/React.createElement(AreaDotsWrapper, {
points: points,
props: propsWithoutId,
clipPathId: clipPathId
}));
}
function interpolateScalarBaseLine(baseLine, prevBaseLine, animationElapsedTime) {
if (isNumber(baseLine)) {
var previousNumberBaseLine = isNumber(prevBaseLine) ? prevBaseLine : undefined;
return interpolate(previousNumberBaseLine, baseLine, animationElapsedTime);
}
if (isNullish(baseLine) || isNan(baseLine)) {
var _previousNumberBaseLine = isNumber(prevBaseLine) ? prevBaseLine : undefined;
return interpolate(_previousNumberBaseLine, 0, animationElapsedTime);
}
return baseLine;
}
function AreaWithAnimation(_ref5) {
var needClip = _ref5.needClip,
clipPathId = _ref5.clipPathId,
props = _ref5.props,
previousPointsRef = _ref5.previousPointsRef,
previousBaselineRef = _ref5.previousBaselineRef;
var points = props.points,
baseLine = props.baseLine,
isAnimationActive = props.isAnimationActive,
animationBegin = props.animationBegin,
animationDuration = props.animationDuration,
animationEasing = props.animationEasing,
animationMatchBy = props.animationMatchBy,
animationInterpolateFn = props.animationInterpolateFn;
var animationInput = useMemo(() => ({
points,
baseLine
}), [points, baseLine]);
var baseLineAnimationState = useAnimationStartSnapshot(animationInput, previousBaselineRef);
var layout = useCartesianChartLayout();
var _useAnimationCallback = useAnimationCallbacks(props.onAnimationStart, props.onAnimationEnd),
isAnimating = _useAnimationCallback.isAnimating,
handleAnimationStart = _useAnimationCallback.handleAnimationStart,
handleAnimationEnd = _useAnimationCallback.handleAnimationEnd;
var prevBaseLine = baseLineAnimationState.startValue;
if (layout == null) {
return null;
}
var baseLineAnimationItems;
if (Array.isArray(baseLine) && Array.isArray(prevBaseLine)) {
baseLineAnimationItems = matchAnimationItems(prevBaseLine, baseLine, animationMatchBy);
} else if (Array.isArray(baseLine)) {
baseLineAnimationItems = matchAnimationItems(null, baseLine, animationMatchBy);
} else {
baseLineAnimationItems = null;
}
return /*#__PURE__*/React.createElement(AnimatedItems, {
animationInput: animationInput,
animationIdPrefix: "recharts-area-",
items: points,
previousItemsRef: previousPointsRef,
isAnimationActive: isAnimationActive,
animationBegin: animationBegin,
animationDuration: animationDuration,
animationEasing: animationEasing,
onAnimationStart: handleAnimationStart,
onAnimationEnd: handleAnimationEnd,
animationInterpolateFn: animationInterpolateFn,
animationMatchBy: animationMatchBy,
layout: layout
}, (stepPoints, animationElapsedTime, isEntrance) => {
var stepBaseLine;
if (animationElapsedTime === 1) {
stepBaseLine = baseLine;
} else if (Array.isArray(baseLine)) {
stepBaseLine = animationInterpolateFn(baseLineAnimationItems, animationElapsedTime, layout);
} else {
stepBaseLine = isEntrance ? baseLine : interpolateScalarBaseLine(baseLine, prevBaseLine, animationElapsedTime);
}
baseLineAnimationState.syncStepValue(stepBaseLine, animationElapsedTime);
return /*#__PURE__*/React.createElement(AreaLabelListProvider, {
showLabels: !isAnimating,
points: points
}, props.children, /*#__PURE__*/React.createElement(StaticArea, {
points: stepPoints,
baseLine: stepBaseLine,
needClip: needClip,
clipPathId: clipPathId,
props: props,
animationElapsedTime: animationElapsedTime,
isAnimating: isAnimating || animationElapsedTime < 1,
isEntrance: isEntrance
}), /*#__PURE__*/React.createElement(LabelListFromLabelProp, {
label: props.label
}));
});
}
/*
* This component decides if the area should be animated or not.
* It also holds the state of the animation.
*/
function RenderArea(_ref6) {
var needClip = _ref6.needClip,
clipPathId = _ref6.clipPathId,
props = _ref6.props;
/*
* These two must be refs, not state!
* Because we want to store the most recent shape of the animation in case we have to interrupt the animation;
* that happens when user initiates another animation before the current one finishes.
*
* If this was a useState, then every step in the animation would trigger a re-render.
* So, useRef it is.
*/
var previousPointsRef = useRef(null);
var previousBaselineRef = useRef();
return /*#__PURE__*/React.createElement(AreaWithAnimation, {
needClip: needClip,
clipPathId: clipPathId,
props: props,
previousPointsRef: previousPointsRef,
previousBaselineRef: previousBaselineRef
});
}
class AreaWithState extends PureComponent {
render() {
var _this$props = this.props,
hide = _this$props.hide,
dot = _this$props.dot,
points = _this$props.points,
className = _this$props.className,
top = _this$props.top,
left = _this$props.left,
needClip = _this$props.needClip,
xAxisId = _this$props.xAxisId,
yAxisId = _this$props.yAxisId,
width = _this$props.width,
height = _this$props.height,
id = _this$props.id,
baseLine = _this$props.baseLine,
zIndex = _this$props.zIndex;
if (hide) {
return null;
}
var layerClass = clsx('recharts-area', className);
var clipPathId = id;
var _getRadiusAndStrokeWi = getRadiusAndStrokeWidthFromDot(dot),
r = _getRadiusAndStrokeWi.r,
strokeWidth = _getRadiusAndStrokeWi.strokeWidth;
var clipDot = isClipDot(dot);
var dotSize = r * 2 + strokeWidth;
var activePointsClipPath = needClip ? "url(#clipPath-".concat(clipDot ? '' : 'dots-').concat(clipPathId, ")") : undefined;
return /*#__PURE__*/React.createElement(ZIndexLayer, {
zIndex: zIndex
}, /*#__PURE__*/React.createElement(Layer, {
className: layerClass
}, needClip && /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement(GraphicalItemClipPath, {
clipPathId: clipPathId,
xAxisId: xAxisId,
yAxisId: yAxisId
}), !clipDot && /*#__PURE__*/React.createElement("clipPath", {
id: "clipPath-dots-".concat(clipPathId)
}, /*#__PURE__*/React.createElement("rect", {
x: left - dotSize / 2,
y: top - dotSize / 2,
width: width + dotSize,
height: height + dotSize
}))), /*#__PURE__*/React.createElement(RenderArea, {
needClip: needClip,
clipPathId: clipPathId,
props: this.props
})), /*#__PURE__*/React.createElement(ActivePoints, {
points: points,
mainColor: getLegendItemColor(this.props.stroke, this.props.fill),
itemDataKey: this.props.dataKey,
activeDot: this.props.activeDot,
clipPath: activePointsClipPath
}), this.props.isRange && Array.isArray(baseLine) && /*#__PURE__*/React.createElement(ActivePoints, {
points: baseLine,
mainColor: getLegendItemColor(this.props.stroke, this.props.fill),
itemDataKey: this.props.dataKey,
activeDot: this.props.activeDot,
clipPath: activePointsClipPath
}));
}
}
function AreaImpl(props) {
var _useAppSelector;
var activeDot = props.activeDot,
animationBegin = props.animationBegin,
animationDuration = props.animationDuration,
animationEasing = props.animationEasing,
connectNulls = props.connectNulls,
dot = props.dot,
fill = props.fill,
fillOpacity = props.fillOpacity,
hide = props.hide,
isAnimationActive = props.isAnimationActive,
legendType = props.legendType,
stroke = props.stroke,
xAxisId = props.xAxisId,
yAxisId = props.yAxisId,
everythingElse = _objectWithoutProperties(props, _excluded2);
var layout = useChartLayout();
var chartName = useChartName();
var _useNeedsClip = useNeedsClip(xAxisId, yAxisId),
needClip = _useNeedsClip.needClip;
var isPanorama = useIsPanorama();
var _ref7 = (_useAppSelector = useAppSelector(state => selectArea(state, props.id, isPanorama))) !== null && _useAppSelector !== void 0 ? _useAppSelector : {},
points = _ref7.points,
isRange = _ref7.isRange,
baseLine = _ref7.baseLine;
var plotArea = usePlotArea();
if (layout !== 'horizontal' && layout !== 'vertical' || plotArea == null) {
// Can't render Area in an unsupported layout
return null;
}
if (chartName !== 'AreaChart' && chartName !== 'ComposedChart') {
// There is nothing stopping us from rendering Area in other charts, except for historical reasons. Do we want to allow that?
return null;
}
var height = plotArea.height,
width = plotArea.width,
left = plotArea.x,
top = plotArea.y;
if (!points || !points.length) {
return null;
}
return /*#__PURE__*/React.createElement(AreaWithState, _extends({}, everythingElse, {
activeDot: activeDot,
animationBegin: animationBegin,
animationDuration: animationDuration,
animationEasing: animationEasing,
baseLine: baseLine,
connectNulls: connectNulls,
dot: dot,
fill: fill,
fillOpacity: fillOpacity,
height: height,
hide: hide,
layout: layout,
isAnimationActive: isAnimationActive,
isRange: isRange,
legendType: legendType,
needClip: needClip,
points: points,
stroke: stroke,
width: width,
left: left,
top: top,
xAxisId: xAxisId,
yAxisId: yAxisId
}));
}
export var getBaseValue = (layout, chartBaseValue, itemBaseValue, xAxis, yAxis) => {
// The baseValue can be defined both on the AreaChart, and on the Area.
// The value for the item takes precedence.
var baseValue = itemBaseValue !== null && itemBaseValue !== void 0 ? itemBaseValue : chartBaseValue;
if (isNumber(baseValue)) {
return baseValue;
}
var numericAxis = layout === 'horizontal' ? yAxis : xAxis;
// @ts-expect-error d3scale .domain() returns unknown, Math.max expects number
var domain = numericAxis.scale.domain();
if (numericAxis.type === 'number') {
var domainMax = Math.max(domain[0], domain[1]);
var domainMin = Math.min(domain[0], domain[1]);
if (baseValue === 'dataMin') {
return domainMin;
}
if (baseValue === 'dataMax') {
return domainMax;
}
return domainMax < 0 ? domainMax : Math.max(Math.min(domain[0], domain[1]), 0);
}
if (baseValue === 'dataMin') {
return domain[0];
}
if (baseValue === 'dataMax') {
return domain[1];
}
return domain[0];
};
export function computeArea(_ref8) {
var _ref8$areaSettings = _ref8.areaSettings,
connectNulls = _ref8$areaSettings.connectNulls,
itemBaseValue = _ref8$areaSettings.baseValue,
dataKey = _ref8$areaSettings.dataKey,
stackedData = _ref8.stackedData,
layout = _ref8.layout,
chartBaseValue = _ref8.chartBaseValue,
xAxis = _ref8.xAxis,
yAxis = _ref8.yAxis,
displayedData = _ref8.displayedData,
dataStartIndex = _ref8.dataStartIndex,
xAxisTicks = _ref8.xAxisTicks,
yAxisTicks = _ref8.yAxisTicks,
bandSize = _ref8.bandSize;
var hasStack = stackedData && stackedData.length;
var baseValue = getBaseValue(layout, chartBaseValue, itemBaseValue, xAxis, yAxis);
var isHorizontalLayout = layout === 'horizontal';
var isRange = false;
var points = displayedData.map((entry, index) => {
var _valueAsArray$, _valueAsArray, _xAxis$scale$map;
var valueAsArray;
if (hasStack) {
valueAsArray = stackedData[dataStartIndex + index];
} else {
var rawValue = getValueByDataKey(entry, dataKey);
if (!Array.isArray(rawValue)) {
valueAsArray = [baseValue, rawValue];
} else {
valueAsArray = rawValue;
isRange = true;
}
}
var value1 = (_valueAsArray$ = (_valueAsArray = valueAsArray) === null || _valueAsArray === void 0 ? void 0 : _valueAsArray[1]) !== null && _valueAsArray$ !== void 0 ? _valueAsArray$ : null;
var isBreakPoint = value1 == null || hasStack && !connectNulls && getValueByDataKey(entry, dataKey) == null;
if (isHorizontalLayout) {
var _yAxis$scale$map;
return {
x: getCateCoordinateOfLine({
axis: xAxis,
ticks: xAxisTicks,
bandSize,
entry,
index
}),
y: isBreakPoint ? null : (_yAxis$scale$map = yAxis.scale.map(value1)) !== null && _yAxis$scale$map !== void 0 ? _yAxis$scale$map : null,
value: valueAsArray,
payload: entry
};
}
return {
x: isBreakPoint ? null : (_xAxis$scale$map = xAxis.scale.map(value1)) !== null && _xAxis$scale$map !== void 0 ? _xAxis$scale$map : null,
y: getCateCoordinateOfLine({
axis: yAxis,
ticks: yAxisTicks,
bandSize,
entry,
index
}),
value: valueAsArray,
payload: entry
};
});
var baseLine;
if (hasStack || isRange) {
baseLine = points.map(entry => {
var _xAxis$scale$map2;
var x = Array.isArray(entry.value) ? entry.value[0] : null;
if (isHorizontalLayout) {
var _yAxis$scale$map2;
return {
x: entry.x,
y: x != null && entry.y != null ? (_yAxis$scale$map2 = yAxis.scale.map(x)) !== null && _yAxis$scale$map2 !== void 0 ? _yAxis$scale$map2 : null : null,
payload: entry.payload
};
}
return {
x: x != null ? (_xAxis$scale$map2 = xAxis.scale.map(x)) !== null && _xAxis$scale$map2 !== void 0 ? _xAxis$scale$map2 : null : null,
y: entry.y,
payload: entry.payload
};
});
} else {
baseLine = isHorizontalLayout ? yAxis.scale.map(baseValue) : xAxis.scale.map(baseValue);
}
return {
points,
baseLine: baseLine !== null && baseLine !== void 0 ? baseLine : 0,
isRange
};
}
function AreaFn(outsideProps) {
var props = resolveDefaultProps(outsideProps, defaultAreaProps);
var isPanorama = useIsPanorama();
// Report all props to Redux store first, before calling hooks, to avoid circular dependencies.
return /*#__PURE__*/React.createElement(RegisterGraphicalItemId, {
id: props.id,
type: "area"
}, id => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SetLegendPayload, {
legendPayload: computeLegendPayloadFromAreaData(props)
}), /*#__PURE__*/React.createElement(SetAreaTooltipEntrySettings, {
dataKey: props.dataKey,
data: props.data,
stroke: props.stroke,
strokeWidth: props.strokeWidth,
fill: props.fill,
name: props.name,
hide: props.hide,
unit: props.unit,
formatter: props.formatter,
tooltipType: props.tooltipType,
id: id
}), /*#__PURE__*/React.createElement(SetCartesianGraphicalItem, {
type: "area",
id: id,
data: props.data,
dataKey: props.dataKey,
xAxisId: props.xAxisId,
yAxisId: props.yAxisId,
zAxisId: 0,
stackId: getNormalizedStackId(props.stackId),
hide: props.hide,
barSize: undefined,
baseValue: props.baseValue,
isPanorama: isPanorama,
connectNulls: props.connectNulls
}), /*#__PURE__*/React.createElement(AreaImpl, _extends({}, props, {
id: id
}))));
}
/**
* @provides LabelListContext
* @consumes CartesianChartContext
*/
export var Area = /*#__PURE__*/React.memo(AreaFn, propsAreEqual);
// @ts-expect-error we need to set the displayName for debugging purposes
Area.displayName = 'Area';