victory-core 36.5.0 → 36.5.3
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.
- package/dist/victory-core.js +13817 -10827
- package/dist/victory-core.min.js +1 -1
- package/es/index.d.ts +7 -27
- package/es/index.js +7 -53
- package/es/{types.d.ts → types/callbacks.d.ts} +12 -8
- package/es/types/callbacks.js +2 -0
- package/es/types/prop-types.d.ts +130 -0
- package/es/types/prop-types.js +2 -0
- package/es/victory-accessible-group/victory-accessible-group.d.ts +1 -0
- package/es/victory-accessible-group/victory-accessible-group.js +2 -1
- package/es/victory-animation/util.d.ts +2 -1
- package/es/victory-animation/util.js +6 -4
- package/es/victory-animation/victory-animation.d.ts +1 -0
- package/es/victory-animation/victory-animation.js +2 -1
- package/es/victory-clip-container/victory-clip-container.d.ts +6 -5
- package/es/victory-clip-container/victory-clip-container.js +2 -1
- package/es/victory-container/victory-container.d.ts +8 -7
- package/es/victory-container/victory-container.js +2 -1
- package/es/victory-label/victory-label.d.ts +3 -2
- package/es/victory-label/victory-label.js +4 -4
- package/es/victory-portal/portal-context.d.ts +1 -0
- package/es/victory-portal/portal-context.js +2 -1
- package/es/victory-portal/portal.d.ts +3 -2
- package/es/victory-portal/portal.js +2 -1
- package/es/victory-portal/victory-portal.d.ts +1 -0
- package/es/victory-portal/victory-portal.js +2 -1
- package/es/victory-primitives/arc.d.ts +31 -2
- package/es/victory-primitives/arc.js +3 -2
- package/es/victory-primitives/background.d.ts +31 -2
- package/es/victory-primitives/background.js +3 -2
- package/es/victory-primitives/border.d.ts +28 -2
- package/es/victory-primitives/border.js +3 -2
- package/es/victory-primitives/circle.d.ts +1 -0
- package/es/victory-primitives/circle.js +2 -1
- package/es/victory-primitives/clip-path.d.ts +2 -1
- package/es/victory-primitives/clip-path.js +2 -1
- package/es/victory-primitives/index.d.ts +1 -0
- package/es/victory-primitives/index.js +2 -1
- package/es/victory-primitives/line-segment.d.ts +29 -2
- package/es/victory-primitives/line-segment.js +3 -2
- package/es/victory-primitives/line.d.ts +1 -0
- package/es/victory-primitives/line.js +2 -1
- package/es/victory-primitives/path.d.ts +1 -0
- package/es/victory-primitives/path.js +2 -1
- package/es/victory-primitives/point.d.ts +30 -2
- package/es/victory-primitives/point.js +3 -2
- package/es/victory-primitives/rect.d.ts +1 -0
- package/es/victory-primitives/rect.js +2 -1
- package/es/victory-primitives/text.d.ts +2 -1
- package/es/victory-primitives/text.js +2 -1
- package/es/victory-primitives/tspan.d.ts +2 -1
- package/es/victory-primitives/tspan.js +2 -1
- package/es/victory-primitives/types.d.ts +2 -1
- package/es/victory-primitives/types.js +2 -1
- package/es/victory-primitives/whisker.d.ts +37 -2
- package/es/victory-primitives/whisker.js +3 -2
- package/es/victory-state/defaults.d.ts +3 -0
- package/es/victory-state/defaults.js +3 -0
- package/es/victory-state/helpers/get-axis-data.d.ts +3 -0
- package/es/victory-state/helpers/get-axis-data.js +15 -0
- package/es/victory-state/helpers/get-data.d.ts +15 -0
- package/es/victory-state/helpers/get-data.js +88 -0
- package/es/victory-state/helpers/get-domain.d.ts +6 -0
- package/es/victory-state/helpers/get-domain.js +68 -0
- package/es/victory-state/helpers/get-range.d.ts +6 -0
- package/es/victory-state/helpers/get-range.js +37 -0
- package/es/victory-state/helpers/get-scale.d.ts +6 -0
- package/es/victory-state/helpers/get-scale.js +59 -0
- package/es/victory-state/index.d.ts +3 -0
- package/es/victory-state/index.js +3 -0
- package/es/victory-state/types.d.ts +24 -0
- package/es/victory-state/types.js +2 -0
- package/es/victory-state/victory-provider.d.ts +19 -0
- package/es/victory-state/victory-provider.js +118 -0
- package/es/victory-theme/grayscale.d.ts +2 -1
- package/es/victory-theme/grayscale.js +2 -1
- package/es/victory-theme/material.d.ts +2 -1
- package/es/victory-theme/material.js +2 -1
- package/{lib/victory-theme/victory-theme-definition.d.ts → es/victory-theme/types.d.ts} +3 -8
- package/es/victory-theme/types.js +2 -0
- package/es/victory-theme/victory-theme.d.ts +4 -3
- package/es/victory-theme/victory-theme.js +3 -2
- package/es/victory-transition/victory-transition.d.ts +1 -0
- package/es/victory-transition/victory-transition.js +2 -1
- package/es/victory-util/add-events.d.ts +106 -0
- package/es/victory-util/add-events.js +40 -33
- package/es/victory-util/axis.d.ts +51 -0
- package/es/victory-util/axis.js +9 -7
- package/es/victory-util/collection.d.ts +9 -0
- package/es/victory-util/collection.js +6 -4
- package/es/victory-util/common-props.d.ts +84 -0
- package/es/victory-util/common-props.js +29 -12
- package/es/victory-util/data.d.ts +75 -0
- package/es/victory-util/data.js +2 -1
- package/es/victory-util/default-transitions.d.ts +5 -0
- package/es/victory-util/default-transitions.js +2 -1
- package/es/victory-util/domain.d.ts +91 -0
- package/es/victory-util/domain.js +6 -2
- package/es/victory-util/events.d.ts +65 -0
- package/es/victory-util/events.js +13 -8
- package/es/victory-util/helpers.d.ts +61 -0
- package/es/victory-util/helpers.js +8 -4
- package/es/victory-util/hooks/index.d.ts +3 -0
- package/es/victory-util/hooks/index.js +2 -1
- package/es/victory-util/hooks/use-animation-state.js +4 -3
- package/es/victory-util/hooks/use-previous-props.d.ts +2 -0
- package/es/victory-util/hooks/use-previous-props.js +4 -3
- package/es/victory-util/immutable.d.ts +12 -0
- package/es/victory-util/immutable.js +5 -4
- package/es/victory-util/index.d.ts +29 -0
- package/es/victory-util/index.js +48 -0
- package/es/victory-util/label-helpers.d.ts +27 -0
- package/es/victory-util/label-helpers.js +2 -1
- package/es/victory-util/line-helpers.d.ts +5 -0
- package/es/victory-util/line-helpers.js +24 -6
- package/es/victory-util/log.d.ts +2 -0
- package/es/victory-util/log.js +2 -1
- package/es/victory-util/point-path-helpers.d.ts +1 -0
- package/es/victory-util/point-path-helpers.js +2 -1
- package/es/victory-util/prop-types.d.ts +51 -0
- package/es/victory-util/prop-types.js +35 -44
- package/es/victory-util/scale.d.ts +10 -0
- package/es/victory-util/scale.js +14 -6
- package/es/victory-util/selection.d.ts +25 -23
- package/es/victory-util/selection.js +25 -14
- package/es/victory-util/style.d.ts +19 -0
- package/es/victory-util/style.js +2 -1
- package/es/victory-util/textsize.d.ts +37 -8
- package/es/victory-util/textsize.js +9 -6
- package/es/victory-util/timer-context.d.ts +1 -0
- package/es/victory-util/timer-context.js +2 -1
- package/es/victory-util/timer.d.ts +3 -2
- package/es/victory-util/timer.js +2 -1
- package/es/victory-util/transitions.d.ts +49 -0
- package/es/victory-util/transitions.js +5 -4
- package/es/victory-util/type-helpers.d.ts +10 -0
- package/es/victory-util/type-helpers.js +28 -0
- package/es/victory-util/user-props.d.ts +21 -0
- package/es/victory-util/user-props.js +6 -5
- package/es/victory-util/with-container.d.ts +5 -0
- package/es/victory-util/with-container.js +32 -0
- package/es/victory-util/wrapper.d.ts +38 -0
- package/es/victory-util/wrapper.js +4 -3
- package/lib/index.d.ts +7 -27
- package/lib/index.js +58 -147
- package/lib/{types.d.ts → types/callbacks.d.ts} +12 -8
- package/lib/types/callbacks.js +2 -0
- package/lib/types/prop-types.d.ts +130 -0
- package/lib/types/prop-types.js +2 -0
- package/lib/victory-accessible-group/victory-accessible-group.d.ts +1 -0
- package/lib/victory-accessible-group/victory-accessible-group.js +2 -1
- package/lib/victory-animation/util.d.ts +2 -1
- package/lib/victory-animation/util.js +6 -4
- package/lib/victory-animation/victory-animation.d.ts +1 -0
- package/lib/victory-animation/victory-animation.js +2 -1
- package/lib/victory-clip-container/victory-clip-container.d.ts +6 -5
- package/lib/victory-clip-container/victory-clip-container.js +2 -1
- package/lib/victory-container/victory-container.d.ts +8 -7
- package/lib/victory-container/victory-container.js +2 -1
- package/lib/victory-label/victory-label.d.ts +3 -2
- package/lib/victory-label/victory-label.js +4 -4
- package/lib/victory-portal/portal-context.d.ts +1 -0
- package/lib/victory-portal/portal-context.js +2 -1
- package/lib/victory-portal/portal.d.ts +3 -2
- package/lib/victory-portal/portal.js +2 -1
- package/lib/victory-portal/victory-portal.d.ts +1 -0
- package/lib/victory-portal/victory-portal.js +2 -1
- package/lib/victory-primitives/arc.d.ts +31 -2
- package/lib/victory-primitives/arc.js +4 -3
- package/lib/victory-primitives/background.d.ts +31 -2
- package/lib/victory-primitives/background.js +4 -3
- package/lib/victory-primitives/border.d.ts +28 -2
- package/lib/victory-primitives/border.js +4 -3
- package/lib/victory-primitives/circle.d.ts +1 -0
- package/lib/victory-primitives/circle.js +2 -1
- package/lib/victory-primitives/clip-path.d.ts +2 -1
- package/lib/victory-primitives/clip-path.js +2 -1
- package/lib/victory-primitives/index.d.ts +1 -0
- package/lib/victory-primitives/index.js +2 -1
- package/lib/victory-primitives/line-segment.d.ts +29 -2
- package/lib/victory-primitives/line-segment.js +4 -3
- package/lib/victory-primitives/line.d.ts +1 -0
- package/lib/victory-primitives/line.js +2 -1
- package/lib/victory-primitives/path.d.ts +1 -0
- package/lib/victory-primitives/path.js +2 -1
- package/lib/victory-primitives/point.d.ts +30 -2
- package/lib/victory-primitives/point.js +4 -3
- package/lib/victory-primitives/rect.d.ts +1 -0
- package/lib/victory-primitives/rect.js +2 -1
- package/lib/victory-primitives/text.d.ts +2 -1
- package/lib/victory-primitives/text.js +2 -1
- package/lib/victory-primitives/tspan.d.ts +2 -1
- package/lib/victory-primitives/tspan.js +2 -1
- package/lib/victory-primitives/types.d.ts +2 -1
- package/lib/victory-primitives/types.js +2 -1
- package/lib/victory-primitives/whisker.d.ts +37 -2
- package/lib/victory-primitives/whisker.js +4 -3
- package/lib/victory-state/defaults.d.ts +3 -0
- package/lib/victory-state/defaults.js +11 -0
- package/lib/victory-state/helpers/get-axis-data.d.ts +3 -0
- package/lib/victory-state/helpers/get-axis-data.js +23 -0
- package/lib/victory-state/helpers/get-data.d.ts +15 -0
- package/lib/victory-state/helpers/get-data.js +99 -0
- package/lib/victory-state/helpers/get-domain.d.ts +6 -0
- package/lib/victory-state/helpers/get-domain.js +82 -0
- package/lib/victory-state/helpers/get-range.d.ts +6 -0
- package/lib/victory-state/helpers/get-range.js +46 -0
- package/lib/victory-state/helpers/get-scale.d.ts +6 -0
- package/lib/victory-state/helpers/get-scale.js +74 -0
- package/lib/victory-state/index.d.ts +3 -0
- package/lib/victory-state/index.js +32 -0
- package/lib/victory-state/types.d.ts +24 -0
- package/lib/victory-state/types.js +2 -0
- package/lib/victory-state/victory-provider.d.ts +19 -0
- package/lib/victory-state/victory-provider.js +144 -0
- package/lib/victory-theme/grayscale.d.ts +2 -1
- package/lib/victory-theme/grayscale.js +2 -1
- package/lib/victory-theme/material.d.ts +2 -1
- package/lib/victory-theme/material.js +2 -1
- package/{es/victory-theme/victory-theme-definition.d.ts → lib/victory-theme/types.d.ts} +3 -8
- package/lib/victory-theme/types.js +2 -0
- package/lib/victory-theme/victory-theme.d.ts +4 -3
- package/lib/victory-theme/victory-theme.js +6 -5
- package/lib/victory-transition/victory-transition.d.ts +1 -0
- package/lib/victory-transition/victory-transition.js +2 -1
- package/lib/victory-util/add-events.d.ts +106 -0
- package/lib/victory-util/add-events.js +40 -36
- package/lib/victory-util/axis.d.ts +51 -0
- package/lib/victory-util/axis.js +8 -6
- package/lib/victory-util/collection.d.ts +9 -0
- package/lib/victory-util/collection.js +6 -4
- package/lib/victory-util/common-props.d.ts +84 -0
- package/lib/victory-util/common-props.js +27 -12
- package/lib/victory-util/data.d.ts +75 -0
- package/lib/victory-util/data.js +2 -1
- package/lib/victory-util/default-transitions.d.ts +5 -0
- package/lib/victory-util/default-transitions.js +2 -1
- package/lib/victory-util/domain.d.ts +91 -0
- package/lib/victory-util/domain.js +6 -2
- package/lib/victory-util/events.d.ts +65 -0
- package/lib/victory-util/events.js +13 -9
- package/lib/victory-util/helpers.d.ts +61 -0
- package/lib/victory-util/helpers.js +8 -4
- package/lib/victory-util/hooks/index.d.ts +3 -0
- package/lib/victory-util/hooks/index.js +2 -1
- package/lib/victory-util/hooks/use-animation-state.js +4 -3
- package/lib/victory-util/hooks/use-previous-props.d.ts +2 -0
- package/lib/victory-util/hooks/use-previous-props.js +5 -6
- package/lib/victory-util/immutable.d.ts +12 -0
- package/lib/victory-util/immutable.js +5 -4
- package/lib/victory-util/index.d.ts +29 -0
- package/lib/victory-util/index.js +181 -0
- package/lib/victory-util/label-helpers.d.ts +27 -0
- package/lib/victory-util/label-helpers.js +2 -1
- package/lib/victory-util/line-helpers.d.ts +5 -0
- package/lib/victory-util/line-helpers.js +28 -7
- package/lib/victory-util/log.d.ts +2 -0
- package/lib/victory-util/log.js +2 -1
- package/lib/victory-util/point-path-helpers.d.ts +1 -0
- package/lib/victory-util/point-path-helpers.js +2 -1
- package/lib/victory-util/prop-types.d.ts +51 -0
- package/lib/victory-util/prop-types.js +36 -44
- package/lib/victory-util/scale.d.ts +10 -0
- package/lib/victory-util/scale.js +14 -5
- package/lib/victory-util/selection.d.ts +25 -23
- package/lib/victory-util/selection.js +25 -19
- package/lib/victory-util/style.d.ts +19 -0
- package/lib/victory-util/style.js +2 -1
- package/lib/victory-util/textsize.d.ts +37 -8
- package/lib/victory-util/textsize.js +9 -6
- package/lib/victory-util/timer-context.d.ts +1 -0
- package/lib/victory-util/timer-context.js +2 -1
- package/lib/victory-util/timer.d.ts +3 -2
- package/lib/victory-util/timer.js +2 -1
- package/lib/victory-util/transitions.d.ts +49 -0
- package/lib/victory-util/transitions.js +5 -4
- package/lib/victory-util/type-helpers.d.ts +10 -0
- package/lib/victory-util/type-helpers.js +45 -0
- package/lib/victory-util/user-props.d.ts +21 -0
- package/lib/victory-util/user-props.js +6 -5
- package/lib/victory-util/with-container.d.ts +5 -0
- package/lib/victory-util/with-container.js +44 -0
- package/lib/victory-util/wrapper.d.ts +38 -0
- package/lib/victory-util/wrapper.js +4 -3
- package/package.json +3 -3
- package/src/index.ts +9 -31
- package/src/{types.ts → types/callbacks.ts} +21 -13
- package/src/types/prop-types.ts +195 -0
- package/src/victory-accessible-group/victory-accessible-group.tsx +3 -3
- package/src/victory-animation/util.ts +3 -2
- package/src/victory-animation/victory-animation.tsx +13 -13
- package/src/victory-clip-container/victory-clip-container.tsx +23 -23
- package/src/victory-container/victory-container.tsx +19 -19
- package/src/victory-label/victory-label.tsx +41 -39
- package/src/victory-portal/portal.tsx +1 -1
- package/src/victory-portal/victory-portal.tsx +3 -3
- package/src/victory-primitives/arc.tsx +8 -6
- package/src/victory-primitives/background.tsx +8 -6
- package/src/victory-primitives/border.tsx +8 -6
- package/src/victory-primitives/clip-path.tsx +3 -3
- package/src/victory-primitives/line-segment.tsx +8 -6
- package/src/victory-primitives/point.tsx +10 -8
- package/src/victory-primitives/text.tsx +2 -2
- package/src/victory-primitives/tspan.tsx +1 -1
- package/src/victory-primitives/types.ts +1 -1
- package/src/victory-primitives/whisker.tsx +15 -13
- package/src/victory-state/defaults.ts +2 -0
- package/src/victory-state/helpers/get-axis-data.ts +14 -0
- package/src/victory-state/helpers/get-data.ts +79 -0
- package/src/victory-state/helpers/get-domain.ts +62 -0
- package/src/victory-state/helpers/get-range.ts +39 -0
- package/src/victory-state/helpers/get-scale.ts +64 -0
- package/src/victory-state/index.ts +2 -0
- package/src/victory-state/types.ts +32 -0
- package/src/victory-state/victory-provider.tsx +116 -0
- package/src/victory-theme/grayscale.tsx +62 -62
- package/src/victory-theme/material.tsx +67 -67
- package/src/victory-theme/{victory-theme-definition.ts → types.ts} +10 -14
- package/src/victory-theme/victory-theme.tsx +1 -1
- package/src/victory-transition/victory-transition.tsx +19 -19
- package/src/victory-util/{add-events.js → add-events.tsx} +136 -59
- package/src/victory-util/{axis.js → axis.tsx} +17 -18
- package/src/victory-util/{collection.js → collection.tsx} +14 -10
- package/src/victory-util/common-props.tsx +307 -0
- package/src/victory-util/{data.js → data.ts} +14 -10
- package/src/victory-util/{default-transitions.js → default-transitions.ts} +20 -18
- package/src/victory-util/{domain.js → domain.ts} +26 -23
- package/src/victory-util/{events.js → events.ts} +82 -31
- package/src/victory-util/{helpers.js → helpers.ts} +41 -22
- package/src/victory-util/hooks/{index.js → index.ts} +0 -0
- package/src/victory-util/hooks/use-animation-state.js +12 -12
- package/src/victory-util/hooks/use-previous-props.ts +9 -0
- package/src/victory-util/{immutable.js → immutable.ts} +14 -10
- package/src/victory-util/index.ts +28 -0
- package/src/victory-util/{label-helpers.js → label-helpers.ts} +7 -7
- package/src/victory-util/line-helpers.ts +104 -0
- package/src/victory-util/{log.js → log.ts} +1 -1
- package/src/victory-util/{prop-types.js → prop-types.ts} +103 -101
- package/src/victory-util/{scale.js → scale.ts} +29 -16
- package/src/victory-util/selection.ts +158 -0
- package/src/victory-util/{style.js → style.ts} +3 -3
- package/src/victory-util/{textsize.js → textsize.ts} +32 -17
- package/src/victory-util/timer-context.ts +1 -1
- package/src/victory-util/timer.ts +5 -10
- package/src/victory-util/{transitions.js → transitions.ts} +50 -22
- package/src/victory-util/type-helpers.ts +50 -0
- package/src/victory-util/{user-props.js → user-props.ts} +16 -11
- package/src/victory-util/with-container.tsx +41 -0
- package/src/victory-util/{wrapper.js → wrapper.tsx} +38 -33
- package/es/types.js +0 -1
- package/es/victory-theme/victory-theme-definition.js +0 -1
- package/es/victory-util/types.d.ts +0 -188
- package/es/victory-util/types.js +0 -1
- package/lib/types.js +0 -1
- package/lib/victory-theme/victory-theme-definition.js +0 -1
- package/lib/victory-util/types.d.ts +0 -188
- package/lib/victory-util/types.js +0 -1
- package/src/victory-util/common-props.js +0 -197
- package/src/victory-util/hooks/use-previous-props.js +0 -9
- package/src/victory-util/line-helpers.js +0 -54
- package/src/victory-util/selection.d.ts +0 -23
- package/src/victory-util/selection.js +0 -98
- package/src/victory-util/textsize.d.ts +0 -8
- package/src/victory-util/types.ts +0 -247
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import PropTypes from "prop-types";
|
|
2
|
+
import * as CustomPropTypes from "./prop-types";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { OriginType } from "../victory-label/victory-label";
|
|
5
|
+
import { PaddingProps, VictoryThemeDefinition } from "../victory-theme/types";
|
|
6
|
+
import {
|
|
7
|
+
AnimatePropTypeInterface,
|
|
8
|
+
CategoryPropType,
|
|
9
|
+
ColorScalePropType,
|
|
10
|
+
D3Scale,
|
|
11
|
+
DataGetterPropType,
|
|
12
|
+
DomainPaddingPropType,
|
|
13
|
+
DomainPropType,
|
|
14
|
+
EventCallbackInterface,
|
|
15
|
+
RangePropType,
|
|
16
|
+
ScalePropType,
|
|
17
|
+
SortOrderPropType,
|
|
18
|
+
StringOrNumberOrList,
|
|
19
|
+
} from "../types/prop-types";
|
|
20
|
+
import { NumberOrCallback, StringOrCallback } from "../types/callbacks";
|
|
21
|
+
|
|
22
|
+
export interface VictoryDatableProps {
|
|
23
|
+
categories?: CategoryPropType;
|
|
24
|
+
data?: readonly any[];
|
|
25
|
+
dataComponent?: React.ReactElement;
|
|
26
|
+
domain?: DomainPropType;
|
|
27
|
+
domainPadding?: DomainPaddingPropType;
|
|
28
|
+
samples?: number;
|
|
29
|
+
sortKey?: DataGetterPropType;
|
|
30
|
+
sortOrder?: SortOrderPropType;
|
|
31
|
+
x?: DataGetterPropType;
|
|
32
|
+
y?: DataGetterPropType;
|
|
33
|
+
y0?: DataGetterPropType;
|
|
34
|
+
}
|
|
35
|
+
const dataProps: React.WeakValidationMap<VictoryDatableProps> = {
|
|
36
|
+
// @ts-expect-error TODO: synchronize the type with this PropTypes
|
|
37
|
+
categories: PropTypes.oneOfType([
|
|
38
|
+
PropTypes.arrayOf(PropTypes.string),
|
|
39
|
+
PropTypes.shape({
|
|
40
|
+
x: PropTypes.arrayOf(PropTypes.string),
|
|
41
|
+
y: PropTypes.arrayOf(PropTypes.string),
|
|
42
|
+
}),
|
|
43
|
+
]),
|
|
44
|
+
// @ts-expect-error TODO: synchronize the type with this PropTypes
|
|
45
|
+
data: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
|
46
|
+
dataComponent: PropTypes.element,
|
|
47
|
+
disableInlineStyles: PropTypes.bool,
|
|
48
|
+
labelComponent: PropTypes.element,
|
|
49
|
+
labels: PropTypes.oneOfType([PropTypes.func, PropTypes.array]),
|
|
50
|
+
samples: CustomPropTypes.nonNegative,
|
|
51
|
+
sortKey: PropTypes.oneOfType([
|
|
52
|
+
PropTypes.func,
|
|
53
|
+
CustomPropTypes.allOfType([
|
|
54
|
+
CustomPropTypes.integer,
|
|
55
|
+
CustomPropTypes.nonNegative,
|
|
56
|
+
]),
|
|
57
|
+
PropTypes.string,
|
|
58
|
+
PropTypes.arrayOf(PropTypes.string.isRequired),
|
|
59
|
+
]),
|
|
60
|
+
sortOrder: PropTypes.oneOf(["ascending", "descending"]),
|
|
61
|
+
style: PropTypes.shape({
|
|
62
|
+
parent: PropTypes.object,
|
|
63
|
+
data: PropTypes.object,
|
|
64
|
+
labels: PropTypes.object,
|
|
65
|
+
}),
|
|
66
|
+
x: PropTypes.oneOfType([
|
|
67
|
+
PropTypes.func,
|
|
68
|
+
CustomPropTypes.allOfType([
|
|
69
|
+
CustomPropTypes.integer,
|
|
70
|
+
CustomPropTypes.nonNegative,
|
|
71
|
+
]),
|
|
72
|
+
PropTypes.string,
|
|
73
|
+
PropTypes.arrayOf(PropTypes.string.isRequired),
|
|
74
|
+
]),
|
|
75
|
+
y: PropTypes.oneOfType([
|
|
76
|
+
PropTypes.func,
|
|
77
|
+
CustomPropTypes.allOfType([
|
|
78
|
+
CustomPropTypes.integer,
|
|
79
|
+
CustomPropTypes.nonNegative,
|
|
80
|
+
]),
|
|
81
|
+
PropTypes.string,
|
|
82
|
+
PropTypes.arrayOf(PropTypes.string.isRequired),
|
|
83
|
+
]),
|
|
84
|
+
y0: PropTypes.oneOfType([
|
|
85
|
+
PropTypes.func,
|
|
86
|
+
CustomPropTypes.allOfType([
|
|
87
|
+
CustomPropTypes.integer,
|
|
88
|
+
CustomPropTypes.nonNegative,
|
|
89
|
+
]),
|
|
90
|
+
PropTypes.string,
|
|
91
|
+
PropTypes.arrayOf(PropTypes.string.isRequired),
|
|
92
|
+
]),
|
|
93
|
+
};
|
|
94
|
+
export interface VictoryCommonThemeProps {
|
|
95
|
+
animate?: boolean | AnimatePropTypeInterface;
|
|
96
|
+
colorScale?: ColorScalePropType;
|
|
97
|
+
containerComponent?: React.ReactElement;
|
|
98
|
+
domainPadding?: DomainPaddingPropType;
|
|
99
|
+
externalEventMutations?: EventCallbackInterface<
|
|
100
|
+
string | string[],
|
|
101
|
+
StringOrNumberOrList
|
|
102
|
+
>[];
|
|
103
|
+
groupComponent?: React.ReactElement;
|
|
104
|
+
height?: number;
|
|
105
|
+
horizontal?: boolean;
|
|
106
|
+
maxDomain?: number | { x?: number; y?: number };
|
|
107
|
+
minDomain?: number | { x?: number; y?: number };
|
|
108
|
+
name?: string;
|
|
109
|
+
origin?: OriginType;
|
|
110
|
+
padding?: PaddingProps;
|
|
111
|
+
polar?: boolean;
|
|
112
|
+
range?: RangePropType;
|
|
113
|
+
scale?:
|
|
114
|
+
| ScalePropType
|
|
115
|
+
| D3Scale
|
|
116
|
+
| {
|
|
117
|
+
x?: ScalePropType | D3Scale;
|
|
118
|
+
y?: ScalePropType | D3Scale;
|
|
119
|
+
};
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
121
|
+
sharedEvents?: { events: any[]; getEventState: Function };
|
|
122
|
+
singleQuadrantDomainPadding?: boolean | { x?: boolean; y?: boolean };
|
|
123
|
+
standalone?: boolean;
|
|
124
|
+
width?: number;
|
|
125
|
+
}
|
|
126
|
+
export interface VictoryCommonProps extends VictoryCommonThemeProps {
|
|
127
|
+
theme?: VictoryThemeDefinition;
|
|
128
|
+
}
|
|
129
|
+
const baseProps: React.WeakValidationMap<VictoryCommonProps> = {
|
|
130
|
+
animate: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
|
|
131
|
+
containerComponent: PropTypes.element,
|
|
132
|
+
domain: PropTypes.oneOfType([
|
|
133
|
+
CustomPropTypes.domain,
|
|
134
|
+
PropTypes.shape({ x: CustomPropTypes.domain, y: CustomPropTypes.domain }),
|
|
135
|
+
]),
|
|
136
|
+
// @ts-expect-error TODO: synchronize the type with this PropTypes
|
|
137
|
+
maxDomain: PropTypes.oneOfType([
|
|
138
|
+
PropTypes.number,
|
|
139
|
+
PropTypes.instanceOf(Date),
|
|
140
|
+
PropTypes.shape({
|
|
141
|
+
x: PropTypes.oneOfType([PropTypes.number, PropTypes.instanceOf(Date)]),
|
|
142
|
+
y: PropTypes.oneOfType([PropTypes.number, PropTypes.instanceOf(Date)]),
|
|
143
|
+
}),
|
|
144
|
+
]),
|
|
145
|
+
// @ts-expect-error TODO: synchronize the type with this PropTypes
|
|
146
|
+
minDomain: PropTypes.oneOfType([
|
|
147
|
+
PropTypes.number,
|
|
148
|
+
PropTypes.instanceOf(Date),
|
|
149
|
+
PropTypes.shape({
|
|
150
|
+
x: PropTypes.oneOfType([PropTypes.number, PropTypes.instanceOf(Date)]),
|
|
151
|
+
y: PropTypes.oneOfType([PropTypes.number, PropTypes.instanceOf(Date)]),
|
|
152
|
+
}),
|
|
153
|
+
]),
|
|
154
|
+
// @ts-expect-error TODO: synchronize the type with this PropTypes
|
|
155
|
+
domainPadding: PropTypes.oneOfType([
|
|
156
|
+
PropTypes.shape({
|
|
157
|
+
x: PropTypes.oneOfType([
|
|
158
|
+
PropTypes.number,
|
|
159
|
+
PropTypes.arrayOf(PropTypes.number),
|
|
160
|
+
]),
|
|
161
|
+
y: PropTypes.oneOfType([
|
|
162
|
+
PropTypes.number,
|
|
163
|
+
PropTypes.arrayOf(PropTypes.number),
|
|
164
|
+
]),
|
|
165
|
+
}),
|
|
166
|
+
PropTypes.number,
|
|
167
|
+
PropTypes.arrayOf(PropTypes.number),
|
|
168
|
+
]),
|
|
169
|
+
eventKey: PropTypes.oneOfType([
|
|
170
|
+
PropTypes.func,
|
|
171
|
+
CustomPropTypes.allOfType([
|
|
172
|
+
CustomPropTypes.integer,
|
|
173
|
+
CustomPropTypes.nonNegative,
|
|
174
|
+
]),
|
|
175
|
+
PropTypes.string,
|
|
176
|
+
]),
|
|
177
|
+
events: PropTypes.arrayOf(
|
|
178
|
+
PropTypes.shape({
|
|
179
|
+
target: PropTypes.oneOf(["data", "labels", "parent"]),
|
|
180
|
+
eventKey: PropTypes.oneOfType([
|
|
181
|
+
PropTypes.array,
|
|
182
|
+
CustomPropTypes.allOfType([
|
|
183
|
+
CustomPropTypes.integer,
|
|
184
|
+
CustomPropTypes.nonNegative,
|
|
185
|
+
]),
|
|
186
|
+
PropTypes.string,
|
|
187
|
+
]),
|
|
188
|
+
eventHandlers: PropTypes.object,
|
|
189
|
+
}),
|
|
190
|
+
),
|
|
191
|
+
// @ts-expect-error TODO: synchronize the type with this PropTypes
|
|
192
|
+
externalEventMutations: PropTypes.arrayOf(
|
|
193
|
+
PropTypes.shape({
|
|
194
|
+
callback: PropTypes.func,
|
|
195
|
+
childName: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
196
|
+
eventKey: PropTypes.oneOfType([
|
|
197
|
+
PropTypes.array,
|
|
198
|
+
CustomPropTypes.allOfType([
|
|
199
|
+
CustomPropTypes.integer,
|
|
200
|
+
CustomPropTypes.nonNegative,
|
|
201
|
+
]),
|
|
202
|
+
PropTypes.string,
|
|
203
|
+
]),
|
|
204
|
+
mutation: PropTypes.func,
|
|
205
|
+
target: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
206
|
+
}),
|
|
207
|
+
),
|
|
208
|
+
groupComponent: PropTypes.element,
|
|
209
|
+
height: CustomPropTypes.nonNegative,
|
|
210
|
+
name: PropTypes.string,
|
|
211
|
+
// @ts-expect-error TODO: synchronize the type with this PropTypes
|
|
212
|
+
origin: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
|
|
213
|
+
// @ts-expect-error TODO: synchronize the type with this PropTypes
|
|
214
|
+
padding: PropTypes.oneOfType([
|
|
215
|
+
PropTypes.number,
|
|
216
|
+
PropTypes.shape({
|
|
217
|
+
top: PropTypes.number,
|
|
218
|
+
bottom: PropTypes.number,
|
|
219
|
+
left: PropTypes.number,
|
|
220
|
+
right: PropTypes.number,
|
|
221
|
+
}),
|
|
222
|
+
]),
|
|
223
|
+
polar: PropTypes.bool,
|
|
224
|
+
range: PropTypes.oneOfType([
|
|
225
|
+
CustomPropTypes.domain,
|
|
226
|
+
PropTypes.shape({
|
|
227
|
+
x: CustomPropTypes.domain.isRequired,
|
|
228
|
+
y: CustomPropTypes.domain.isRequired,
|
|
229
|
+
}),
|
|
230
|
+
]),
|
|
231
|
+
scale: PropTypes.oneOfType([
|
|
232
|
+
CustomPropTypes.scale,
|
|
233
|
+
PropTypes.shape({
|
|
234
|
+
x: CustomPropTypes.scale.isRequired,
|
|
235
|
+
y: CustomPropTypes.scale.isRequired,
|
|
236
|
+
}),
|
|
237
|
+
]),
|
|
238
|
+
// @ts-expect-error TODO: synchronize the type with this PropTypes
|
|
239
|
+
sharedEvents: PropTypes.shape({
|
|
240
|
+
events: PropTypes.array,
|
|
241
|
+
getEventState: PropTypes.func,
|
|
242
|
+
}),
|
|
243
|
+
// @ts-expect-error TODO: synchronize the type with this PropTypes
|
|
244
|
+
singleQuadrantDomainPadding: PropTypes.oneOfType([
|
|
245
|
+
PropTypes.bool,
|
|
246
|
+
PropTypes.shape({
|
|
247
|
+
x: PropTypes.oneOfType([PropTypes.bool]),
|
|
248
|
+
y: PropTypes.oneOfType([PropTypes.bool]),
|
|
249
|
+
}),
|
|
250
|
+
]),
|
|
251
|
+
standalone: PropTypes.bool,
|
|
252
|
+
theme: PropTypes.object,
|
|
253
|
+
width: CustomPropTypes.nonNegative,
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
export interface VictoryCommonPrimitiveProps {
|
|
257
|
+
active?: boolean;
|
|
258
|
+
ariaLabel?: StringOrCallback;
|
|
259
|
+
className?: string;
|
|
260
|
+
clipPath?: string;
|
|
261
|
+
data?: any;
|
|
262
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
263
|
+
desc?: string | Function;
|
|
264
|
+
disableInlineStyles?: boolean;
|
|
265
|
+
events?: object;
|
|
266
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
267
|
+
id?: number | string | Function;
|
|
268
|
+
index?: number | string;
|
|
269
|
+
origin?: OriginType;
|
|
270
|
+
polar?: boolean;
|
|
271
|
+
role?: string;
|
|
272
|
+
scale?: any;
|
|
273
|
+
shapeRendering?: string;
|
|
274
|
+
style?: any;
|
|
275
|
+
tabIndex?: NumberOrCallback;
|
|
276
|
+
transform?: string;
|
|
277
|
+
}
|
|
278
|
+
const primitiveProps: React.WeakValidationMap<VictoryCommonPrimitiveProps> = {
|
|
279
|
+
active: PropTypes.bool,
|
|
280
|
+
ariaLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
|
281
|
+
className: PropTypes.string,
|
|
282
|
+
clipPath: PropTypes.string,
|
|
283
|
+
data: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
|
284
|
+
desc: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
|
285
|
+
disableInlineStyles: PropTypes.bool,
|
|
286
|
+
events: PropTypes.object,
|
|
287
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.func]),
|
|
288
|
+
index: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
289
|
+
// @ts-expect-error TODO: synchronize the type with this PropTypes
|
|
290
|
+
origin: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
|
|
291
|
+
polar: PropTypes.bool,
|
|
292
|
+
role: PropTypes.string,
|
|
293
|
+
scale: PropTypes.oneOfType([
|
|
294
|
+
CustomPropTypes.scale,
|
|
295
|
+
PropTypes.shape({ x: CustomPropTypes.scale, y: CustomPropTypes.scale }),
|
|
296
|
+
]),
|
|
297
|
+
shapeRendering: PropTypes.string,
|
|
298
|
+
style: PropTypes.object,
|
|
299
|
+
tabIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
|
|
300
|
+
transform: PropTypes.string,
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
export const CommonProps = {
|
|
304
|
+
dataProps,
|
|
305
|
+
baseProps,
|
|
306
|
+
primitiveProps,
|
|
307
|
+
};
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
isEqual,
|
|
14
14
|
includes,
|
|
15
15
|
isUndefined,
|
|
16
|
-
omitBy
|
|
16
|
+
omitBy,
|
|
17
17
|
} from "lodash";
|
|
18
18
|
import * as Helpers from "./helpers";
|
|
19
19
|
import * as Collection from "./collection";
|
|
@@ -25,7 +25,7 @@ import * as Immutable from "./immutable";
|
|
|
25
25
|
function parseDatum(datum) {
|
|
26
26
|
const immutableDatumWhitelist = {
|
|
27
27
|
errorX: true,
|
|
28
|
-
errorY: true
|
|
28
|
+
errorY: true,
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
return Immutable.isImmutable(datum)
|
|
@@ -70,7 +70,7 @@ function cleanData(dataset, props) {
|
|
|
70
70
|
const smallNumber = 1 / Number.MAX_SAFE_INTEGER;
|
|
71
71
|
const scaleType = {
|
|
72
72
|
x: Scale.getScaleType(props, "x"),
|
|
73
|
-
y: Scale.getScaleType(props, "y")
|
|
73
|
+
y: Scale.getScaleType(props, "y"),
|
|
74
74
|
};
|
|
75
75
|
if (scaleType.x !== "log" && scaleType.y !== "log") {
|
|
76
76
|
return dataset;
|
|
@@ -188,7 +188,7 @@ export function createStringMap(props, axis) {
|
|
|
188
188
|
const allStrings = uniq([
|
|
189
189
|
...stringsFromAxes,
|
|
190
190
|
...stringsFromCategories,
|
|
191
|
-
...stringsFromData
|
|
191
|
+
...stringsFromData,
|
|
192
192
|
]);
|
|
193
193
|
return allStrings.length === 0
|
|
194
194
|
? null
|
|
@@ -215,7 +215,7 @@ export function downsample(data, maxPoints, startingIndex = 0) {
|
|
|
215
215
|
const k = Math.pow(2, Math.ceil(Math.log2(dataLength / maxPoints)));
|
|
216
216
|
return data.filter(
|
|
217
217
|
// ensure modulo is always calculated from same reference: i + startingIndex
|
|
218
|
-
(d, i) => (i + startingIndex) % k === 0
|
|
218
|
+
(d, i) => (i + startingIndex) % k === 0,
|
|
219
219
|
);
|
|
220
220
|
}
|
|
221
221
|
return data;
|
|
@@ -228,7 +228,11 @@ export function downsample(data, maxPoints, startingIndex = 0) {
|
|
|
228
228
|
* @param {Array} expectedKeys: an array of expected data keys
|
|
229
229
|
* @returns {Array} the formatted data
|
|
230
230
|
*/
|
|
231
|
-
export function formatData(
|
|
231
|
+
export function formatData(
|
|
232
|
+
dataset: any[],
|
|
233
|
+
props: any,
|
|
234
|
+
expectedKeys?: string[],
|
|
235
|
+
) {
|
|
232
236
|
const isArrayOrIterable =
|
|
233
237
|
Array.isArray(dataset) || Immutable.isIterable(dataset);
|
|
234
238
|
if (!isArrayOrIterable || getLength(dataset) < 1) {
|
|
@@ -240,7 +244,7 @@ export function formatData(dataset, props, expectedKeys) {
|
|
|
240
244
|
|
|
241
245
|
const createAccessor = (name) => {
|
|
242
246
|
return Helpers.createAccessor(
|
|
243
|
-
props[name] !== undefined ? props[name] : name
|
|
247
|
+
props[name] !== undefined ? props[name] : name,
|
|
244
248
|
);
|
|
245
249
|
};
|
|
246
250
|
|
|
@@ -270,7 +274,7 @@ export function formatData(dataset, props, expectedKeys) {
|
|
|
270
274
|
y0:
|
|
271
275
|
expectedKeys.indexOf("y0") !== -1
|
|
272
276
|
? createStringMap(props, "y")
|
|
273
|
-
: undefined
|
|
277
|
+
: undefined,
|
|
274
278
|
};
|
|
275
279
|
}
|
|
276
280
|
|
|
@@ -280,7 +284,7 @@ export function formatData(dataset, props, expectedKeys) {
|
|
|
280
284
|
// eslint-disable-line complexity
|
|
281
285
|
datum = parseDatum(datum);
|
|
282
286
|
const fallbackValues = { x: index, y: datum };
|
|
283
|
-
const processedValues = expectedKeys
|
|
287
|
+
const processedValues = expectedKeys!.reduce((memo, type) => {
|
|
284
288
|
const processedValue = accessor[type](datum);
|
|
285
289
|
const value =
|
|
286
290
|
processedValue !== undefined
|
|
@@ -446,7 +450,7 @@ export function isDataComponent(component) {
|
|
|
446
450
|
"pie",
|
|
447
451
|
"scatter",
|
|
448
452
|
"stack",
|
|
449
|
-
"voronoi"
|
|
453
|
+
"voronoi",
|
|
450
454
|
];
|
|
451
455
|
return includes(whitelist, role);
|
|
452
456
|
}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
import { AnimatePropTypeInterface } from "../types/prop-types";
|
|
2
|
+
|
|
3
|
+
export function continuousTransitions(): AnimatePropTypeInterface {
|
|
2
4
|
return {
|
|
3
5
|
onLoad: {
|
|
4
|
-
duration: 2000
|
|
6
|
+
duration: 2000,
|
|
5
7
|
},
|
|
6
8
|
onExit: {
|
|
7
|
-
duration: 500
|
|
9
|
+
duration: 500,
|
|
8
10
|
},
|
|
9
11
|
onEnter: {
|
|
10
|
-
duration: 500
|
|
11
|
-
}
|
|
12
|
+
duration: 500,
|
|
13
|
+
},
|
|
12
14
|
};
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
export function continuousPolarTransitions() {
|
|
17
|
+
export function continuousPolarTransitions(): AnimatePropTypeInterface {
|
|
16
18
|
return {
|
|
17
19
|
onLoad: {
|
|
18
20
|
duration: 2000,
|
|
19
21
|
before: () => ({ _y: 0, _y1: 0, _y0: 0 }),
|
|
20
|
-
after: (datum) => ({ _y: datum._y, _y1: datum._y1, _y0: datum._y0 })
|
|
22
|
+
after: (datum) => ({ _y: datum._y, _y1: datum._y1, _y0: datum._y0 }),
|
|
21
23
|
},
|
|
22
24
|
onExit: {
|
|
23
25
|
duration: 500,
|
|
@@ -29,9 +31,9 @@ export function continuousPolarTransitions() {
|
|
|
29
31
|
return {
|
|
30
32
|
_x: adjacent("_x"),
|
|
31
33
|
_y: adjacent("_y"),
|
|
32
|
-
_y0: adjacent("_y0")
|
|
34
|
+
_y0: adjacent("_y0"),
|
|
33
35
|
};
|
|
34
|
-
}
|
|
36
|
+
},
|
|
35
37
|
},
|
|
36
38
|
onEnter: {
|
|
37
39
|
duration: 500,
|
|
@@ -43,34 +45,34 @@ export function continuousPolarTransitions() {
|
|
|
43
45
|
return {
|
|
44
46
|
_x: adjacent("_x"),
|
|
45
47
|
_y: adjacent("_y"),
|
|
46
|
-
_y0: adjacent("_y0")
|
|
48
|
+
_y0: adjacent("_y0"),
|
|
47
49
|
};
|
|
48
50
|
},
|
|
49
51
|
after: (datum) => ({
|
|
50
52
|
_x: datum._x,
|
|
51
53
|
_y: datum._y,
|
|
52
54
|
_y1: datum._y1,
|
|
53
|
-
_y0: datum._y0
|
|
54
|
-
})
|
|
55
|
-
}
|
|
55
|
+
_y0: datum._y0,
|
|
56
|
+
}),
|
|
57
|
+
},
|
|
56
58
|
};
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
export function discreteTransitions() {
|
|
61
|
+
export function discreteTransitions(): AnimatePropTypeInterface {
|
|
60
62
|
return {
|
|
61
63
|
onLoad: {
|
|
62
64
|
duration: 2000,
|
|
63
65
|
before: () => ({ opacity: 0 }),
|
|
64
|
-
after: (datum) => datum
|
|
66
|
+
after: (datum) => datum,
|
|
65
67
|
},
|
|
66
68
|
onExit: {
|
|
67
69
|
duration: 600,
|
|
68
|
-
before: () => ({ opacity: 0 })
|
|
70
|
+
before: () => ({ opacity: 0 }),
|
|
69
71
|
},
|
|
70
72
|
onEnter: {
|
|
71
73
|
duration: 600,
|
|
72
74
|
before: () => ({ opacity: 0 }),
|
|
73
|
-
after: (datum) => datum
|
|
74
|
-
}
|
|
75
|
+
after: (datum) => datum,
|
|
76
|
+
},
|
|
75
77
|
};
|
|
76
78
|
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
sortedUniq,
|
|
7
7
|
isFunction,
|
|
8
8
|
includes,
|
|
9
|
-
isDate
|
|
9
|
+
isDate,
|
|
10
10
|
} from "lodash";
|
|
11
11
|
import * as Data from "./data";
|
|
12
12
|
import * as Scale from "./scale";
|
|
@@ -47,11 +47,12 @@ function getDomainPadding(props, axis) {
|
|
|
47
47
|
: formatPadding(props.domainPadding);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
function getFlatData(dataset, axis) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
function getFlatData(dataset, axis: "x" | "y") {
|
|
51
|
+
const axisKey = `_${axis}`;
|
|
52
|
+
return flatten(dataset).map((datum: any) => {
|
|
53
|
+
return datum[axisKey] && datum[axisKey][1] !== undefined
|
|
54
|
+
? datum[axisKey][1]
|
|
55
|
+
: datum[axisKey];
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
58
|
|
|
@@ -60,7 +61,7 @@ function getExtremeFromData(dataset, axis, type = "min") {
|
|
|
60
61
|
type === "max" ? Math.max(...arr) : Math.min(...arr);
|
|
61
62
|
const initialValue = type === "max" ? -Infinity : Infinity;
|
|
62
63
|
let containsDate = false;
|
|
63
|
-
const result = flatten(dataset).reduce((memo, datum) => {
|
|
64
|
+
const result = flatten(dataset).reduce((memo: number, datum: any) => {
|
|
64
65
|
const current0 =
|
|
65
66
|
datum[`_${axis}0`] !== undefined ? datum[`_${axis}0`] : datum[`_${axis}`];
|
|
66
67
|
const current1 =
|
|
@@ -94,23 +95,23 @@ function padDomain(domain, props, axis) {
|
|
|
94
95
|
|
|
95
96
|
const paddedRangeExtent = Math.max(
|
|
96
97
|
rangeExtent - padding.left - padding.right,
|
|
97
|
-
1
|
|
98
|
+
1,
|
|
98
99
|
);
|
|
99
100
|
const paddedDomainExtent =
|
|
100
101
|
(Math.abs(max.valueOf() - min.valueOf()) / paddedRangeExtent) * rangeExtent;
|
|
101
102
|
|
|
102
103
|
const simplePadding = {
|
|
103
104
|
left: (paddedDomainExtent * padding.left) / rangeExtent,
|
|
104
|
-
right: (paddedDomainExtent * padding.right) / rangeExtent
|
|
105
|
+
right: (paddedDomainExtent * padding.right) / rangeExtent,
|
|
105
106
|
};
|
|
106
107
|
|
|
107
108
|
let paddedDomain = {
|
|
108
109
|
min: min.valueOf() - simplePadding.left,
|
|
109
|
-
max: max.valueOf() + simplePadding.right
|
|
110
|
+
max: max.valueOf() + simplePadding.right,
|
|
110
111
|
};
|
|
111
112
|
|
|
112
113
|
const singleQuadrantDomainPadding = isPlainObject(
|
|
113
|
-
props.singleQuadrantDomainPadding
|
|
114
|
+
props.singleQuadrantDomainPadding,
|
|
114
115
|
)
|
|
115
116
|
? props.singleQuadrantDomainPadding[axis]
|
|
116
117
|
: props.singleQuadrantDomainPadding;
|
|
@@ -128,14 +129,16 @@ function padDomain(domain, props, axis) {
|
|
|
128
129
|
if (addsQuadrants && singleQuadrantDomainPadding !== false) {
|
|
129
130
|
// Naive initial padding calculation
|
|
130
131
|
const initialPadding = {
|
|
132
|
+
// @ts-expect-error `max/min` might be dates
|
|
131
133
|
left: (Math.abs(max - min) * padding.left) / rangeExtent,
|
|
132
|
-
|
|
134
|
+
// @ts-expect-error `max/min` might be dates
|
|
135
|
+
right: (Math.abs(max - min) * padding.right) / rangeExtent,
|
|
133
136
|
};
|
|
134
137
|
|
|
135
138
|
// Adjust the domain by the initial padding
|
|
136
139
|
const adjustedDomain = {
|
|
137
140
|
min: adjust(min.valueOf() - initialPadding.left, "min"),
|
|
138
|
-
max: adjust(max.valueOf() + initialPadding.right, "max")
|
|
141
|
+
max: adjust(max.valueOf() + initialPadding.right, "max"),
|
|
139
142
|
};
|
|
140
143
|
|
|
141
144
|
// re-calculate padding, taking the adjusted domain into account
|
|
@@ -145,20 +148,20 @@ function padDomain(domain, props, axis) {
|
|
|
145
148
|
rangeExtent,
|
|
146
149
|
right:
|
|
147
150
|
(Math.abs(adjustedDomain.max - adjustedDomain.min) * padding.right) /
|
|
148
|
-
rangeExtent
|
|
151
|
+
rangeExtent,
|
|
149
152
|
};
|
|
150
153
|
|
|
151
154
|
// Adjust the domain by the final padding
|
|
152
155
|
paddedDomain = {
|
|
153
156
|
min: adjust(min.valueOf() - finalPadding.left, "min"),
|
|
154
|
-
max: adjust(max.valueOf() + finalPadding.right, "max")
|
|
157
|
+
max: adjust(max.valueOf() + finalPadding.right, "max"),
|
|
155
158
|
};
|
|
156
159
|
}
|
|
157
160
|
|
|
158
161
|
// default to minDomain / maxDomain if they exist
|
|
159
162
|
const finalDomain = {
|
|
160
163
|
min: minDomain !== undefined ? minDomain : paddedDomain.min,
|
|
161
|
-
max: maxDomain !== undefined ? maxDomain : paddedDomain.max
|
|
164
|
+
max: maxDomain !== undefined ? maxDomain : paddedDomain.max,
|
|
162
165
|
};
|
|
163
166
|
|
|
164
167
|
return min instanceof Date || max instanceof Date
|
|
@@ -177,8 +180,8 @@ function padDomain(domain, props, axis) {
|
|
|
177
180
|
* @returns {Function} a function that takes props and axis and returns a formatted domain
|
|
178
181
|
*/
|
|
179
182
|
export function createDomainFunction(
|
|
180
|
-
getDomainFromDataFunction
|
|
181
|
-
formatDomainFunction
|
|
183
|
+
getDomainFromDataFunction?,
|
|
184
|
+
formatDomainFunction?,
|
|
182
185
|
) {
|
|
183
186
|
getDomainFromDataFunction = isFunction(getDomainFromDataFunction)
|
|
184
187
|
? getDomainFromDataFunction
|
|
@@ -227,7 +230,7 @@ export function getDomain(props, axis) {
|
|
|
227
230
|
* @param {Array} categories: an array of categories corresponding to a given axis
|
|
228
231
|
* @returns {Array|undefined} returns a domain from categories or undefined
|
|
229
232
|
*/
|
|
230
|
-
export function getDomainFromCategories(props, axis, categories) {
|
|
233
|
+
export function getDomainFromCategories(props, axis, categories?) {
|
|
231
234
|
categories = categories || Data.getCategories(props, axis);
|
|
232
235
|
const { polar, startAngle = 0, endAngle = 360 } = props;
|
|
233
236
|
if (!categories) {
|
|
@@ -354,7 +357,7 @@ export function getDomainWithZero(props, axis) {
|
|
|
354
357
|
const dataset = Data.getData(props);
|
|
355
358
|
const y0Min = dataset.reduce(
|
|
356
359
|
(min, datum) => (datum._y0 < min ? datum._y0 : min),
|
|
357
|
-
Infinity
|
|
360
|
+
Infinity,
|
|
358
361
|
);
|
|
359
362
|
|
|
360
363
|
const ensureZero = (domain) => {
|
|
@@ -387,7 +390,7 @@ export function getDomainWithZero(props, axis) {
|
|
|
387
390
|
|
|
388
391
|
return createDomainFunction(getDomainFunction, formatDomainFunction)(
|
|
389
392
|
props,
|
|
390
|
-
axis
|
|
393
|
+
axis,
|
|
391
394
|
);
|
|
392
395
|
}
|
|
393
396
|
|
|
@@ -428,7 +431,7 @@ export function getMinFromProps(props, axis) {
|
|
|
428
431
|
* for a given dimension i.e. only x values.
|
|
429
432
|
* @returns {Array} the symmetric domain
|
|
430
433
|
*/
|
|
431
|
-
export function getSymmetricDomain(domain, values) {
|
|
434
|
+
export function getSymmetricDomain(domain, values: number[]) {
|
|
432
435
|
const processedData = sortedUniq(values.sort((a, b) => a - b));
|
|
433
436
|
const step = processedData[1] - processedData[0];
|
|
434
437
|
return [domain[0], domain[1] + step];
|
|
@@ -461,7 +464,7 @@ export function isDomainComponent(component) {
|
|
|
461
464
|
"pie",
|
|
462
465
|
"scatter",
|
|
463
466
|
"stack",
|
|
464
|
-
"voronoi"
|
|
467
|
+
"voronoi",
|
|
465
468
|
];
|
|
466
469
|
return includes(whitelist, role);
|
|
467
470
|
}
|