| 1 | import { AxisId } from './state/cartesianAxisSlice';
|
|---|
| 2 | import { BaseAxisWithScale } from './state/selectors/axisSelectors';
|
|---|
| 3 | import { ChartOffset, PlotArea } from './types';
|
|---|
| 4 | import { CategoricalDomain, Coordinate, NumberDomain } from './util/types';
|
|---|
| 5 | import { ActiveLabel } from './synchronisation/types';
|
|---|
| 6 | export declare const useXAxis: (xAxisId: AxisId) => BaseAxisWithScale | undefined;
|
|---|
| 7 | export declare const useYAxis: (yAxisId: AxisId) => BaseAxisWithScale | undefined;
|
|---|
| 8 | /**
|
|---|
| 9 | * Returns the active tooltip label. The label is one of the values from the chart data,
|
|---|
| 10 | * and is used to display in the tooltip content.
|
|---|
| 11 | *
|
|---|
| 12 | * Returns undefined if there is no active user interaction or if used outside a chart context
|
|---|
| 13 | *
|
|---|
| 14 | * @returns ActiveLabel
|
|---|
| 15 | */
|
|---|
| 16 | export declare const useActiveTooltipLabel: () => ActiveLabel;
|
|---|
| 17 | /**
|
|---|
| 18 | * Returns the offset of the chart in pixels.
|
|---|
| 19 | *
|
|---|
| 20 | * Offset defines the blank space between the chart and the plot area.
|
|---|
| 21 | * This blank space is occupied by supporting elements like axes, legends, and brushes.
|
|---|
| 22 | *
|
|---|
| 23 | * The offset includes:
|
|---|
| 24 | *
|
|---|
| 25 | * - Margins
|
|---|
| 26 | * - Width and height of the axes
|
|---|
| 27 | * - Width and height of the legend
|
|---|
| 28 | * - Brush height
|
|---|
| 29 | *
|
|---|
| 30 | * If you are interested in the margin alone, use {@link useMargin} instead.
|
|---|
| 31 | *
|
|---|
| 32 | * The offset is independent of charts position on the page, meaning it does not change as the chart is scrolled or resized.
|
|---|
| 33 | *
|
|---|
| 34 | * It is also independent of the scale and zoom, meaning that as the user zooms in and out,
|
|---|
| 35 | * the numbers will not change as the chart gets visually larger or smaller.
|
|---|
| 36 | *
|
|---|
| 37 | * This hook must be used within a chart context (inside a `<LineChart>`, `<BarChart>`, etc.).
|
|---|
| 38 | * This hook returns `undefined` if used outside a chart context.
|
|---|
| 39 | *
|
|---|
| 40 | * @returns Offset of the chart in pixels, or undefined if used outside a chart context.
|
|---|
| 41 | */
|
|---|
| 42 | export declare const useOffset: () => ChartOffset | undefined;
|
|---|
| 43 | /**
|
|---|
| 44 | * Plot area is the area where the actual chart data is rendered.
|
|---|
| 45 | * This means: bars, lines, scatter points, etc.
|
|---|
| 46 | *
|
|---|
| 47 | * The plot area is calculated based on the chart dimensions and the offset.
|
|---|
| 48 | *
|
|---|
| 49 | * Plot area `width` and `height` are the dimensions in pixels;
|
|---|
| 50 | * `x` and `y` are the coordinates of the top-left corner of the plot area relative to the chart container.
|
|---|
| 51 | *
|
|---|
| 52 | * They are also independent of the scale and zoom, meaning that as the user zooms in and out,
|
|---|
| 53 | * the plot area dimensions will not change as the chart gets visually larger or smaller.
|
|---|
| 54 | *
|
|---|
| 55 | * This hook must be used within a chart context (inside a `<LineChart>`, `<BarChart>`, etc.).
|
|---|
| 56 | * This hook returns `undefined` if used outside a chart context.
|
|---|
| 57 | *
|
|---|
| 58 | * @returns Plot area of the chart in pixels, or undefined if used outside a chart context.
|
|---|
| 59 | */
|
|---|
| 60 | export declare const usePlotArea: () => PlotArea | undefined;
|
|---|
| 61 | /**
|
|---|
| 62 | * Returns the currently active data points being displayed in the Tooltip.
|
|---|
| 63 | * Active means that it is currently visible; this hook will return `undefined` if there is no current interaction.
|
|---|
| 64 | *
|
|---|
| 65 | * This follows the `<Tooltip />` props, if the Tooltip element is present in the chart.
|
|---|
| 66 | * If there is no `<Tooltip />` then this hook will follow the default Tooltip props.
|
|---|
| 67 | *
|
|---|
| 68 | * Data point is whatever you pass as an input to the chart using the `data={}` prop.
|
|---|
| 69 | *
|
|---|
| 70 | * This returns an array because a chart can have multiple graphical items in it (multiple Lines for example)
|
|---|
| 71 | * and tooltip with `shared={true}` will display all items at the same time.
|
|---|
| 72 | *
|
|---|
| 73 | * Returns undefined when used outside a chart context.
|
|---|
| 74 | *
|
|---|
| 75 | * @returns Data points that are currently visible in a Tooltip
|
|---|
| 76 | */
|
|---|
| 77 | export declare const useActiveTooltipDataPoints: <T = unknown>() => ReadonlyArray<T> | undefined;
|
|---|
| 78 | /**
|
|---|
| 79 | * Returns the calculated domain of an X-axis.
|
|---|
| 80 | *
|
|---|
| 81 | * The domain can be numerical: `[min, max]`, or categorical: `['a', 'b', 'c']`.
|
|---|
| 82 | *
|
|---|
| 83 | * The type of the domain is defined by the `type` prop of the XAxis.
|
|---|
| 84 | *
|
|---|
| 85 | * The values of the domain are calculated based on the data and the `dataKey` of the axis.
|
|---|
| 86 | *
|
|---|
| 87 | * If the chart has a Brush, the domain will be filtered to the brushed indexes if the hook is used outside a Brush context,
|
|---|
| 88 | * and the full domain will be returned if the hook is used inside a Brush context.
|
|---|
| 89 | *
|
|---|
| 90 | * @param xAxisId The `xAxisId` of the X-axis. Defaults to `0` if not provided.
|
|---|
| 91 | * @returns The domain of the X-axis, or `undefined` if it cannot be calculated or if used outside a chart context.
|
|---|
| 92 | */
|
|---|
| 93 | export declare const useXAxisDomain: (xAxisId?: AxisId) => NumberDomain | CategoricalDomain | undefined;
|
|---|
| 94 | /**
|
|---|
| 95 | * Returns the calculated domain of a Y-axis.
|
|---|
| 96 | *
|
|---|
| 97 | * The domain can be numerical: `[min, max]`, or categorical: `['a', 'b', 'c']`.
|
|---|
| 98 | *
|
|---|
| 99 | * The type of the domain is defined by the `type` prop of the YAxis.
|
|---|
| 100 | *
|
|---|
| 101 | * The values of the domain are calculated based on the data and the `dataKey` of the axis.
|
|---|
| 102 | *
|
|---|
| 103 | * Does not interact with Brushes, as Y-axes do not support brushing.
|
|---|
| 104 | *
|
|---|
| 105 | * @param yAxisId The `yAxisId` of the Y-axis. Defaults to `0` if not provided.
|
|---|
| 106 | * @returns The domain of the Y-axis, or `undefined` if it cannot be calculated or if used outside a chart context.
|
|---|
| 107 | */
|
|---|
| 108 | export declare const useYAxisDomain: (yAxisId?: AxisId) => NumberDomain | CategoricalDomain | undefined;
|
|---|
| 109 | /**
|
|---|
| 110 | * Returns true if the {@link Tooltip} is currently active (visible).
|
|---|
| 111 | *
|
|---|
| 112 | * Returns false if the Tooltip is not active or if used outside a chart context.
|
|---|
| 113 | *
|
|---|
| 114 | * Recharts only allows one Tooltip per chart, so this hook does not take any parameters.
|
|---|
| 115 | * Weird things may happen if you have multiple Tooltip components in the same chart so please don't do that.
|
|---|
| 116 | *
|
|---|
| 117 | * @returns {boolean} True if the Tooltip is active, false otherwise.
|
|---|
| 118 | * @since 3.7
|
|---|
| 119 | */
|
|---|
| 120 | export declare const useIsTooltipActive: () => boolean;
|
|---|
| 121 | /**
|
|---|
| 122 | * Returns the Cartesian `x` + `y` coordinates of the active {@link Tooltip}.
|
|---|
| 123 | *
|
|---|
| 124 | * Returns undefined if there is no active user interaction or if used outside a chart context.
|
|---|
| 125 | *
|
|---|
| 126 | * Recharts only allows one Tooltip per chart, so this hook does not take any parameters.
|
|---|
| 127 | * Weird things may happen if you have multiple Tooltip components in the same chart so please don't do that.
|
|---|
| 128 | *
|
|---|
| 129 | * @returns {Coordinate | undefined} The coordinate of the active Tooltip, or undefined.
|
|---|
| 130 | * @since 3.7
|
|---|
| 131 | */
|
|---|
| 132 | export declare const useActiveTooltipCoordinate: () => Coordinate | undefined;
|
|---|