recharts
Version:
React charts
56 lines (55 loc) • 2.63 kB
TypeScript
import { DataKey, LayoutType } from '../../util/types';
import { RechartsRootState } from '../store';
import { AxisId } from '../cartesianAxisSlice';
import { AllAxisTypes } from './selectTooltipAxisType';
/**
* The parts of a graphical item that decide its effective dataKey.
* Cartesian items have xAxisId and yAxisId, polar items have angleAxisId and radiusAxisId.
*/
export type GraphicalItemDataKeySource = {
dataKey?: DataKey<any> | undefined;
xAxisId?: AxisId;
yAxisId?: AxisId;
angleAxisId?: AxisId;
radiusAxisId?: AxisId;
};
/**
* Value axis is the axis where graphical items display their value,
* as opposed to the categorical axis where they display the category (or name, or index).
*
* The chart layout alone decides which axis that is.
* The axis `type` prop has no say in this: an axis in the value position is the value axis
* even if it has `type="category"`, and the other axis is not, even if it has `type="number"`.
*
* @param layout chart layout
* @param axisType kind of the axis
* @returns true if graphical items in this layout show their value on this axis
*/
export declare function isValueAxis(layout: LayoutType | undefined, axisType: AllAxisTypes): boolean;
/**
* Decides which dataKey reads the value of a graphical item on the given axis.
*
* On the value axis the graphical item wins, and the axis is the fallback.
* On all other axes the axis wins, and the graphical item is the fallback.
*
* @param itemDataKey dataKey of the graphical item
* @param axisDataKey dataKey of the axis
* @param layout chart layout
* @param axisType kind of the axis
* @returns dataKey to use when reading the item value on this axis
*/
export declare function getDataKeyOnAxis(itemDataKey: DataKey<any> | undefined, axisDataKey: DataKey<any> | undefined, layout: LayoutType | undefined, axisType: AllAxisTypes): DataKey<any> | undefined;
/**
* Returns the effective dataKey of a graphical item:
* its own dataKey if it has one, otherwise the dataKey of its value axis.
*
* @param state Recharts root state
* @param item graphical item props or settings
* @returns effective dataKey, or undefined if neither the item nor its value axis define one
*/
export declare function selectEffectiveDataKey(state: RechartsRootState, item: GraphicalItemDataKeySource): DataKey<any> | undefined;
/**
* Effective dataKeys of all graphical items in the chart, including the hidden ones.
* Items that do not have any effective dataKey are skipped.
*/
export declare const selectAllEffectiveGraphicalItemDataKeys: (state: RechartsRootState) => ReadonlyArray<DataKey<any>>;