recharts
Version:
React charts
44 lines (43 loc) • 2.37 kB
TypeScript
import type { RechartsFill } from '../fill/RechartsFill';
import { GraphicalItemStyle, RechartsTheme, Styles2D } from './RechartsTheme';
/**
* Theme styles with the `fill` as a plain color.
*/
export type ColorStyles2D = Omit<Styles2D, 'fill'> & {
fill?: string;
};
/**
* A theme entry of a graphical item with the `fill`, and the `fill` of its `active` styles, as plain colors.
*/
export type ColorGraphicalItemStyle = Omit<GraphicalItemStyle, 'fill' | 'active'> & {
fill?: string;
active?: ColorStyles2D;
};
/**
* Returns the fill object of a theme `fill`, or undefined if the `fill` is a color.
* @param fill the `fill` of a theme style
*/
export declare function getThemeFillObject(fill: string | RechartsFill | undefined): RechartsFill | undefined;
/**
* Returns the theme style with its fill objects replaced by their `color`,
* for everything that paints with a plain color.
* A fill object without `color` leaves no `fill`.
* A style without fill objects comes back as it is. Otherwise the result is a copy, and it is cached,
* so the same style always returns the same object. That keeps theme selectors stable.
* @param style theme style, for example an entry of `graphicalItems`, or `grid`
*/
export declare function withFillColor(style: GraphicalItemStyle): ColorGraphicalItemStyle;
export declare function withFillColor(style: GraphicalItemStyle | undefined): ColorGraphicalItemStyle | undefined;
/**
* Returns {@link withFillColor} of each theme entry. The result is cached, so the same entries always return
* the same array.
* @param graphicalItems the `graphicalItems` of a theme
*/
export declare function getColorGraphicalItems(graphicalItems: ReadonlyArray<GraphicalItemStyle>): ReadonlyArray<ColorGraphicalItemStyle>;
export declare function getColorGraphicalItems(graphicalItems: ReadonlyArray<GraphicalItemStyle> | undefined): ReadonlyArray<ColorGraphicalItemStyle> | undefined;
/**
* Returns the fill object of a theme slot, or undefined without a theme, or if the slot fills with a color.
* Components that draw fill objects paint with it when they have no `fill` of their own.
* @param themeSelector selects the theme slot, for example `theme => theme.grid`
*/
export declare function useThemeFillObject(themeSelector: (theme: RechartsTheme) => Pick<Styles2D, 'fill'> | undefined): RechartsFill | undefined;