๐Ÿ“ฆ mui / mui-x

๐Ÿ“„ useChartCartesianAxisLayout.selectors.ts ยท 28 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28import { type UseChartCartesianAxisSignature } from './useChartCartesianAxis.types';
import { type DefaultedXAxis, type DefaultedYAxis } from '../../../../models/axis';
import { type ChartState } from '../../models/chart';

export const selectorChartCartesianAxisState = (
  state: ChartState<[], [UseChartCartesianAxisSignature]>,
) => state.cartesianAxis;

export type SelectorChartRawXAxisType = <
  State extends ChartState<[], [UseChartCartesianAxisSignature]>,
>(
  state: State,
) => DefaultedXAxis[] | undefined;

export const selectorChartRawXAxis: SelectorChartRawXAxisType = (state) => state.cartesianAxis?.x;

export type SelectorChartRawYAxisType = <
  State extends ChartState<[], [UseChartCartesianAxisSignature]>,
>(
  state: State,
) => DefaultedYAxis[] | undefined;

export const selectorChartRawYAxis: SelectorChartRawYAxisType = (state) => state.cartesianAxis?.y;

export const selectorChartCartesianAxesGap = (
  state: ChartState<[], [UseChartCartesianAxisSignature]>,
) => state.cartesianAxis?.axesGap ?? 0;