@octanejs/recharts 0.1.16 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/package.json +4 -4
  2. package/src/animation/CSSTransitionAnimate.tsrx +142 -0
  3. package/src/cartesian/Area.tsrx +1096 -0
  4. package/src/cartesian/Area.tsrx.d.ts +340 -0
  5. package/src/cartesian/AreaRevealShape.tsrx +202 -0
  6. package/src/cartesian/CartesianGrid.tsrx +643 -0
  7. package/src/cartesian/CartesianGrid.tsrx.d.ts +219 -0
  8. package/src/cartesian/ErrorBar.tsrx +322 -0
  9. package/src/cartesian/ErrorBar.tsrx.d.ts +131 -0
  10. package/src/cartesian/Funnel.tsrx +833 -0
  11. package/src/cartesian/Funnel.tsrx.d.ts +274 -0
  12. package/src/cartesian/ReferenceLine.tsrx +452 -0
  13. package/src/cartesian/ReferenceLine.tsrx.d.ts +178 -0
  14. package/src/cartesian/Scatter.tsrx +1076 -0
  15. package/src/cartesian/Scatter.tsrx.d.ts +351 -0
  16. package/src/cartesian/ZAxis.tsrx +148 -0
  17. package/src/cartesian/ZAxis.tsrx.d.ts +102 -0
  18. package/src/chart/AreaChart.tsrx +22 -0
  19. package/src/chart/AreaChart.tsrx.d.ts +12 -0
  20. package/src/chart/ComposedChart.tsrx +22 -0
  21. package/src/chart/ComposedChart.tsrx.d.ts +12 -0
  22. package/src/chart/FunnelChart.tsrx +22 -0
  23. package/src/chart/FunnelChart.tsrx.d.ts +12 -0
  24. package/src/chart/PieChart.tsrx +31 -0
  25. package/src/chart/PieChart.tsrx.d.ts +31 -0
  26. package/src/chart/PolarChart.tsrx +121 -0
  27. package/src/chart/RadarChart.tsrx +53 -0
  28. package/src/chart/RadarChart.tsrx.d.ts +31 -0
  29. package/src/chart/RadialBarChart.tsrx +31 -0
  30. package/src/chart/RadialBarChart.tsrx.d.ts +31 -0
  31. package/src/chart/Sankey.tsrx +1542 -0
  32. package/src/chart/Sankey.tsrx.d.ts +253 -0
  33. package/src/chart/ScatterChart.tsrx +22 -0
  34. package/src/chart/ScatterChart.tsrx.d.ts +12 -0
  35. package/src/chart/SunburstChart.tsrx +495 -0
  36. package/src/chart/SunburstChart.tsrx.d.ts +146 -0
  37. package/src/chart/types.ts +19 -0
  38. package/src/component/Cursor.tsrx +157 -0
  39. package/src/component/DefaultLegendContent.tsrx +288 -0
  40. package/src/component/DefaultLegendContent.tsrx.d.ts +125 -0
  41. package/src/component/DefaultTooltipContent.tsrx +215 -0
  42. package/src/component/DefaultTooltipContent.tsrx.d.ts +87 -0
  43. package/src/component/Legend.tsrx +302 -0
  44. package/src/component/Legend.tsrx.d.ts +88 -0
  45. package/src/component/ResponsiveContainer.ts +1 -22
  46. package/src/component/ResponsiveContainer.tsrx +171 -0
  47. package/src/component/ResponsiveContainer.tsrx.d.ts +81 -0
  48. package/src/component/Tooltip.tsrx +425 -0
  49. package/src/component/Tooltip.tsrx.d.ts +246 -0
  50. package/src/component/TooltipBoundingBox.tsrx +135 -0
  51. package/src/context/CellsContext.ts +12 -0
  52. package/src/context/legendPayloadContext.tsrx +11 -0
  53. package/src/context/useTooltipAxis.ts +20 -0
  54. package/src/index.d.ts +236 -0
  55. package/src/index.ts +67 -0
  56. package/src/polar/Pie.tsrx +1224 -0
  57. package/src/polar/Pie.tsrx.d.ts +436 -0
  58. package/src/polar/PolarAngleAxis.tsrx +554 -0
  59. package/src/polar/PolarAngleAxis.tsrx.d.ts +215 -0
  60. package/src/polar/PolarGrid.tsrx +317 -0
  61. package/src/polar/PolarGrid.tsrx.d.ts +117 -0
  62. package/src/polar/PolarRadiusAxis.tsrx +463 -0
  63. package/src/polar/PolarRadiusAxis.tsrx.d.ts +209 -0
  64. package/src/polar/Radar.tsrx +696 -0
  65. package/src/polar/Radar.tsrx.d.ts +215 -0
  66. package/src/polar/RadialBar.tsrx +887 -0
  67. package/src/polar/RadialBar.tsrx.d.ts +340 -0
  68. package/src/state/ReportPolarOptions.tsrx +11 -0
  69. package/src/state/selectors/areaSelectors.ts +257 -0
  70. package/src/state/selectors/funnelSelectors.ts +86 -0
  71. package/src/state/selectors/pieSelectors.ts +134 -0
  72. package/src/state/selectors/polarGridSelectors.ts +43 -0
  73. package/src/state/selectors/polarScaleSelectors.ts +159 -0
  74. package/src/state/selectors/polarSelectors.ts +198 -0
  75. package/src/state/selectors/radarSelectors.ts +228 -0
  76. package/src/state/selectors/radialBarSelectors.ts +511 -0
  77. package/src/state/selectors/scatterSelectors.ts +168 -0
  78. package/src/util/FunnelUtils.tsrx +19 -0
  79. package/src/util/RadialBarUtils.tsrx +29 -0
  80. package/src/util/ScatterUtils.tsrx +34 -0
  81. package/src/util/cursor/getCursorPoints.ts +45 -0
  82. package/src/util/cursor/getCursorRectangle.ts +28 -0
  83. package/src/util/cursor/getRadialCursorPoints.ts +31 -0
  84. package/src/util/payload/getUniqPayload.ts +28 -0
  85. package/src/util/scale/CartesianScaleHelper.ts +71 -0
  86. package/src/util/tooltip/translate.ts +168 -0
  87. package/src/util/types.ts +3 -0
  88. package/src/util/useElementOffset.ts +147 -0
