UNPKG

1.78 kBTypeScriptView Raw
1/**
2 * @fileOverview Render a group of error bar
3 */
4import React, { SVGProps } from 'react';
5import { Props as XAxisProps } from './XAxis';
6import { Props as YAxisProps } from './YAxis';
7import { D3Scale, DataKey } from '../util/types';
8import { BarRectangleItem } from './Bar';
9import { LinePointItem } from './Line';
10import { ScatterPointItem } from './Scatter';
11export interface ErrorBarDataItem {
12 x: number;
13 y: number;
14 value: number;
15 errorVal?: number[] | number;
16}
17export type ErrorBarDataPointFormatter = (entry: BarRectangleItem | LinePointItem | ScatterPointItem, dataKey: DataKey<any>) => ErrorBarDataItem;
18interface InternalErrorBarProps {
19 xAxis?: Omit<XAxisProps, 'scale'> & {
20 scale: D3Scale<string | number>;
21 };
22 yAxis?: Omit<YAxisProps, 'scale'> & {
23 scale: D3Scale<string | number>;
24 };
25 data?: any[];
26 layout?: 'horizontal' | 'vertical';
27 dataPointFormatter?: ErrorBarDataPointFormatter;
28 /** The offset between central and the given coordinate, often set by <Bar/> */
29 offset?: number;
30}
31interface ErrorBarProps extends InternalErrorBarProps {
32 dataKey: DataKey<any>;
33 /** the width of the error bar ends */
34 width?: number;
35 /**
36 * Only used for ScatterChart with error bars in two directions.
37 * Only accepts a value of "x" or "y" and makes the error bars lie in that direction.
38 */
39 direction?: 'x' | 'y';
40}
41export type Props = SVGProps<SVGLineElement> & ErrorBarProps;
42export declare class ErrorBar extends React.Component<Props> {
43 static defaultProps: {
44 stroke: string;
45 strokeWidth: number;
46 width: number;
47 offset: number;
48 layout: string;
49 };
50 static displayName: string;
51 render(): React.JSX.Element;
52}
53export {};