recharts
Version:
React charts
26 lines • 991 B
JavaScript
import { useAppSelector } from '../state/hooks';
import { selectEffectiveDataKey } from '../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
*/
export function useEffectiveDataKey(_ref) {
var _useAppSelector;
var dataKey = _ref.dataKey,
xAxisId = _ref.xAxisId,
yAxisId = _ref.yAxisId,
angleAxisId = _ref.angleAxisId,
radiusAxisId = _ref.radiusAxisId;
return (_useAppSelector = useAppSelector(state => selectEffectiveDataKey(state, {
dataKey,
xAxisId,
yAxisId,
angleAxisId,
radiusAxisId
}))) !== null && _useAppSelector !== void 0 ? _useAppSelector : dataKey;
}