victory-core 36.4.1 → 36.5.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.
- package/dist/victory-core.js +14463 -11478
- package/dist/victory-core.min.js +1 -1
- package/dist/victory-core.min.js.LICENSE.txt +19 -0
- package/es/index.d.ts +18 -941
- package/es/index.js +18 -73
- package/es/types/callbacks.d.ts +37 -0
- 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 +26 -0
- package/es/victory-accessible-group/victory-accessible-group.js +9 -16
- package/es/victory-animation/util.d.ts +67 -0
- package/es/victory-animation/util.js +7 -4
- package/es/victory-animation/victory-animation.d.ts +70 -0
- package/es/victory-animation/victory-animation.js +60 -67
- package/es/victory-clip-container/victory-clip-container.d.ts +77 -0
- package/es/victory-clip-container/victory-clip-container.js +16 -21
- package/es/victory-container/victory-container.d.ts +100 -0
- package/es/victory-container/victory-container.js +32 -31
- package/es/victory-label/victory-label.d.ts +62 -0
- package/es/victory-label/victory-label.js +14 -9
- package/es/victory-portal/portal-context.d.ts +12 -0
- package/es/victory-portal/portal-context.js +3 -3
- package/es/victory-portal/portal.d.ts +29 -0
- package/es/victory-portal/portal.js +26 -33
- package/es/victory-portal/victory-portal.d.ts +32 -0
- package/es/victory-portal/victory-portal.js +24 -22
- package/es/victory-primitives/arc.d.ts +50 -0
- package/es/victory-primitives/arc.js +4 -5
- package/es/victory-primitives/background.d.ts +51 -0
- package/es/victory-primitives/background.js +5 -6
- package/es/victory-primitives/border.d.ts +44 -0
- package/es/victory-primitives/border.js +4 -5
- package/es/victory-primitives/circle.d.ts +3 -0
- package/es/victory-primitives/circle.js +11 -7
- package/es/victory-primitives/clip-path.d.ts +15 -0
- package/es/victory-primitives/clip-path.js +6 -5
- package/es/victory-primitives/index.d.ts +15 -0
- package/es/victory-primitives/index.js +15 -0
- package/es/victory-primitives/line-segment.d.ts +46 -0
- package/es/victory-primitives/line-segment.js +4 -5
- package/es/victory-primitives/line.d.ts +3 -0
- package/es/victory-primitives/line.js +11 -7
- package/es/victory-primitives/path.d.ts +3 -0
- package/es/victory-primitives/path.js +9 -5
- package/es/victory-primitives/point.d.ts +49 -0
- package/es/victory-primitives/point.js +10 -19
- package/es/victory-primitives/rect.d.ts +3 -0
- package/es/victory-primitives/rect.js +11 -7
- package/es/victory-primitives/text.d.ts +17 -0
- package/es/victory-primitives/text.js +7 -5
- package/es/victory-primitives/tspan.d.ts +3 -0
- package/es/victory-primitives/tspan.js +7 -5
- package/es/victory-primitives/types.d.ts +8 -0
- package/es/victory-primitives/types.js +2 -0
- package/es/victory-primitives/whisker.d.ts +59 -0
- package/es/victory-primitives/whisker.js +4 -5
- 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 +3 -0
- package/es/victory-theme/grayscale.js +3 -2
- package/es/victory-theme/material.d.ts +3 -0
- package/es/victory-theme/material.js +3 -2
- package/es/victory-theme/types.d.ts +239 -0
- package/es/victory-theme/types.js +2 -0
- package/es/victory-theme/victory-theme.d.ts +6 -0
- package/es/victory-theme/victory-theme.js +8 -6
- package/es/victory-transition/victory-transition.d.ts +60 -0
- package/es/victory-transition/victory-transition.js +20 -23
- package/es/victory-util/add-events.d.ts +106 -0
- package/es/victory-util/add-events.js +44 -34
- package/es/victory-util/axis.d.ts +51 -0
- package/es/victory-util/axis.js +9 -8
- package/es/victory-util/collection.d.ts +9 -0
- package/es/victory-util/collection.js +6 -6
- 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 -3
- package/es/victory-util/default-transitions.d.ts +5 -0
- package/es/victory-util/default-transitions.js +2 -2
- package/es/victory-util/domain.d.ts +91 -0
- package/es/victory-util/domain.js +6 -4
- 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 -6
- 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 +2 -1
- 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 -5
- 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 -3
- 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 -2
- package/es/victory-util/point-path-helpers.d.ts +10 -0
- package/es/victory-util/point-path-helpers.js +60 -61
- 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 -0
- package/es/victory-util/selection.js +25 -16
- package/es/victory-util/style.d.ts +19 -0
- package/es/victory-util/style.js +2 -3
- package/es/victory-util/textsize.d.ts +37 -0
- package/es/victory-util/textsize.js +9 -6
- package/es/victory-util/timer-context.d.ts +12 -0
- package/es/victory-util/timer-context.js +2 -1
- package/es/victory-util/timer.d.ts +17 -0
- package/es/victory-util/timer.js +15 -9
- 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 +18 -941
- package/lib/index.js +224 -311
- package/lib/types/callbacks.d.ts +37 -0
- 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 +26 -0
- package/lib/victory-accessible-group/victory-accessible-group.js +10 -15
- package/lib/victory-animation/util.d.ts +67 -0
- package/lib/victory-animation/util.js +7 -4
- package/lib/victory-animation/victory-animation.d.ts +70 -0
- package/lib/victory-animation/victory-animation.js +61 -65
- package/lib/victory-clip-container/victory-clip-container.d.ts +77 -0
- package/lib/victory-clip-container/victory-clip-container.js +20 -22
- package/lib/victory-container/victory-container.d.ts +100 -0
- package/lib/victory-container/victory-container.js +35 -31
- package/lib/victory-label/victory-label.d.ts +62 -0
- package/lib/victory-label/victory-label.js +20 -14
- package/lib/victory-portal/portal-context.d.ts +12 -0
- package/lib/victory-portal/portal-context.js +3 -3
- package/lib/victory-portal/portal.d.ts +29 -0
- package/lib/victory-portal/portal.js +27 -31
- package/lib/victory-portal/victory-portal.d.ts +32 -0
- package/lib/victory-portal/victory-portal.js +25 -20
- package/lib/victory-primitives/arc.d.ts +50 -0
- package/lib/victory-primitives/arc.js +7 -7
- package/lib/victory-primitives/background.d.ts +51 -0
- package/lib/victory-primitives/background.js +9 -9
- package/lib/victory-primitives/border.d.ts +44 -0
- package/lib/victory-primitives/border.js +7 -7
- package/lib/victory-primitives/circle.d.ts +3 -0
- package/lib/victory-primitives/circle.js +12 -6
- package/lib/victory-primitives/clip-path.d.ts +15 -0
- package/lib/victory-primitives/clip-path.js +7 -4
- package/lib/victory-primitives/index.d.ts +15 -0
- package/lib/victory-primitives/index.js +188 -0
- package/lib/victory-primitives/line-segment.d.ts +46 -0
- package/lib/victory-primitives/line-segment.js +7 -7
- package/lib/victory-primitives/line.d.ts +3 -0
- package/lib/victory-primitives/line.js +12 -6
- package/lib/victory-primitives/path.d.ts +3 -0
- package/lib/victory-primitives/path.js +10 -4
- package/lib/victory-primitives/point.d.ts +49 -0
- package/lib/victory-primitives/point.js +15 -22
- package/lib/victory-primitives/rect.d.ts +3 -0
- package/lib/victory-primitives/rect.js +12 -6
- package/lib/victory-primitives/text.d.ts +17 -0
- package/lib/victory-primitives/text.js +8 -4
- package/lib/victory-primitives/tspan.d.ts +3 -0
- package/lib/victory-primitives/tspan.js +8 -4
- package/lib/victory-primitives/types.d.ts +8 -0
- package/lib/victory-primitives/types.js +2 -0
- package/lib/victory-primitives/whisker.d.ts +59 -0
- package/lib/victory-primitives/whisker.js +7 -7
- 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 +3 -0
- package/lib/victory-theme/grayscale.js +4 -3
- package/lib/victory-theme/material.d.ts +3 -0
- package/lib/victory-theme/material.js +4 -3
- package/lib/victory-theme/types.d.ts +239 -0
- package/lib/victory-theme/types.js +2 -0
- package/lib/victory-theme/victory-theme.d.ts +6 -0
- package/lib/victory-theme/victory-theme.js +23 -8
- package/lib/victory-transition/victory-transition.d.ts +60 -0
- package/lib/victory-transition/victory-transition.js +22 -23
- package/lib/victory-util/add-events.d.ts +106 -0
- package/lib/victory-util/add-events.js +48 -40
- 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 -6
- 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 -2
- 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 -6
- 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 +2 -1
- 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 -6
- 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 -3
- 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 -2
- package/lib/victory-util/point-path-helpers.d.ts +10 -0
- package/lib/victory-util/point-path-helpers.js +87 -73
- 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 -0
- package/lib/victory-util/selection.js +25 -21
- package/lib/victory-util/style.d.ts +19 -0
- package/lib/victory-util/style.js +2 -3
- package/lib/victory-util/textsize.d.ts +37 -0
- package/lib/victory-util/textsize.js +9 -6
- package/lib/victory-util/timer-context.d.ts +12 -0
- package/lib/victory-util/timer-context.js +2 -1
- package/lib/victory-util/timer.d.ts +17 -0
- package/lib/victory-util/timer.js +15 -9
- 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 +4 -4
- package/src/index.ts +17 -0
- package/src/types/callbacks.ts +53 -0
- package/src/types/prop-types.ts +195 -0
- package/src/victory-accessible-group/{victory-accessible-group.js → victory-accessible-group.tsx} +13 -6
- package/src/victory-animation/{util.js → util.ts} +6 -4
- package/src/victory-animation/{victory-animation.js → victory-animation.tsx} +100 -23
- package/src/victory-clip-container/{victory-clip-container.js → victory-clip-container.tsx} +52 -28
- package/src/victory-container/{victory-container.js → victory-container.tsx} +86 -42
- package/src/victory-label/{victory-label.js → victory-label.tsx} +108 -49
- package/src/victory-portal/portal-context.ts +14 -0
- package/src/victory-portal/{portal.js → portal.tsx} +24 -13
- package/src/victory-portal/{victory-portal.js → victory-portal.tsx} +24 -9
- package/src/victory-primitives/{arc.js → arc.tsx} +22 -10
- package/src/victory-primitives/{background.js → background.tsx} +24 -12
- package/src/victory-primitives/{border.js → border.tsx} +19 -10
- package/src/victory-primitives/{circle.js → circle.tsx} +4 -3
- package/src/victory-primitives/clip-path.tsx +25 -0
- package/src/victory-primitives/index.ts +14 -0
- package/src/victory-primitives/{line-segment.js → line-segment.tsx} +20 -10
- package/src/victory-primitives/{line.js → line.tsx} +4 -3
- package/src/victory-primitives/{path.js → path.tsx} +4 -3
- package/src/victory-primitives/{point.js → point.tsx} +33 -26
- package/src/victory-primitives/{rect.js → rect.tsx} +4 -2
- package/src/victory-primitives/{text.js → text.tsx} +10 -4
- package/src/victory-primitives/tspan.tsx +7 -0
- package/src/victory-primitives/types.ts +19 -0
- package/src/victory-primitives/{whisker.js → whisker.tsx} +34 -19
- 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.js → grayscale.tsx} +63 -62
- package/src/victory-theme/{material.js → material.tsx} +68 -67
- package/src/victory-theme/types.ts +257 -0
- package/src/victory-theme/victory-theme.tsx +5 -0
- package/src/victory-transition/{victory-transition.js → victory-transition.tsx} +82 -33
- package/src/victory-util/{add-events.js → add-events.tsx} +142 -60
- package/src/victory-util/{axis.js → axis.tsx} +17 -19
- package/src/victory-util/{collection.js → collection.tsx} +14 -11
- package/src/victory-util/common-props.tsx +307 -0
- package/src/victory-util/{data.js → data.ts} +14 -11
- package/src/victory-util/{default-transitions.js → default-transitions.ts} +20 -19
- package/src/victory-util/{domain.js → domain.ts} +26 -24
- package/src/victory-util/{events.js → events.ts} +83 -32
- package/src/victory-util/{helpers.js → helpers.ts} +41 -23
- package/src/victory-util/hooks/{index.js → index.ts} +0 -0
- package/src/victory-util/hooks/use-animation-state.js +10 -10
- package/src/victory-util/hooks/use-previous-props.ts +9 -0
- package/src/victory-util/{immutable.js → immutable.ts} +14 -11
- package/src/victory-util/index.ts +28 -0
- package/src/victory-util/{label-helpers.js → label-helpers.ts} +7 -8
- package/src/victory-util/line-helpers.ts +104 -0
- package/src/victory-util/{log.js → log.ts} +1 -2
- package/src/victory-util/point-path-helpers.ts +119 -0
- package/src/victory-util/{prop-types.js → prop-types.ts} +103 -102
- package/src/victory-util/{scale.js → scale.ts} +29 -17
- package/src/victory-util/selection.ts +158 -0
- package/src/victory-util/{style.js → style.ts} +3 -4
- package/src/victory-util/{textsize.js → textsize.ts} +32 -17
- package/src/victory-util/{timer-context.js → timer-context.ts} +1 -1
- package/src/victory-util/{timer.js → timer.ts} +16 -6
- package/src/victory-util/{transitions.js → transitions.ts} +50 -23
- 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 -34
- package/src/index.d.ts +0 -941
- package/src/index.js +0 -51
- package/src/victory-portal/portal-context.js +0 -10
- package/src/victory-primitives/clip-path.js +0 -18
- package/src/victory-primitives/tspan.js +0 -5
- package/src/victory-theme/victory-theme.js +0 -7
- 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/point-path-helpers.js +0 -121
- package/src/victory-util/selection.js +0 -99
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable func-style */
|
|
2
1
|
import React from "react";
|
|
3
2
|
import {
|
|
4
3
|
assign,
|
|
@@ -12,11 +11,12 @@ import {
|
|
|
12
11
|
orderBy,
|
|
13
12
|
values,
|
|
14
13
|
includes,
|
|
15
|
-
without
|
|
14
|
+
without,
|
|
16
15
|
} from "lodash";
|
|
17
16
|
import * as Collection from "./collection";
|
|
18
17
|
import * as Domain from "./domain";
|
|
19
18
|
import * as Helpers from "./helpers";
|
|
19
|
+
import { D3Scale } from "../types/prop-types";
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Returns the axis (x or y) of a particular axis component
|
|
@@ -35,7 +35,7 @@ export function getAxis(props) {
|
|
|
35
35
|
* @param {Function} predicate: a predicate function that will be called with each
|
|
36
36
|
* @returns {Array} all axis components that pass the given predicate or []
|
|
37
37
|
*/
|
|
38
|
-
export function findAxisComponents(childComponents, predicate) {
|
|
38
|
+
export function findAxisComponents(childComponents, predicate?) {
|
|
39
39
|
predicate = predicate || identity;
|
|
40
40
|
const findAxes = (children) => {
|
|
41
41
|
return children.reduce((memo, child) => {
|
|
@@ -43,7 +43,7 @@ export function findAxisComponents(childComponents, predicate) {
|
|
|
43
43
|
return memo.concat(child);
|
|
44
44
|
} else if (child.props && child.props.children) {
|
|
45
45
|
return memo.concat(
|
|
46
|
-
findAxes(React.Children.toArray(child.props.children))
|
|
46
|
+
findAxes(React.Children.toArray(child.props.children)),
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
return memo;
|
|
@@ -87,7 +87,7 @@ export function getAxisComponentsWithParent(childComponents, type) {
|
|
|
87
87
|
return memo.concat(child);
|
|
88
88
|
} else if (child.props && child.props.children) {
|
|
89
89
|
const childAxis = findComponents(
|
|
90
|
-
React.Children.toArray(child.props.children)
|
|
90
|
+
React.Children.toArray(child.props.children),
|
|
91
91
|
);
|
|
92
92
|
return childAxis.length > 0 ? memo.concat(child) : memo;
|
|
93
93
|
}
|
|
@@ -111,7 +111,7 @@ export function getOrigin(domain) {
|
|
|
111
111
|
: getSingleOrigin(domain.x),
|
|
112
112
|
y: Collection.containsDates(domain.y)
|
|
113
113
|
? new Date(Math.min(...domain.y))
|
|
114
|
-
: getSingleOrigin(domain.y)
|
|
114
|
+
: getSingleOrigin(domain.y),
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -202,9 +202,9 @@ function getTickArray(props) {
|
|
|
202
202
|
? tickValues.map((tick) => stringMap[tick])
|
|
203
203
|
: range(1, tickValues.length + 1);
|
|
204
204
|
}
|
|
205
|
-
const tickArray = ticks ? uniq(ticks) : getTicksFromFormat(
|
|
206
|
-
const buildTickArray = (arr) => {
|
|
207
|
-
const newTickArray = [];
|
|
205
|
+
const tickArray = ticks ? uniq(ticks) : getTicksFromFormat();
|
|
206
|
+
const buildTickArray = (arr: number[]) => {
|
|
207
|
+
const newTickArray = [] as Array<{ value: number; index: number }>;
|
|
208
208
|
const domain = (props.domain && props.domain[axis]) || props.domain;
|
|
209
209
|
if (arr) {
|
|
210
210
|
arr.forEach(function (t, index) {
|
|
@@ -215,13 +215,13 @@ function getTickArray(props) {
|
|
|
215
215
|
) {
|
|
216
216
|
newTickArray.push({
|
|
217
217
|
value: t,
|
|
218
|
-
index
|
|
218
|
+
index,
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
221
|
} else {
|
|
222
222
|
newTickArray.push({
|
|
223
223
|
value: t,
|
|
224
|
-
index
|
|
224
|
+
index,
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
227
|
});
|
|
@@ -249,11 +249,9 @@ export function getTickFormat(props, scale) {
|
|
|
249
249
|
return defaultTickFormat || scaleTickFormat;
|
|
250
250
|
} else if (tickFormat && Array.isArray(tickFormat)) {
|
|
251
251
|
const tickArray = getTickArray(props);
|
|
252
|
-
const tickArrayIndices = tickArray
|
|
253
|
-
? tickArray.map((v) => v.index)
|
|
254
|
-
: undefined;
|
|
252
|
+
const tickArrayIndices = tickArray?.map((v) => v.index);
|
|
255
253
|
const filteredTickFormat = tickFormat.filter((t, index) =>
|
|
256
|
-
tickArrayIndices
|
|
254
|
+
tickArrayIndices?.includes(index),
|
|
257
255
|
);
|
|
258
256
|
return (x, index) => filteredTickFormat[index];
|
|
259
257
|
} else if (tickFormat && isFunction(tickFormat)) {
|
|
@@ -268,7 +266,7 @@ export function getTickFormat(props, scale) {
|
|
|
268
266
|
}
|
|
269
267
|
}
|
|
270
268
|
|
|
271
|
-
function downsampleTicks(ticks, tickCount) {
|
|
269
|
+
function downsampleTicks(ticks: number[], tickCount: number) {
|
|
272
270
|
if (!tickCount || !Array.isArray(ticks) || ticks.length <= tickCount) {
|
|
273
271
|
return ticks;
|
|
274
272
|
}
|
|
@@ -276,7 +274,7 @@ function downsampleTicks(ticks, tickCount) {
|
|
|
276
274
|
return ticks.filter((d, i) => i % k === 0);
|
|
277
275
|
}
|
|
278
276
|
|
|
279
|
-
export function getTicks(props, scale, filterZero) {
|
|
277
|
+
export function getTicks(props, scale: D3Scale, filterZero = false) {
|
|
280
278
|
const { tickCount } = props;
|
|
281
279
|
const tickArray = getTickArray(props);
|
|
282
280
|
const tickValues = tickArray ? tickArray.map((v) => v.value) : undefined;
|
|
@@ -336,7 +334,7 @@ function getDomainFromData(props, axis) {
|
|
|
336
334
|
}
|
|
337
335
|
|
|
338
336
|
// exposed for use by VictoryChart
|
|
339
|
-
export function getDomain(props, axis) {
|
|
337
|
+
export function getDomain(props, axis?) {
|
|
340
338
|
const inherentAxis = getAxis(props);
|
|
341
339
|
if (axis && axis !== inherentAxis) {
|
|
342
340
|
return undefined;
|
|
@@ -383,6 +381,6 @@ export function modifyProps(props, fallbackProps) {
|
|
|
383
381
|
return Helpers.modifyProps(
|
|
384
382
|
assign({}, props, { theme }),
|
|
385
383
|
fallbackProps,
|
|
386
|
-
"axis"
|
|
384
|
+
"axis",
|
|
387
385
|
);
|
|
388
386
|
}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
/* eslint-disable func-style */
|
|
2
|
-
/* eslint-disable no-use-before-define */
|
|
3
|
-
|
|
4
1
|
function isNonEmptyArray(collection) {
|
|
5
2
|
return Array.isArray(collection) && collection.length > 0;
|
|
6
3
|
}
|
|
7
4
|
|
|
8
|
-
export function containsStrings(collection) {
|
|
5
|
+
export function containsStrings<T>(collection: Array<T>) {
|
|
9
6
|
return (
|
|
10
7
|
Array.isArray(collection) &&
|
|
11
8
|
collection.some((value) => typeof value === "string")
|
|
12
9
|
);
|
|
13
10
|
}
|
|
14
11
|
|
|
15
|
-
export function containsDates(collection) {
|
|
12
|
+
export function containsDates(collection: Array<number | Date>): boolean {
|
|
16
13
|
return (
|
|
17
14
|
Array.isArray(collection) &&
|
|
18
15
|
collection.some((value) => value instanceof Date)
|
|
@@ -41,16 +38,22 @@ export function removeUndefined(arr) {
|
|
|
41
38
|
return arr.filter((el) => el !== undefined);
|
|
42
39
|
}
|
|
43
40
|
|
|
44
|
-
export function getMaxValue(
|
|
45
|
-
|
|
41
|
+
export function getMaxValue(
|
|
42
|
+
arr: Array<number | Date>,
|
|
43
|
+
...values: Array<number | Date>
|
|
44
|
+
): number | Date {
|
|
45
|
+
const array = arr.concat(values) as number[];
|
|
46
46
|
return containsDates(array)
|
|
47
|
-
? new Date(Math.max(...array))
|
|
47
|
+
? new Date(Math.max(...array)) // Dates will be coerced to numbers
|
|
48
48
|
: Math.max(...array);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
export function getMinValue(
|
|
52
|
-
|
|
51
|
+
export function getMinValue(
|
|
52
|
+
arr: Array<number | Date>,
|
|
53
|
+
...values: Array<number | Date>
|
|
54
|
+
): number | Date {
|
|
55
|
+
const array = arr.concat(values) as number[];
|
|
53
56
|
return containsDates(array)
|
|
54
|
-
? new Date(Math.min(...array))
|
|
57
|
+
? new Date(Math.min(...array)) // Dates will be coerced to numbers
|
|
55
58
|
: Math.min(...array);
|
|
56
59
|
}
|
|
@@ -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
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable func-style */
|
|
2
1
|
/* eslint-disable no-use-before-define */
|
|
3
2
|
import React from "react";
|
|
4
3
|
import {
|
|
@@ -14,7 +13,7 @@ import {
|
|
|
14
13
|
isEqual,
|
|
15
14
|
includes,
|
|
16
15
|
isUndefined,
|
|
17
|
-
omitBy
|
|
16
|
+
omitBy,
|
|
18
17
|
} from "lodash";
|
|
19
18
|
import * as Helpers from "./helpers";
|
|
20
19
|
import * as Collection from "./collection";
|
|
@@ -26,7 +25,7 @@ import * as Immutable from "./immutable";
|
|
|
26
25
|
function parseDatum(datum) {
|
|
27
26
|
const immutableDatumWhitelist = {
|
|
28
27
|
errorX: true,
|
|
29
|
-
errorY: true
|
|
28
|
+
errorY: true,
|
|
30
29
|
};
|
|
31
30
|
|
|
32
31
|
return Immutable.isImmutable(datum)
|
|
@@ -71,7 +70,7 @@ function cleanData(dataset, props) {
|
|
|
71
70
|
const smallNumber = 1 / Number.MAX_SAFE_INTEGER;
|
|
72
71
|
const scaleType = {
|
|
73
72
|
x: Scale.getScaleType(props, "x"),
|
|
74
|
-
y: Scale.getScaleType(props, "y")
|
|
73
|
+
y: Scale.getScaleType(props, "y"),
|
|
75
74
|
};
|
|
76
75
|
if (scaleType.x !== "log" && scaleType.y !== "log") {
|
|
77
76
|
return dataset;
|
|
@@ -189,7 +188,7 @@ export function createStringMap(props, axis) {
|
|
|
189
188
|
const allStrings = uniq([
|
|
190
189
|
...stringsFromAxes,
|
|
191
190
|
...stringsFromCategories,
|
|
192
|
-
...stringsFromData
|
|
191
|
+
...stringsFromData,
|
|
193
192
|
]);
|
|
194
193
|
return allStrings.length === 0
|
|
195
194
|
? null
|
|
@@ -216,7 +215,7 @@ export function downsample(data, maxPoints, startingIndex = 0) {
|
|
|
216
215
|
const k = Math.pow(2, Math.ceil(Math.log2(dataLength / maxPoints)));
|
|
217
216
|
return data.filter(
|
|
218
217
|
// ensure modulo is always calculated from same reference: i + startingIndex
|
|
219
|
-
(d, i) => (i + startingIndex) % k === 0
|
|
218
|
+
(d, i) => (i + startingIndex) % k === 0,
|
|
220
219
|
);
|
|
221
220
|
}
|
|
222
221
|
return data;
|
|
@@ -229,7 +228,11 @@ export function downsample(data, maxPoints, startingIndex = 0) {
|
|
|
229
228
|
* @param {Array} expectedKeys: an array of expected data keys
|
|
230
229
|
* @returns {Array} the formatted data
|
|
231
230
|
*/
|
|
232
|
-
export function formatData(
|
|
231
|
+
export function formatData(
|
|
232
|
+
dataset: any[],
|
|
233
|
+
props: any,
|
|
234
|
+
expectedKeys?: string[],
|
|
235
|
+
) {
|
|
233
236
|
const isArrayOrIterable =
|
|
234
237
|
Array.isArray(dataset) || Immutable.isIterable(dataset);
|
|
235
238
|
if (!isArrayOrIterable || getLength(dataset) < 1) {
|
|
@@ -241,7 +244,7 @@ export function formatData(dataset, props, expectedKeys) {
|
|
|
241
244
|
|
|
242
245
|
const createAccessor = (name) => {
|
|
243
246
|
return Helpers.createAccessor(
|
|
244
|
-
props[name] !== undefined ? props[name] : name
|
|
247
|
+
props[name] !== undefined ? props[name] : name,
|
|
245
248
|
);
|
|
246
249
|
};
|
|
247
250
|
|
|
@@ -271,7 +274,7 @@ export function formatData(dataset, props, expectedKeys) {
|
|
|
271
274
|
y0:
|
|
272
275
|
expectedKeys.indexOf("y0") !== -1
|
|
273
276
|
? createStringMap(props, "y")
|
|
274
|
-
: undefined
|
|
277
|
+
: undefined,
|
|
275
278
|
};
|
|
276
279
|
}
|
|
277
280
|
|
|
@@ -281,7 +284,7 @@ export function formatData(dataset, props, expectedKeys) {
|
|
|
281
284
|
// eslint-disable-line complexity
|
|
282
285
|
datum = parseDatum(datum);
|
|
283
286
|
const fallbackValues = { x: index, y: datum };
|
|
284
|
-
const processedValues = expectedKeys
|
|
287
|
+
const processedValues = expectedKeys!.reduce((memo, type) => {
|
|
285
288
|
const processedValue = accessor[type](datum);
|
|
286
289
|
const value =
|
|
287
290
|
processedValue !== undefined
|
|
@@ -447,7 +450,7 @@ export function isDataComponent(component) {
|
|
|
447
450
|
"pie",
|
|
448
451
|
"scatter",
|
|
449
452
|
"stack",
|
|
450
|
-
"voronoi"
|
|
453
|
+
"voronoi",
|
|
451
454
|
];
|
|
452
455
|
return includes(whitelist, role);
|
|
453
456
|
}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { AnimatePropTypeInterface } from "../types/prop-types";
|
|
2
|
+
|
|
3
|
+
export function continuousTransitions(): AnimatePropTypeInterface {
|
|
3
4
|
return {
|
|
4
5
|
onLoad: {
|
|
5
|
-
duration: 2000
|
|
6
|
+
duration: 2000,
|
|
6
7
|
},
|
|
7
8
|
onExit: {
|
|
8
|
-
duration: 500
|
|
9
|
+
duration: 500,
|
|
9
10
|
},
|
|
10
11
|
onEnter: {
|
|
11
|
-
duration: 500
|
|
12
|
-
}
|
|
12
|
+
duration: 500,
|
|
13
|
+
},
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
export function continuousPolarTransitions() {
|
|
17
|
+
export function continuousPolarTransitions(): AnimatePropTypeInterface {
|
|
17
18
|
return {
|
|
18
19
|
onLoad: {
|
|
19
20
|
duration: 2000,
|
|
20
21
|
before: () => ({ _y: 0, _y1: 0, _y0: 0 }),
|
|
21
|
-
after: (datum) => ({ _y: datum._y, _y1: datum._y1, _y0: datum._y0 })
|
|
22
|
+
after: (datum) => ({ _y: datum._y, _y1: datum._y1, _y0: datum._y0 }),
|
|
22
23
|
},
|
|
23
24
|
onExit: {
|
|
24
25
|
duration: 500,
|
|
@@ -30,9 +31,9 @@ export function continuousPolarTransitions() {
|
|
|
30
31
|
return {
|
|
31
32
|
_x: adjacent("_x"),
|
|
32
33
|
_y: adjacent("_y"),
|
|
33
|
-
_y0: adjacent("_y0")
|
|
34
|
+
_y0: adjacent("_y0"),
|
|
34
35
|
};
|
|
35
|
-
}
|
|
36
|
+
},
|
|
36
37
|
},
|
|
37
38
|
onEnter: {
|
|
38
39
|
duration: 500,
|
|
@@ -44,34 +45,34 @@ export function continuousPolarTransitions() {
|
|
|
44
45
|
return {
|
|
45
46
|
_x: adjacent("_x"),
|
|
46
47
|
_y: adjacent("_y"),
|
|
47
|
-
_y0: adjacent("_y0")
|
|
48
|
+
_y0: adjacent("_y0"),
|
|
48
49
|
};
|
|
49
50
|
},
|
|
50
51
|
after: (datum) => ({
|
|
51
52
|
_x: datum._x,
|
|
52
53
|
_y: datum._y,
|
|
53
54
|
_y1: datum._y1,
|
|
54
|
-
_y0: datum._y0
|
|
55
|
-
})
|
|
56
|
-
}
|
|
55
|
+
_y0: datum._y0,
|
|
56
|
+
}),
|
|
57
|
+
},
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
export function discreteTransitions() {
|
|
61
|
+
export function discreteTransitions(): AnimatePropTypeInterface {
|
|
61
62
|
return {
|
|
62
63
|
onLoad: {
|
|
63
64
|
duration: 2000,
|
|
64
65
|
before: () => ({ opacity: 0 }),
|
|
65
|
-
after: (datum) => datum
|
|
66
|
+
after: (datum) => datum,
|
|
66
67
|
},
|
|
67
68
|
onExit: {
|
|
68
69
|
duration: 600,
|
|
69
|
-
before: () => ({ opacity: 0 })
|
|
70
|
+
before: () => ({ opacity: 0 }),
|
|
70
71
|
},
|
|
71
72
|
onEnter: {
|
|
72
73
|
duration: 600,
|
|
73
74
|
before: () => ({ opacity: 0 }),
|
|
74
|
-
after: (datum) => datum
|
|
75
|
-
}
|
|
75
|
+
after: (datum) => datum,
|
|
76
|
+
},
|
|
76
77
|
};
|
|
77
78
|
}
|