recharts
Version:
React charts
88 lines (87 loc) • 3.51 kB
TypeScript
/**
* @fileOverview Polygon
*/
import * as React from 'react';
import { SVGProps } from 'react';
import { RechartsFill } from '../fill/RechartsFill';
import { Coordinate } from '../util/types';
interface PolygonProps {
/**
* The fill of the polygon. Either a color string, or a {@link RechartsFill} object with an SVG definition,
* such as a pattern or a gradient. Recharts renders the definition with a unique ID.
* Set the `color` of the fill object: there is no theme color to fall back to.
*
* @since 3.11
* @example <Polygon fill={{ color: 'blue', definition: pattern(patterns.diagonal) }} />
*/
fill?: string | RechartsFill;
/**
* The SVG element's class name.
*/
className?: string;
/**
* The coordinates of all the vertexes of the polygon, like an array of objects with x and y coordinates.
*/
points?: ReadonlyArray<Coordinate>;
/**
* An optional second set of coordinates. When provided, Polygon fills the
* area enclosed between `points` and `baseLinePoints` similar to a data
* line and its baseline. If `stroke` is set (and isn't `"none"`), the
* outline of `points` and of `baseLinePoints` are also each stroked
* separately. Used e.g. by Radar in "range" mode to draw a min/max band.
*/
baseLinePoints?: ReadonlyArray<Coordinate>;
/**
* Whether to connect the curve across null points.
*/
connectNulls?: boolean;
/**
* The customized event handler of click on the polygon
*/
onClick?: (e: React.MouseEvent<SVGPolygonElement, MouseEvent>) => void;
/**
* The customized event handler of mousedown on the polygon
*/
onMouseDown?: (e: React.MouseEvent<SVGPolygonElement, MouseEvent>) => void;
/**
* The customized event handler of mouseup on the polygon
*/
onMouseUp?: (e: React.MouseEvent<SVGPolygonElement, MouseEvent>) => void;
/**
* The customized event handler of mousemove on the polygon
*/
onMouseMove?: (e: React.MouseEvent<SVGPolygonElement, MouseEvent>) => void;
/**
* The customized event handler of mouseover on the polygon
*/
onMouseOver?: (e: React.MouseEvent<SVGPolygonElement, MouseEvent>) => void;
/**
* The customized event handler of mouseout on the polygon
*/
onMouseOut?: (e: React.MouseEvent<SVGPolygonElement, MouseEvent>) => void;
/**
* The customized event handler of mouseenter on the polygon
*/
onMouseEnter?: (e: React.MouseEvent<SVGPolygonElement, MouseEvent>) => void;
/**
* The customized event handler of mouseleave on the polygon
*/
onMouseLeave?: (e: React.MouseEvent<SVGPolygonElement, MouseEvent>) => void;
}
/**
* @public
*/
export type Props = Omit<SVGProps<SVGPolygonElement>, 'points' | 'fill'> & PolygonProps;
/**
* Renders a polygon shape from an array of x/y coordinates, closing the
* outline into a filled shape by default. If the given points contain a
* gap (an invalid or missing coordinate) and `connectNulls` is not set,
* the outline is split into separate, unclosed subpaths around that gap
* instead of forming a single closed shape. Used internally by polar
* components such as Radar and PolarGrid to draw chart shapes. Accepts
* standard SVG presentation attributes (e.g. `stroke`, `fill`,
* `strokeWidth`) for styling, since it wraps a native SVG path element.
* @public
*/
export declare const Polygon: (props: Props) => React.JSX.Element;
export {};