victory-chart 36.7.0 → 36.8.2

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.
@@ -1,91 +0,0 @@
1
- import * as React from "react";
2
- import {
3
- CategoryPropType,
4
- DomainPropType,
5
- EventPropTypeInterface,
6
- StringOrNumberOrCallback,
7
- VictoryCommonProps,
8
- VictoryStyleInterface,
9
- VictoryStyleObject,
10
- } from "victory-core";
11
- import {
12
- withContainer,
13
- useDomain,
14
- useScale,
15
- useData,
16
- } from "victory-core/es/v37";
17
- import { AxesType } from "..";
18
- import { VictoryAxis, VictoryAxisProps } from "victory-axis";
19
-
20
- interface VictoryChartProps extends VictoryCommonProps {
21
- backgroundComponent?: React.ReactElement;
22
- categories?: CategoryPropType;
23
- children?: React.ReactNode | React.ReactNode[];
24
- desc?: string;
25
- defaultAxes?: AxesType;
26
- defaultPolarAxes?: AxesType;
27
- domain?: DomainPropType;
28
- endAngle?: number;
29
- eventKey?: StringOrNumberOrCallback;
30
- events?: EventPropTypeInterface<
31
- string,
32
- string[] | number[] | string | number
33
- >[];
34
- innerRadius?: number;
35
- prependDefaultAxes?: boolean;
36
- startAngle?: number;
37
- style?: Pick<VictoryStyleInterface, "parent"> & {
38
- background?: VictoryStyleObject;
39
- };
40
- title?: string;
41
- }
42
-
43
- const DEFAULT_AXES = {
44
- independent: <VictoryAxis />,
45
- dependent: <VictoryAxis dependentAxis />,
46
- };
47
-
48
- // TODO: This does not accept data
49
- const VictoryChart = ({
50
- defaultAxes = DEFAULT_AXES,
51
- groupComponent = <g />,
52
- children,
53
- }: VictoryChartProps) => {
54
- const scale = useScale();
55
- const data = useData();
56
- const domain = useDomain();
57
-
58
- const axes = React.useMemo(() => {
59
- const { dependent, independent } = {
60
- ...defaultAxes,
61
- ...DEFAULT_AXES,
62
- };
63
- const axisProps: VictoryAxisProps = {
64
- data,
65
- domain,
66
- // @ts-expect-error we need to fix this scale type
67
- scale,
68
- standalone: false,
69
- };
70
- return [
71
- React.cloneElement(dependent, { ...axisProps, key: "dependent-axis" }),
72
- React.cloneElement(independent, {
73
- ...axisProps,
74
- key: "independent-axis",
75
- }),
76
- ];
77
- }, [defaultAxes, domain, scale, data]);
78
-
79
- const childComponents = React.Children.map(children, (child, index) => {
80
- // @ts-expect-error Why is this throwing a type error?
81
- return React.cloneElement(child, {
82
- key: `child-${index}`,
83
- index,
84
- standalone: false,
85
- });
86
- });
87
-
88
- return React.cloneElement(groupComponent, {}, axes, childComponents);
89
- };
90
-
91
- export default withContainer(VictoryChart);