@@ -0,0 +1,22 @@
1
+ import { arrayTooltipSearcher } from '../state/optionsSlice';
2
+ import { CartesianChart } from './CartesianChart.tsrx';
3
+ import { CartesianChartProps, TooltipEventType } from '../util/types';
4
+
5
+ const allowedTooltipTypes: ReadonlyArray<TooltipEventType> = ['item'];
6
+
7
+ /**
8
+ * @consumes ResponsiveContainerContext
9
+ * @provides CartesianViewBoxContext
10
+ * @provides CartesianChartContext
11
+ */
12
+ export function FunnelChart(props: CartesianChartProps<unknown>) {
13
+ const { ref, ...rest } = props;
14
+ return <CartesianChart
15
+ chartName="FunnelChart"
16
+ defaultTooltipEventType="item"
17
+ validateTooltipEventTypes={allowedTooltipTypes}
18
+ tooltipPayloadSearcher={arrayTooltipSearcher}
19
+ categoricalChartProps={rest}
20
+ ref={ref}
21
+ />;
22
+ }
@@ -0,0 +1,12 @@
1
+ import * as React from 'octane';
2
+ import { CartesianChartProps } from '../util/types';
3
+ /**
4
+ * @consumes ResponsiveContainerContext
5
+ * @provides CartesianViewBoxContext
6
+ * @provides CartesianChartContext
7
+ */
8
+ export declare const FunnelChart: <DataPointType = any>(
9
+ props: CartesianChartProps<DataPointType> & {
10
+ ref?: React.Ref<SVGSVGElement>;
11
+ },
12
+ ) => React.ReactElement;
@@ -0,0 +1,31 @@
1
+ import { arrayTooltipSearcher } from '../state/optionsSlice';
2
+ import { defaultPolarChartProps, PolarChart } from './PolarChart';
3
+ import { PolarChartProps, TooltipEventType } from '../util/types';
4
+ import { resolveDefaultProps } from '../util/resolveDefaultProps';
5
+
6
+ const allowedTooltipTypes: ReadonlyArray<TooltipEventType> = ['item'];
7
+
8
+ export const defaultPieChartProps = {
9
+ ...defaultPolarChartProps,
10
+ layout: 'centric',
11
+ startAngle: 0,
12
+ endAngle: 360,
13
+ } as const satisfies Partial<PolarChartProps<never>>;
14
+
15
+ /**
16
+ * @consumes ResponsiveContainerContext
17
+ * @provides PolarViewBoxContext
18
+ * @provides PolarChartContext
19
+ */
20
+ export function PieChart(props: PolarChartProps<unknown>) {
21
+ const { ref, ...rest } = props;
22
+ const propsWithDefaults = resolveDefaultProps(rest, defaultPieChartProps);
23
+ return <PolarChart
24
+ chartName="PieChart"
25
+ defaultTooltipEventType="item"
26
+ validateTooltipEventTypes={allowedTooltipTypes}
27
+ tooltipPayloadSearcher={arrayTooltipSearcher}
28
+ categoricalChartProps={propsWithDefaults}
29
+ ref={ref}
30
+ />;
31
+ }
@@ -0,0 +1,31 @@
1
+ import * as React from 'octane';
2
+ import { PolarChartProps } from '../util/types';
3
+ export declare const defaultPieChartProps: {
4
+ readonly layout: 'centric';
5
+ readonly startAngle: 0;
6
+ readonly endAngle: 360;
7
+ readonly throttleDelay: number | 'raf';
8
+ readonly throttledEvents: ReadonlyArray<keyof GlobalEventHandlersEventMap> | 'all';
9
+ readonly accessibilityLayer: true;
10
+ readonly stackOffset: 'none';
11
+ readonly barCategoryGap: '10%';
12
+ readonly barGap: 4;
13
+ readonly margin: import('..').Margin;
14
+ readonly reverseStackOrder: false;
15
+ readonly syncMethod: 'index';
16
+ readonly responsive: false;
17
+ readonly cx: '50%';
18
+ readonly cy: '50%';
19
+ readonly innerRadius: 0;
20
+ readonly outerRadius: '80%';
21
+ };
22
+ /**
23
+ * @consumes ResponsiveContainerContext
24
+ * @provides PolarViewBoxContext
25
+ * @provides PolarChartContext
26
+ */
27
+ export declare const PieChart: <DataPointType = any>(
28
+ props: PolarChartProps<DataPointType> & {
29
+ ref?: React.Ref<SVGSVGElement>;
30
+ },
31
+ ) => React.ReactElement;
@@ -0,0 +1,121 @@
1
+ import { ChartOptions } from '../state/optionsSlice';
2
+ import { RechartsStoreProvider } from '../state/RechartsStoreProvider';
3
+ import { ChartDataContextProvider } from '../context/chartDataContext';
4
+ import { ReportMainChartProps } from '../state/ReportMainChartProps';
5
+ import { ReportChartProps } from '../state/ReportChartProps';
6
+ import { ReportEventSettings } from '../state/ReportEventSettings';
7
+ import { ReportPolarOptions } from '../state/ReportPolarOptions';
8
+ import { Margin, PolarChartProps, TooltipEventType } from '../util/types';
9
+ import { TooltipPayloadSearcher } from '../state/tooltipSlice';
10
+ import { CategoricalChart } from './CategoricalChart';
11
+ import { resolveDefaultProps } from '../util/resolveDefaultProps';
12
+ import { initialEventSettingsState } from '../state/eventSettingsSlice';
13
+
14
+ const defaultMargin: Margin = { top: 5, right: 5, bottom: 5, left: 5 };
15
+
16
+ /**
17
+ * These default props are the same for all PolarChart components.
18
+ */
19
+ export const defaultPolarChartProps = {
20
+ accessibilityLayer: true,
21
+ stackOffset: 'none',
22
+ barCategoryGap: '10%',
23
+ barGap: 4,
24
+ margin: defaultMargin,
25
+ reverseStackOrder: false,
26
+ syncMethod: 'index',
27
+ layout: 'radial',
28
+ responsive: false,
29
+ cx: '50%',
30
+ cy: '50%',
31
+ innerRadius: 0,
32
+ outerRadius: '80%',
33
+ ...initialEventSettingsState,
34
+ } as const satisfies Partial<PolarChartProps<never>>;
35
+
36
+ /**
37
+ * These props are required for the PolarChart to function correctly.
38
+ * Users usually would not need to specify these explicitly,
39
+ * because the convenience components like PieChart, RadarChart, etc.
40
+ * will provide these defaults.
41
+ * We can't have the defaults in this file because each of those convenience components
42
+ * have their own opinions about what they should be.
43
+ */
44
+ type PolarChartPropsWithDefaults =
45
+ PolarChartProps & {
46
+ cx: NonNullable<PolarChartProps['cx']>;
47
+ cy: NonNullable<PolarChartProps['cy']>;
48
+ startAngle: NonNullable<PolarChartProps['startAngle']>;
49
+ endAngle: NonNullable<PolarChartProps['endAngle']>;
50
+ innerRadius: NonNullable<PolarChartProps['innerRadius']>;
51
+ outerRadius: NonNullable<PolarChartProps['outerRadius']>;
52
+ };
53
+
54
+ /**
55
+ * These are one-time, immutable options that decide the chart's behavior.
56
+ * Users who wish to call CartesianChart may decide to pass these options explicitly,
57
+ * but usually we would expect that they use one of the convenience components like PieChart, RadarChart, etc.
58
+ */
59
+ export type PolarChartOptions = {
60
+ chartName: string;
61
+ defaultTooltipEventType: TooltipEventType;
62
+ validateTooltipEventTypes: ReadonlyArray<TooltipEventType>;
63
+ tooltipPayloadSearcher: TooltipPayloadSearcher;
64
+ categoricalChartProps: PolarChartPropsWithDefaults;
65
+ };
66
+
67
+ export function PolarChart(props: PolarChartOptions & { ref?: unknown }) {
68
+ const { ref } = props;
69
+ const polarChartProps = resolveDefaultProps(props.categoricalChartProps, defaultPolarChartProps);
70
+
71
+ const { layout, ...otherCategoricalProps } = polarChartProps;
72
+
73
+ const {
74
+ chartName,
75
+ defaultTooltipEventType,
76
+ validateTooltipEventTypes,
77
+ tooltipPayloadSearcher,
78
+ } = props;
79
+
80
+ const options: ChartOptions = {
81
+ chartName,
82
+ defaultTooltipEventType,
83
+ validateTooltipEventTypes,
84
+ tooltipPayloadSearcher,
85
+ eventEmitter: undefined,
86
+ };
87
+
88
+ return <RechartsStoreProvider
89
+ preloadedState={{ options }}
90
+ reduxStoreName={polarChartProps.id ?? chartName}
91
+ >
92
+ <ChartDataContextProvider chartData={polarChartProps.data} />
93
+ <ReportMainChartProps layout={layout} margin={polarChartProps.margin} />
94
+ <ReportEventSettings
95
+ throttleDelay={polarChartProps.throttleDelay}
96
+ throttledEvents={polarChartProps.throttledEvents}
97
+ />
98
+ <ReportChartProps
99
+ baseValue={undefined}
100
+ accessibilityLayer={polarChartProps.accessibilityLayer}
101
+ barCategoryGap={polarChartProps.barCategoryGap}
102
+ maxBarSize={polarChartProps.maxBarSize}
103
+ stackOffset={polarChartProps.stackOffset}
104
+ barGap={polarChartProps.barGap}
105
+ barSize={polarChartProps.barSize}
106
+ syncId={polarChartProps.syncId}
107
+ syncMethod={polarChartProps.syncMethod}
108
+ className={polarChartProps.className}
109
+ reverseStackOrder={polarChartProps.reverseStackOrder}
110
+ />
111
+ <ReportPolarOptions
112
+ cx={polarChartProps.cx}
113
+ cy={polarChartProps.cy}
114
+ startAngle={polarChartProps.startAngle}
115
+ endAngle={polarChartProps.endAngle}
116
+ innerRadius={polarChartProps.innerRadius}
117
+ outerRadius={polarChartProps.outerRadius}
118
+ />
119
+ <CategoricalChart {...otherCategoricalProps} ref={ref} />
120
+ </RechartsStoreProvider>;
121
+ }
@@ -0,0 +1,53 @@
1
+ import { arrayTooltipSearcher } from '../state/optionsSlice';
2
+ import { PolarChartProps, PolarLayout, TooltipEventType } from '../util/types';
3
+ import { resolveDefaultProps } from '../util/resolveDefaultProps';
4
+ import { defaultPolarChartProps, PolarChart } from './PolarChart';
5
+
6
+ const allowedTooltipTypes: ReadonlyArray<TooltipEventType> = ['axis'];
7
+
8
+ export const defaultRadarChartProps = {
9
+ ...defaultPolarChartProps,
10
+ layout: 'centric',
11
+ startAngle: 90,
12
+ endAngle: -270,
13
+ } as const satisfies Partial<PolarChartProps<never>>;
14
+
15
+ type RadarChartProps<DataPointType> =
16
+ Omit<PolarChartProps<DataPointType>, 'layout' | 'startAngle' | 'endAngle'> & {
17
+ /**
18
+ * The layout of chart defines the orientation of axes, graphical items, and tooltip.
19
+ *
20
+ * @defaultValue centric
21
+ */
22
+ layout?: PolarLayout;
23
+ /**
24
+ * Angle in degrees from which the chart should start.
25
+ * @defaultValue 90
26
+ *
27
+ */
28
+ startAngle?: number;
29
+ /**
30
+ * Angle, in degrees, at which the chart should end.
31
+ *
32
+ * @defaultValue -270
33
+ */
34
+ endAngle?: number;
35
+ };
36
+
37
+ /**
38
+ * @consumes ResponsiveContainerContext
39
+ * @provides PolarViewBoxContext
40
+ * @provides PolarChartContext
41
+ */
42
+ export function RadarChart(props: RadarChartProps<unknown>) {
43
+ const { ref, ...rest } = props;
44
+ const propsWithDefaults = resolveDefaultProps(rest, defaultRadarChartProps);
45
+ return <PolarChart
46
+ chartName="RadarChart"
47
+ defaultTooltipEventType="axis"
48
+ validateTooltipEventTypes={allowedTooltipTypes}
49
+ tooltipPayloadSearcher={arrayTooltipSearcher}
50
+ categoricalChartProps={propsWithDefaults}
51
+ ref={ref}
52
+ />;
53
+ }
@@ -0,0 +1,31 @@
1
+ import * as React from 'octane';
2
+ import { PolarChartProps } from '../util/types';
3
+ export declare const defaultRadarChartProps: {
4
+ readonly layout: 'centric';
5
+ readonly startAngle: 90;
6
+ readonly endAngle: -270;
7
+ readonly throttleDelay: number | 'raf';
8
+ readonly throttledEvents: ReadonlyArray<keyof GlobalEventHandlersEventMap> | 'all';
9
+ readonly accessibilityLayer: true;
10
+ readonly stackOffset: 'none';
11
+ readonly barCategoryGap: '10%';
12
+ readonly barGap: 4;
13
+ readonly margin: import('..').Margin;
14
+ readonly reverseStackOrder: false;
15
+ readonly syncMethod: 'index';
16
+ readonly responsive: false;
17
+ readonly cx: '50%';
18
+ readonly cy: '50%';
19
+ readonly innerRadius: 0;
20
+ readonly outerRadius: '80%';
21
+ };
22
+ /**
23
+ * @consumes ResponsiveContainerContext
24
+ * @provides PolarViewBoxContext
25
+ * @provides PolarChartContext
26
+ */
27
+ export declare const RadarChart: <DataPointType = any>(
28
+ props: PolarChartProps<DataPointType> & {
29
+ ref?: React.Ref<SVGSVGElement>;
30
+ },
31
+ ) => React.ReactElement;
@@ -0,0 +1,31 @@
1
+ import { arrayTooltipSearcher } from '../state/optionsSlice';
2
+ import { PolarChartProps, TooltipEventType } from '../util/types';
3
+ import { resolveDefaultProps } from '../util/resolveDefaultProps';
4
+ import { defaultPolarChartProps, PolarChart } from './PolarChart';
5
+
6
+ const allowedTooltipTypes: ReadonlyArray<TooltipEventType> = ['axis', 'item'];
7
+
8
+ export const defaultRadialBarChartProps = {
9
+ ...defaultPolarChartProps,
10
+ layout: 'radial',
11
+ startAngle: 0,
12
+ endAngle: 360,
13
+ } as const satisfies Partial<PolarChartProps<never>>;
14
+
15
+ /**
16
+ * @consumes ResponsiveContainerContext
17
+ * @provides PolarViewBoxContext
18
+ * @provides PolarChartContext
19
+ */
20
+ export function RadialBarChart(props: PolarChartProps<unknown>) {
21
+ const { ref, ...rest } = props;
22
+ const propsWithDefaults = resolveDefaultProps(rest, defaultRadialBarChartProps);
23
+ return <PolarChart
24
+ chartName="RadialBarChart"
25
+ defaultTooltipEventType="axis"
26
+ validateTooltipEventTypes={allowedTooltipTypes}
27
+ tooltipPayloadSearcher={arrayTooltipSearcher}
28
+ categoricalChartProps={propsWithDefaults}
29
+ ref={ref}
30
+ />;
31
+ }
@@ -0,0 +1,31 @@
1
+ import * as React from 'octane';
2
+ import { PolarChartProps } from '../util/types';
3
+ export declare const defaultRadialBarChartProps: {
4
+ readonly layout: 'radial';
5
+ readonly startAngle: 0;
6
+ readonly endAngle: 360;
7
+ readonly throttleDelay: number | 'raf';
8
+ readonly throttledEvents: ReadonlyArray<keyof GlobalEventHandlersEventMap> | 'all';
9
+ readonly accessibilityLayer: true;
10
+ readonly stackOffset: 'none';
11
+ readonly barCategoryGap: '10%';
12
+ readonly barGap: 4;
13
+ readonly margin: import('..').Margin;
14
+ readonly reverseStackOrder: false;
15
+ readonly syncMethod: 'index';
16
+ readonly responsive: false;
17
+ readonly cx: '50%';
18
+ readonly cy: '50%';
19
+ readonly innerRadius: 0;
20
+ readonly outerRadius: '80%';
21
+ };
22
+ /**
23
+ * @consumes ResponsiveContainerContext
24
+ * @provides PolarViewBoxContext
25
+ * @provides PolarChartContext
26
+ */
27
+ export declare const RadialBarChart: <DataPointType = any>(
28
+ props: PolarChartProps<DataPointType> & {
29
+ ref?: React.Ref<SVGSVGElement>;
30
+ },
31
+ ) => React.ReactElement;