recharts
Version:
React charts
32 lines (31 loc) • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useEffectiveDataKey = useEffectiveDataKey;
var _hooks = require("../state/hooks");
var _effectiveDataKeySelectors = require("../state/selectors/effectiveDataKeySelectors");
/**
* Returns the effective dataKey of a graphical item:
* its own dataKey if it has one, otherwise the dataKey of its value axis.
*
* Returns the item's own dataKey when used outside a chart context.
*
* @param item dataKey and axis IDs of the graphical item, with defaults already applied
* @returns effective dataKey, or undefined if neither the item nor its value axis define one
*/
function useEffectiveDataKey(_ref) {
var _useAppSelector;
var dataKey = _ref.dataKey,
xAxisId = _ref.xAxisId,
yAxisId = _ref.yAxisId,
angleAxisId = _ref.angleAxisId,
radiusAxisId = _ref.radiusAxisId;
return (_useAppSelector = (0, _hooks.useAppSelector)(state => (0, _effectiveDataKeySelectors.selectEffectiveDataKey)(state, {
dataKey,
xAxisId,
yAxisId,
angleAxisId,
radiusAxisId
}))) !== null && _useAppSelector !== void 0 ? _useAppSelector : dataKey;
}