victory-core 36.3.2 → 36.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/dist/victory-core.js +15084 -15018
  2. package/dist/victory-core.min.js +1 -1
  3. package/es/index.d.ts +38 -941
  4. package/es/index.js +19 -28
  5. package/es/types.d.ts +33 -0
  6. package/es/types.js +1 -0
  7. package/es/victory-accessible-group/victory-accessible-group.d.ts +25 -0
  8. package/es/victory-accessible-group/victory-accessible-group.js +35 -45
  9. package/es/victory-animation/util.d.ts +66 -0
  10. package/es/victory-animation/util.js +3 -2
  11. package/es/victory-animation/victory-animation.d.ts +69 -0
  12. package/es/victory-animation/victory-animation.js +92 -102
  13. package/es/victory-clip-container/victory-clip-container.d.ts +76 -0
  14. package/es/victory-clip-container/victory-clip-container.js +75 -82
  15. package/es/victory-container/victory-container.d.ts +99 -0
  16. package/es/victory-container/victory-container.js +97 -107
  17. package/es/victory-label/victory-label.d.ts +61 -0
  18. package/es/victory-label/victory-label.js +43 -31
  19. package/es/victory-portal/portal-context.d.ts +11 -0
  20. package/es/victory-portal/portal-context.js +3 -4
  21. package/es/victory-portal/portal.d.ts +28 -0
  22. package/es/victory-portal/portal.js +44 -50
  23. package/es/victory-portal/victory-portal.d.ts +31 -0
  24. package/es/victory-portal/victory-portal.js +38 -47
  25. package/es/victory-primitives/arc.d.ts +21 -0
  26. package/es/victory-primitives/arc.js +9 -9
  27. package/es/victory-primitives/background.d.ts +22 -0
  28. package/es/victory-primitives/background.js +12 -12
  29. package/es/victory-primitives/border.d.ts +18 -0
  30. package/es/victory-primitives/border.js +9 -9
  31. package/es/victory-primitives/circle.d.ts +2 -0
  32. package/es/victory-primitives/circle.js +17 -10
  33. package/es/victory-primitives/clip-path.d.ts +14 -0
  34. package/es/victory-primitives/clip-path.js +6 -6
  35. package/es/victory-primitives/index.d.ts +14 -0
  36. package/es/victory-primitives/index.js +14 -0
  37. package/es/victory-primitives/line-segment.d.ts +19 -0
  38. package/es/victory-primitives/line-segment.js +9 -9
  39. package/es/victory-primitives/line.d.ts +2 -0
  40. package/es/victory-primitives/line.js +17 -10
  41. package/es/victory-primitives/path.d.ts +2 -0
  42. package/es/victory-primitives/path.js +15 -8
  43. package/es/victory-primitives/point.d.ts +21 -0
  44. package/es/victory-primitives/point.js +15 -23
  45. package/es/victory-primitives/rect.d.ts +2 -0
  46. package/es/victory-primitives/rect.js +17 -10
  47. package/es/victory-primitives/text.d.ts +16 -0
  48. package/es/victory-primitives/text.js +13 -8
  49. package/es/victory-primitives/tspan.d.ts +2 -0
  50. package/es/victory-primitives/tspan.js +7 -6
  51. package/es/victory-primitives/types.d.ts +7 -0
  52. package/es/victory-primitives/types.js +1 -0
  53. package/es/victory-primitives/whisker.d.ts +24 -0
  54. package/es/victory-primitives/whisker.js +12 -12
  55. package/es/victory-theme/grayscale.d.ts +2 -0
  56. package/es/victory-theme/grayscale.js +1 -1
  57. package/es/victory-theme/material.d.ts +2 -0
  58. package/es/victory-theme/material.js +1 -1
  59. package/es/victory-theme/victory-theme-definition.d.ts +244 -0
  60. package/es/victory-theme/victory-theme-definition.js +1 -0
  61. package/es/victory-theme/victory-theme.d.ts +5 -0
  62. package/es/victory-theme/victory-theme.js +6 -5
  63. package/es/victory-transition/victory-transition.d.ts +59 -0
  64. package/es/victory-transition/victory-transition.js +38 -44
  65. package/es/victory-util/add-events.js +328 -319
  66. package/es/victory-util/axis.js +12 -6
  67. package/es/victory-util/collection.js +7 -5
  68. package/es/victory-util/common-props.js +2 -2
  69. package/es/victory-util/data.js +8 -6
  70. package/es/victory-util/default-transitions.js +0 -1
  71. package/es/victory-util/domain.js +7 -5
  72. package/es/victory-util/events.js +8 -4
  73. package/es/victory-util/helpers.js +1 -3
  74. package/es/victory-util/hooks/use-animation-state.js +11 -5
  75. package/es/victory-util/immutable.js +0 -1
  76. package/es/victory-util/label-helpers.js +0 -2
  77. package/es/victory-util/line-helpers.js +1 -1
  78. package/es/victory-util/log.js +0 -1
  79. package/es/victory-util/point-path-helpers.d.ts +9 -0
  80. package/es/victory-util/point-path-helpers.js +59 -61
  81. package/es/victory-util/scale.js +19 -19
  82. package/es/victory-util/selection.d.ts +23 -0
  83. package/es/victory-util/selection.js +0 -2
  84. package/es/victory-util/style.js +0 -2
  85. package/es/victory-util/textsize.d.ts +8 -0
  86. package/es/victory-util/textsize.js +11 -7
  87. package/es/victory-util/timer-context.d.ts +11 -0
  88. package/es/victory-util/timer-context.js +1 -1
  89. package/es/victory-util/timer.d.ts +16 -0
  90. package/es/victory-util/timer.js +16 -13
  91. package/es/victory-util/types.d.ts +188 -0
  92. package/es/victory-util/types.js +1 -0
  93. package/es/victory-util/user-props.js +44 -4
  94. package/es/victory-util/wrapper.js +18 -12
  95. package/lib/index.d.ts +38 -941
  96. package/lib/index.js +201 -189
  97. package/lib/types.d.ts +33 -0
  98. package/lib/types.js +1 -0
  99. package/lib/victory-accessible-group/victory-accessible-group.d.ts +25 -0
  100. package/lib/victory-accessible-group/victory-accessible-group.js +37 -45
  101. package/lib/victory-animation/util.d.ts +66 -0
  102. package/lib/victory-animation/util.js +4 -3
  103. package/lib/victory-animation/victory-animation.d.ts +69 -0
  104. package/lib/victory-animation/victory-animation.js +97 -102
  105. package/lib/victory-clip-container/victory-clip-container.d.ts +76 -0
  106. package/lib/victory-clip-container/victory-clip-container.js +81 -82
  107. package/lib/victory-container/victory-container.d.ts +99 -0
  108. package/lib/victory-container/victory-container.js +102 -107
  109. package/lib/victory-label/victory-label.d.ts +61 -0
  110. package/lib/victory-label/victory-label.js +49 -32
  111. package/lib/victory-portal/portal-context.d.ts +11 -0
  112. package/lib/victory-portal/portal-context.js +4 -5
  113. package/lib/victory-portal/portal.d.ts +28 -0
  114. package/lib/victory-portal/portal.js +49 -50
  115. package/lib/victory-portal/victory-portal.d.ts +31 -0
  116. package/lib/victory-portal/victory-portal.js +43 -47
  117. package/lib/victory-primitives/arc.d.ts +21 -0
  118. package/lib/victory-primitives/arc.js +13 -10
  119. package/lib/victory-primitives/background.d.ts +22 -0
  120. package/lib/victory-primitives/background.js +16 -13
  121. package/lib/victory-primitives/border.d.ts +18 -0
  122. package/lib/victory-primitives/border.js +13 -10
  123. package/lib/victory-primitives/circle.d.ts +2 -0
  124. package/lib/victory-primitives/circle.js +17 -8
  125. package/lib/victory-primitives/clip-path.d.ts +14 -0
  126. package/lib/victory-primitives/clip-path.js +7 -5
  127. package/lib/victory-primitives/index.d.ts +14 -0
  128. package/lib/victory-primitives/index.js +187 -0
  129. package/lib/victory-primitives/line-segment.d.ts +19 -0
  130. package/lib/victory-primitives/line-segment.js +13 -10
  131. package/lib/victory-primitives/line.d.ts +2 -0
  132. package/lib/victory-primitives/line.js +17 -8
  133. package/lib/victory-primitives/path.d.ts +2 -0
  134. package/lib/victory-primitives/path.js +15 -6
  135. package/lib/victory-primitives/point.d.ts +21 -0
  136. package/lib/victory-primitives/point.js +21 -25
  137. package/lib/victory-primitives/rect.d.ts +2 -0
  138. package/lib/victory-primitives/rect.js +17 -8
  139. package/lib/victory-primitives/text.d.ts +16 -0
  140. package/lib/victory-primitives/text.js +14 -7
  141. package/lib/victory-primitives/tspan.d.ts +2 -0
  142. package/lib/victory-primitives/tspan.js +7 -4
  143. package/lib/victory-primitives/types.d.ts +7 -0
  144. package/lib/victory-primitives/types.js +1 -0
  145. package/lib/victory-primitives/whisker.d.ts +24 -0
  146. package/lib/victory-primitives/whisker.js +16 -13
  147. package/lib/victory-theme/grayscale.d.ts +2 -0
  148. package/lib/victory-theme/grayscale.js +3 -3
  149. package/lib/victory-theme/material.d.ts +2 -0
  150. package/lib/victory-theme/material.js +3 -3
  151. package/lib/victory-theme/victory-theme-definition.d.ts +244 -0
  152. package/lib/victory-theme/victory-theme-definition.js +1 -0
  153. package/lib/victory-theme/victory-theme.d.ts +5 -0
  154. package/lib/victory-theme/victory-theme.js +22 -8
  155. package/lib/victory-transition/victory-transition.d.ts +59 -0
  156. package/lib/victory-transition/victory-transition.js +43 -45
  157. package/lib/victory-util/add-events.js +326 -316
  158. package/lib/victory-util/axis.js +20 -11
  159. package/lib/victory-util/collection.js +10 -8
  160. package/lib/victory-util/common-props.js +6 -4
  161. package/lib/victory-util/data.js +13 -7
  162. package/lib/victory-util/default-transitions.js +1 -2
  163. package/lib/victory-util/domain.js +11 -5
  164. package/lib/victory-util/events.js +17 -11
  165. package/lib/victory-util/helpers.js +14 -16
  166. package/lib/victory-util/hooks/index.js +4 -4
  167. package/lib/victory-util/hooks/use-animation-state.js +14 -6
  168. package/lib/victory-util/immutable.js +3 -5
  169. package/lib/victory-util/label-helpers.js +6 -6
  170. package/lib/victory-util/line-helpers.js +4 -2
  171. package/lib/victory-util/log.js +0 -1
  172. package/lib/victory-util/point-path-helpers.d.ts +9 -0
  173. package/lib/victory-util/point-path-helpers.js +86 -73
  174. package/lib/victory-util/prop-types.js +5 -3
  175. package/lib/victory-util/scale.js +24 -21
  176. package/lib/victory-util/selection.d.ts +23 -0
  177. package/lib/victory-util/selection.js +5 -5
  178. package/lib/victory-util/style.js +0 -2
  179. package/lib/victory-util/textsize.d.ts +8 -0
  180. package/lib/victory-util/textsize.js +12 -8
  181. package/lib/victory-util/timer-context.d.ts +11 -0
  182. package/lib/victory-util/timer-context.js +1 -1
  183. package/lib/victory-util/timer.d.ts +16 -0
  184. package/lib/victory-util/timer.js +16 -13
  185. package/lib/victory-util/types.d.ts +188 -0
  186. package/lib/victory-util/types.js +1 -0
  187. package/lib/victory-util/user-props.js +53 -6
  188. package/lib/victory-util/wrapper.js +31 -23
  189. package/package.json +6 -13
  190. package/src/index.ts +42 -0
  191. package/src/types.ts +45 -0
  192. package/src/victory-accessible-group/{victory-accessible-group.js → victory-accessible-group.tsx} +10 -3
  193. package/src/victory-animation/{util.js → util.ts} +5 -4
  194. package/src/victory-animation/{victory-animation.js → victory-animation.tsx} +90 -13
  195. package/src/victory-clip-container/{victory-clip-container.js → victory-clip-container.tsx} +32 -6
  196. package/src/victory-container/{victory-container.js → victory-container.tsx} +70 -26
  197. package/src/victory-label/{victory-label.js → victory-label.tsx} +80 -19
  198. package/src/victory-portal/portal-context.ts +14 -0
  199. package/src/victory-portal/{portal.js → portal.tsx} +23 -12
  200. package/src/victory-portal/{victory-portal.js → victory-portal.tsx} +21 -6
  201. package/src/victory-primitives/{arc.js → arc.tsx} +15 -5
  202. package/src/victory-primitives/{background.js → background.tsx} +17 -7
  203. package/src/victory-primitives/{border.js → border.tsx} +12 -5
  204. package/src/victory-primitives/{circle.js → circle.tsx} +4 -3
  205. package/src/victory-primitives/clip-path.tsx +25 -0
  206. package/src/victory-primitives/index.ts +14 -0
  207. package/src/victory-primitives/{line-segment.js → line-segment.tsx} +13 -5
  208. package/src/victory-primitives/{line.js → line.tsx} +4 -3
  209. package/src/victory-primitives/{path.js → path.tsx} +4 -3
  210. package/src/victory-primitives/{point.js → point.tsx} +25 -20
  211. package/src/victory-primitives/{rect.js → rect.tsx} +4 -2
  212. package/src/victory-primitives/{text.js → text.tsx} +9 -3
  213. package/src/victory-primitives/tspan.tsx +7 -0
  214. package/src/victory-primitives/types.ts +19 -0
  215. package/src/victory-primitives/{whisker.js → whisker.tsx} +20 -7
  216. package/src/victory-theme/{grayscale.js → grayscale.tsx} +2 -1
  217. package/src/victory-theme/{material.js → material.tsx} +2 -1
  218. package/src/victory-theme/victory-theme-definition.ts +261 -0
  219. package/src/victory-theme/victory-theme.tsx +5 -0
  220. package/src/victory-transition/{victory-transition.js → victory-transition.tsx} +68 -19
  221. package/src/victory-util/add-events.js +7 -5
  222. package/src/victory-util/axis.js +3 -1
  223. package/src/victory-util/collection.js +0 -1
  224. package/src/victory-util/common-props.js +2 -2
  225. package/src/victory-util/data.js +0 -1
  226. package/src/victory-util/default-transitions.js +0 -1
  227. package/src/victory-util/domain.js +0 -1
  228. package/src/victory-util/events.js +1 -1
  229. package/src/victory-util/helpers.js +0 -1
  230. package/src/victory-util/immutable.js +0 -1
  231. package/src/victory-util/label-helpers.js +0 -1
  232. package/src/victory-util/line-helpers.js +1 -1
  233. package/src/victory-util/log.js +0 -1
  234. package/src/victory-util/point-path-helpers.ts +119 -0
  235. package/src/victory-util/prop-types.js +0 -1
  236. package/src/victory-util/scale.js +18 -10
  237. package/src/victory-util/selection.d.ts +23 -0
  238. package/src/victory-util/selection.js +0 -1
  239. package/src/victory-util/style.js +0 -1
  240. package/src/victory-util/textsize.d.ts +8 -0
  241. package/src/victory-util/{timer-context.js → timer-context.ts} +0 -0
  242. package/src/victory-util/{timer.js → timer.ts} +20 -5
  243. package/src/victory-util/transitions.js +0 -1
  244. package/src/victory-util/types.ts +247 -0
  245. package/src/victory-util/user-props.js +31 -1
  246. package/src/victory-util/wrapper.js +0 -1
  247. package/src/index.d.ts +0 -941
  248. package/src/index.js +0 -51
  249. package/src/victory-portal/portal-context.js +0 -10
  250. package/src/victory-primitives/clip-path.js +0 -18
  251. package/src/victory-primitives/tspan.js +0 -5
  252. package/src/victory-theme/victory-theme.js +0 -7
  253. package/src/victory-util/point-path-helpers.js +0 -121
@@ -0,0 +1,261 @@
1
+ import * as React from "react";
2
+ import { VictoryCommonThemeProps, VictoryDatableProps } from "../index";
3
+ import { CallbackArgs, StringOrNumberOrCallback } from "../types";
4
+
5
+ export type BlockProps = {
6
+ top?: number;
7
+ bottom?: number;
8
+ left?: number;
9
+ right?: number;
10
+ };
11
+ export type PaddingProps = number | BlockProps;
12
+ export type OrientationTypes = "top" | "bottom" | "left" | "right";
13
+ export type VictoryNumberCallback = (args: CallbackArgs) => number;
14
+ export type VictoryPaddingCallback = (
15
+ args: CallbackArgs
16
+ ) => number | BlockProps;
17
+ export type VictoryOrientationCallback = (
18
+ args: CallbackArgs
19
+ ) => OrientationTypes;
20
+ export type NumberOrCallback = number | VictoryNumberCallback;
21
+ export type PaddingOrCallback = number | BlockProps | VictoryPaddingCallback;
22
+ export type OrientationOrCallback =
23
+ | OrientationTypes
24
+ | VictoryOrientationCallback;
25
+ export type VictoryStyleObject = {
26
+ [K in keyof React.CSSProperties]: StringOrNumberOrCallback;
27
+ };
28
+ export type LabelProps = React.CSSProperties & {
29
+ angle?: number;
30
+ verticalAnchor?: VerticalAnchorType;
31
+ };
32
+ export type VictoryLabelStyleObject = {
33
+ [K in keyof LabelProps]: StringOrNumberOrCallback;
34
+ };
35
+
36
+ /**
37
+ * Style interface used in components/themeing
38
+ */
39
+ export interface VictoryStyleInterface {
40
+ parent?: VictoryStyleObject;
41
+ data?: VictoryStyleObject;
42
+ labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
43
+ border?: VictoryStyleObject;
44
+ }
45
+
46
+ export type TickProps = React.CSSProperties & { size?: number };
47
+ export type VictoryTickStyleObject = {
48
+ [K in keyof TickProps]: StringOrNumberOrCallback;
49
+ };
50
+
51
+ export interface VictoryAxisCommonProps {
52
+ axisComponent?: React.ReactElement;
53
+ axisLabelComponent?: React.ReactElement;
54
+ axisValue?: number | string | object | Date;
55
+ dependentAxis?: boolean;
56
+ disableInlineStyles?: boolean;
57
+ gridComponent?: React.ReactElement;
58
+ invertAxis?: boolean;
59
+ style?: {
60
+ parent?: VictoryStyleObject;
61
+ axis?: VictoryStyleObject;
62
+ axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
63
+ grid?: VictoryStyleObject;
64
+ ticks?: VictoryTickStyleObject;
65
+ tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
66
+ };
67
+ tickComponent?: React.ReactElement;
68
+ tickCount?: number;
69
+ tickLabelComponent?: React.ReactElement;
70
+ tickFormat?:
71
+ | any[]
72
+ | { (tick: any, index: number, ticks: any[]): string | number };
73
+ tickValues?: any[];
74
+ }
75
+
76
+ export type VerticalAnchorType = "start" | "middle" | "end";
77
+ // #region Victory Theme
78
+ // Note: Many SVG attributes are missed in CSSProperties interface
79
+ export interface VictoryThemeDefinition {
80
+ area?: {
81
+ style?: {
82
+ data?: VictoryStyleObject;
83
+ labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
84
+ };
85
+ } & VictoryCommonThemeProps &
86
+ VictoryDatableProps;
87
+ axis?: {
88
+ style?: {
89
+ axis?: VictoryStyleObject;
90
+ axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
91
+ grid?: VictoryStyleObject;
92
+ ticks?: VictoryTickStyleObject;
93
+ tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
94
+ };
95
+ offsetX?: number;
96
+ offsetY?: number;
97
+ } & VictoryCommonThemeProps;
98
+ bar?: {
99
+ style?: {
100
+ data?: VictoryStyleObject;
101
+ labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
102
+ };
103
+ } & VictoryCommonThemeProps &
104
+ VictoryDatableProps;
105
+ boxplot?: {
106
+ style?: {
107
+ max?: VictoryStyleObject;
108
+ maxLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
109
+ median?: VictoryStyleObject;
110
+ medianLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
111
+ min?: VictoryStyleObject;
112
+ minLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
113
+ q1?: VictoryStyleObject;
114
+ q1Labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
115
+ q3?: VictoryStyleObject;
116
+ q3Labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
117
+ };
118
+ boxWidth?: number;
119
+ } & VictoryCommonThemeProps;
120
+ candlestick?: {
121
+ style?: {
122
+ data?: VictoryStyleObject;
123
+ labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
124
+ };
125
+ candleColors?: {
126
+ positive?: string;
127
+ negative?: string;
128
+ };
129
+ } & VictoryCommonThemeProps;
130
+ chart?: VictoryCommonThemeProps;
131
+ dependentAxis?: {
132
+ style?: {
133
+ axis?: VictoryStyleObject;
134
+ axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
135
+ grid?: VictoryStyleObject;
136
+ ticks?: VictoryTickStyleObject;
137
+ tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
138
+ };
139
+ offsetX?: number;
140
+ offsetY?: number;
141
+ orientation?: OrientationTypes;
142
+ } & VictoryCommonThemeProps;
143
+ errorbar?: {
144
+ borderWidth?: number;
145
+ style?: {
146
+ data?: VictoryStyleObject;
147
+ labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
148
+ };
149
+ } & VictoryCommonThemeProps;
150
+ group?: {
151
+ style?: {
152
+ data?: VictoryStyleObject;
153
+ labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
154
+ };
155
+ } & VictoryCommonThemeProps;
156
+ histogram?: {
157
+ style?: {
158
+ data?: VictoryStyleObject;
159
+ labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
160
+ };
161
+ } & VictoryCommonThemeProps;
162
+ independentAxis?: {
163
+ style?: {
164
+ axis?: VictoryStyleObject;
165
+ axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
166
+ grid?: VictoryStyleObject;
167
+ ticks?: VictoryTickStyleObject;
168
+ tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
169
+ };
170
+ offsetX?: number;
171
+ offsetY?: number;
172
+ orientation?: OrientationTypes;
173
+ } & VictoryCommonThemeProps;
174
+ legend?: {
175
+ gutter?: number | BlockProps;
176
+ rowGutter?: number | BlockProps;
177
+ orientation?: string;
178
+ titleOrientation?: string;
179
+ style?: {
180
+ data?: VictoryStyleObject & {
181
+ type?: string;
182
+ };
183
+ border?: VictoryStyleObject;
184
+ labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
185
+ title?: VictoryLabelStyleObject;
186
+ };
187
+ itemsPerRow?: number;
188
+ x?: number;
189
+ y?: number;
190
+ centerTitle?: boolean;
191
+ borderPadding?: number | BlockProps;
192
+ } & VictoryCommonThemeProps;
193
+ line?: {
194
+ style?: {
195
+ data?: VictoryStyleObject;
196
+ labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
197
+ };
198
+ } & VictoryCommonThemeProps &
199
+ VictoryDatableProps;
200
+ pie?: {
201
+ style?: {
202
+ data?: VictoryStyleObject;
203
+ labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
204
+ };
205
+ } & VictoryCommonThemeProps &
206
+ VictoryDatableProps;
207
+ polarAxis?: {
208
+ style?: {
209
+ axis?: VictoryStyleObject;
210
+ axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
211
+ grid?: VictoryStyleObject;
212
+ ticks?: VictoryTickStyleObject;
213
+ tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
214
+ };
215
+ } & VictoryCommonThemeProps;
216
+ polarDependentAxis?: {
217
+ style?: {
218
+ axis?: VictoryStyleObject;
219
+ axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
220
+ grid?: VictoryStyleObject;
221
+ ticks?: VictoryTickStyleObject;
222
+ tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
223
+ };
224
+ } & VictoryCommonThemeProps;
225
+ polarIndependentAxis?: {
226
+ style?: {
227
+ axis?: VictoryStyleObject;
228
+ axisLabel?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
229
+ grid?: VictoryStyleObject;
230
+ ticks?: VictoryTickStyleObject;
231
+ tickLabels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
232
+ };
233
+ } & VictoryCommonThemeProps;
234
+ scatter?: {
235
+ style?: {
236
+ data?: VictoryStyleObject;
237
+ labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
238
+ };
239
+ } & VictoryCommonThemeProps &
240
+ VictoryDatableProps;
241
+ stack?: VictoryCommonThemeProps;
242
+ tooltip?: {
243
+ style?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
244
+ flyoutStyle?: VictoryStyleObject;
245
+ cornerRadius?: NumberOrCallback;
246
+ pointerLength?: NumberOrCallback;
247
+ flyoutPadding?: PaddingOrCallback;
248
+ flyoutWidth?: NumberOrCallback;
249
+ flyoutHeight?: NumberOrCallback;
250
+ orientation?: OrientationOrCallback;
251
+ pointerOrientation?: OrientationOrCallback;
252
+ };
253
+ voronoi?: {
254
+ style?: {
255
+ data?: VictoryStyleObject;
256
+ labels?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
257
+ flyout?: VictoryStyleObject;
258
+ };
259
+ } & VictoryCommonThemeProps &
260
+ VictoryDatableProps;
261
+ }
@@ -0,0 +1,5 @@
1
+ import { grayscale } from "./grayscale";
2
+ import { material } from "./material";
3
+ export * from "./victory-theme-definition";
4
+
5
+ export const VictoryTheme = { grayscale, material };
@@ -1,14 +1,52 @@
1
1
  import React from "react";
2
2
  import PropTypes from "prop-types";
3
- import VictoryAnimation from "../victory-animation/victory-animation";
3
+ import { VictoryAnimation } from "../victory-animation/victory-animation";
4
4
  import * as Collection from "../victory-util/collection";
5
5
  import * as Helpers from "../victory-util/helpers";
6
6
  import TimerContext from "../victory-util/timer-context";
7
7
  import * as Transitions from "../victory-util/transitions";
8
- import { defaults, isFunction, pick, isObject } from "lodash";
8
+ import { defaults, isFunction, pick } from "lodash";
9
9
  import isEqual from "react-fast-compare";
10
+ import Timer from "../victory-util/timer";
10
11
 
11
- export default class VictoryTransition extends React.Component {
12
+ type VictoryTransitionChild = React.ReactElement<
13
+ // Props:
14
+ {
15
+ polar?: boolean;
16
+ domain?: number[] | { x: number[]; y: number[] };
17
+ groupComponent?: React.ReactElement;
18
+ },
19
+ // Type:
20
+ {
21
+ new (props: any): React.Component<any, any>;
22
+ continuous?: boolean;
23
+ }
24
+ >;
25
+ interface VictoryTransitionProps {
26
+ animate?: boolean | any;
27
+ animationWhitelist?: string[];
28
+ children: VictoryTransitionChild;
29
+ }
30
+
31
+ interface VictoryTransitionState {
32
+ oldProps?: VictoryTransitionProps | null;
33
+ nextProps?: VictoryTransitionProps;
34
+ nodesShouldLoad?: boolean;
35
+ nodesDoneLoad?: boolean;
36
+ nodesWillExit?: boolean;
37
+ nodesWillEnter?: boolean;
38
+ nodesShouldEnter?: boolean;
39
+ childrenTransitions?: unknown;
40
+ }
41
+
42
+ export interface VictoryTransition {
43
+ context: React.ContextType<typeof TimerContext>;
44
+ }
45
+
46
+ export class VictoryTransition extends React.Component<
47
+ VictoryTransitionProps,
48
+ VictoryTransitionState
49
+ > {
12
50
  static displayName = "VictoryTransition";
13
51
 
14
52
  static propTypes = {
@@ -18,6 +56,9 @@ export default class VictoryTransition extends React.Component {
18
56
  };
19
57
 
20
58
  static contextType = TimerContext;
59
+ private continuous: boolean;
60
+ private timer: Timer;
61
+ private transitionProps: any;
21
62
 
22
63
  constructor(props, context) {
23
64
  super(props, context);
@@ -28,7 +69,6 @@ export default class VictoryTransition extends React.Component {
28
69
  const child = this.props.children;
29
70
  const polar = child.props.polar;
30
71
  this.continuous = !polar && child.type && child.type.continuous === true;
31
- this.getTransitionState = this.getTransitionState.bind(this);
32
72
  this.timer = this.context.transitionTimer;
33
73
  }
34
74
 
@@ -36,7 +76,7 @@ export default class VictoryTransition extends React.Component {
36
76
  this.setState({ nodesShouldLoad: true }); //eslint-disable-line react/no-did-mount-set-state
37
77
  }
38
78
 
39
- shouldComponentUpdate(nextProps) {
79
+ shouldComponentUpdate(nextProps: VictoryTransitionProps) {
40
80
  if (!isEqual(this.props, nextProps)) {
41
81
  this.timer.bypassAnimation();
42
82
  this.setState(this.getTransitionState(this.props, nextProps), () =>
@@ -50,7 +90,10 @@ export default class VictoryTransition extends React.Component {
50
90
  this.timer.stop();
51
91
  }
52
92
 
53
- getTransitionState(props, nextProps) {
93
+ private getTransitionState(
94
+ props: VictoryTransitionProps,
95
+ nextProps: VictoryTransitionProps
96
+ ): VictoryTransitionState {
54
97
  const { animate } = props;
55
98
  if (!animate) {
56
99
  return {};
@@ -78,7 +121,10 @@ export default class VictoryTransition extends React.Component {
78
121
  }
79
122
  }
80
123
 
81
- getDomainFromChildren(props, axis) {
124
+ private getDomainFromChildren(
125
+ props: VictoryTransitionProps,
126
+ axis: "x" | "y"
127
+ ) {
82
128
  const getChildDomains = (children) => {
83
129
  return children.reduce((memo, child) => {
84
130
  if (child.type && isFunction(child.type.getDomain)) {
@@ -94,8 +140,10 @@ export default class VictoryTransition extends React.Component {
94
140
  }, []);
95
141
  };
96
142
 
97
- const child = React.Children.toArray(props.children)[0];
98
- const childProps = child.props || {};
143
+ const child = React.Children.toArray(
144
+ props.children
145
+ )[0] as VictoryTransitionChild;
146
+ const childProps: any = child.props || {};
99
147
  const domain = Array.isArray(childProps.domain)
100
148
  ? childProps.domain
101
149
  : childProps.domain && childProps.domain[axis];
@@ -121,10 +169,10 @@ export default class VictoryTransition extends React.Component {
121
169
  : this.props;
122
170
  }
123
171
 
124
- pickDomainProps(props) {
125
- const parentState = isObject(props.animate) && props.animate.parentState;
172
+ private pickDomainProps(props: VictoryTransitionProps) {
173
+ const parentState = props.animate?.parentState;
126
174
  if (parentState && parentState.nodesWillExit) {
127
- return this.continous || parentState.continuous
175
+ return this.continuous || parentState.continuous
128
176
  ? parentState.nextProps || this.state.nextProps || props
129
177
  : props;
130
178
  }
@@ -146,13 +194,14 @@ export default class VictoryTransition extends React.Component {
146
194
 
147
195
  render() {
148
196
  const props = this.pickProps();
149
- const getTransitionProps =
150
- isObject(this.props.animate) && this.props.animate.getTransitions
151
- ? this.props.animate.getTransitions
152
- : Transitions.getTransitionPropsFactory(props, this.state, (newState) =>
153
- this.setState(newState)
154
- );
155
- const child = React.Children.toArray(props.children)[0];
197
+ const getTransitionProps = this.props.animate?.getTransitions
198
+ ? this.props.animate.getTransitions
199
+ : Transitions.getTransitionPropsFactory(props, this.state, (newState) =>
200
+ this.setState(newState)
201
+ );
202
+ const child = React.Children.toArray(
203
+ props.children
204
+ )[0] as VictoryTransitionChild;
156
205
  const transitionProps = getTransitionProps(child);
157
206
  this.transitionProps = transitionProps;
158
207
  const domain = {
@@ -13,8 +13,12 @@ import {
13
13
  } from "lodash";
14
14
  import * as Events from "./events";
15
15
  import isEqual from "react-fast-compare";
16
- import VictoryTransition from "../victory-transition/victory-transition";
17
- import * as UserProps from "../victory-util/user-props";
16
+ import { VictoryTransition } from "../victory-transition/victory-transition";
17
+
18
+ // DISCLAIMER:
19
+ // This file is not currently tested, and it is first on the list of files
20
+ // to refactor in our current refactoring effort. Please do not make changes
21
+ // to this file without manual testing and/or refactoring and adding tests.
18
22
 
19
23
  const datumHasXandY = (datum) => {
20
24
  return !isNil(datum._x) && !isNil(datum._y);
@@ -330,7 +334,6 @@ export default (WrappedComponent, options) => {
330
334
 
331
335
  renderData(props, shouldRenderDatum = datumHasXandY) {
332
336
  const { dataComponent, labelComponent, groupComponent } = props;
333
- const userProps = UserProps.getSafeUserProps(props);
334
337
  const dataComponents = this.dataKeys.reduce(
335
338
  (validDataComponents, _dataKey, index) => {
336
339
  const dataProps = this.getComponentProps(
@@ -363,8 +366,7 @@ export default (WrappedComponent, options) => {
363
366
  .filter(Boolean);
364
367
 
365
368
  const children = [...dataComponents, ...labelComponents];
366
- const group = React.cloneElement(groupComponent, userProps, children);
367
- return this.renderContainer(group, children);
369
+ return this.renderContainer(groupComponent, children);
368
370
  }
369
371
  };
370
372
  };
@@ -1,4 +1,3 @@
1
- /* eslint-disable func-style */
2
1
  import React from "react";
3
2
  import {
4
3
  assign,
@@ -239,6 +238,9 @@ export function getTickFormat(props, scale) {
239
238
  const stringMap = props.stringMap && props.stringMap[axis];
240
239
  if (!tickFormat) {
241
240
  const defaultTickFormat = getDefaultTickFormat(props);
241
+ // If there is no user-provided tick format, we use d3's tickFormat function
242
+ // by default. This changed the default formatting for some scale types when
243
+ // we upgraded to d3-scale@4..
242
244
  const scaleTickFormat =
243
245
  scale.tickFormat && isFunction(scale.tickFormat)
244
246
  ? scale.tickFormat()
@@ -1,4 +1,3 @@
1
- /* eslint-disable func-style */
2
1
  /* eslint-disable no-use-before-define */
3
2
 
4
3
  function isNonEmptyArray(collection) {
@@ -120,7 +120,7 @@ export const baseProps = {
120
120
  ),
121
121
  externalEventMutations: PropTypes.arrayOf(
122
122
  PropTypes.shape({
123
- callback: PropTypes.function,
123
+ callback: PropTypes.func,
124
124
  childName: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
125
125
  eventKey: PropTypes.oneOfType([
126
126
  PropTypes.array,
@@ -130,7 +130,7 @@ export const baseProps = {
130
130
  ]),
131
131
  PropTypes.string
132
132
  ]),
133
- mutation: PropTypes.function,
133
+ mutation: PropTypes.func,
134
134
  target: PropTypes.oneOfType([PropTypes.string, PropTypes.array])
135
135
  })
136
136
  ),
@@ -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 {
@@ -1,4 +1,3 @@
1
- /* eslint-disable func-style */
2
1
  export function continuousTransitions() {
3
2
  return {
4
3
  onLoad: {
@@ -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 {
@@ -1,4 +1,4 @@
1
- /* eslint-disable func-style,no-use-before-define */
1
+ /* eslint-disable no-use-before-define */
2
2
  import {
3
3
  assign,
4
4
  isEmpty,
@@ -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 { defaults, isFunction, property, pick, assign, keys } from "lodash";
@@ -1,4 +1,3 @@
1
- /* eslint-disable func-style */
2
1
  export const IMMUTABLE_ITERABLE = "@@__IMMUTABLE_ITERABLE__@@";
3
2
  export const IMMUTABLE_RECORD = "@@__IMMUTABLE_RECORD__@@";
4
3
  export const IMMUTABLE_LIST = "@@__IMMUTABLE_LIST__@@";
@@ -1,4 +1,3 @@
1
- /* eslint-disable func-style */
2
1
  /* eslint-disable no-use-before-define */
3
2
  import * as Helpers from "./helpers";
4
3
  import { defaults } from "lodash";
@@ -1,4 +1,4 @@
1
- import * as d3Shape from "d3-shape";
1
+ import * as d3Shape from "victory-vendor/d3-shape";
2
2
 
3
3
  const defined = (d) => {
4
4
  const y = d._y1 !== undefined ? d._y1 : d._y;
@@ -2,7 +2,6 @@
2
2
  /* eslint-disable no-console */
3
3
 
4
4
  // TODO: Use "warning" npm module like React is switching to.
5
- // eslint-disable-next-line func-style
6
5
  export function warn(message) {
7
6
  if (process.env.NODE_ENV !== "production") {
8
7
  if (console && console.warn) {
@@ -0,0 +1,119 @@
1
+ /*eslint no-magic-numbers: ["error", { "ignore": [0, 1, 2, 2.5, 3] }]*/
2
+ import { range } from "lodash";
3
+
4
+ export function circle(x: number, y: number, size: number) {
5
+ return `M ${x}, ${y}
6
+ m ${-size}, 0
7
+ a ${size}, ${size} 0 1,0 ${size * 2},0
8
+ a ${size}, ${size} 0 1,0 ${-size * 2},0`;
9
+ }
10
+
11
+ export function square(x: number, y: number, size: number) {
12
+ const baseSize = 0.87 * size; // eslint-disable-line no-magic-numbers
13
+ const x0 = x - baseSize;
14
+ const y1 = y + baseSize;
15
+ const distance = x + baseSize - x0;
16
+ return `M ${x0}, ${y1}
17
+ h${distance}
18
+ v-${distance}
19
+ h-${distance}
20
+ z`;
21
+ }
22
+
23
+ export function diamond(x: number, y: number, size: number) {
24
+ const baseSize = 0.87 * size; // eslint-disable-line no-magic-numbers
25
+ const length = Math.sqrt(2 * (baseSize * baseSize));
26
+ return `M ${x}, ${y + length}
27
+ l ${length}, -${length}
28
+ l -${length}, -${length}
29
+ l -${length}, ${length}
30
+ l ${length}, ${length}
31
+ z`;
32
+ }
33
+
34
+ export function triangleDown(x: number, y: number, size: number) {
35
+ const height = (size / 2) * Math.sqrt(3);
36
+ const x0 = x - size;
37
+ const x1 = x + size;
38
+ const y0 = y - size;
39
+ const y1 = y + height;
40
+ return `M ${x0}, ${y0}
41
+ L ${x1}, ${y0}
42
+ L ${x}, ${y1}
43
+ z`;
44
+ }
45
+
46
+ export function triangleUp(x: number, y: number, size: number) {
47
+ const height = (size / 2) * Math.sqrt(3);
48
+ const x0 = x - size;
49
+ const x1 = x + size;
50
+ const y0 = y - height;
51
+ const y1 = y + size;
52
+ return `M ${x0}, ${y1}
53
+ L ${x1}, ${y1}
54
+ L ${x}, ${y0}
55
+ z`;
56
+ }
57
+
58
+ export function plus(x: number, y: number, size: number) {
59
+ const baseSize = 1.1 * size; // eslint-disable-line no-magic-numbers
60
+ const distance = baseSize / 1.5; // eslint-disable-line no-magic-numbers
61
+ return `
62
+ M ${x - distance / 2}, ${y + baseSize}
63
+ v-${distance}
64
+ h-${distance}
65
+ v-${distance}
66
+ h${distance}
67
+ v-${distance}
68
+ h${distance}
69
+ v${distance}
70
+ h${distance}
71
+ v${distance}
72
+ h-${distance}
73
+ v${distance}
74
+ z`;
75
+ }
76
+
77
+ export function cross(x: number, y: number, size: number) {
78
+ const baseSize = 0.8 * size; // eslint-disable-line no-magic-numbers
79
+ const distance = baseSize / 1.5; // eslint-disable-line no-magic-numbers
80
+ return `
81
+ M ${x - distance / 2}, ${y + baseSize + distance}
82
+ v-${distance * 2}
83
+ h-${distance}
84
+ v-${distance}
85
+ h${distance}
86
+ v-${distance}
87
+ h${distance}
88
+ v${distance}
89
+ h${distance}
90
+ v${distance}
91
+ h-${distance}
92
+ v${distance * 2}
93
+ z`;
94
+ }
95
+
96
+ export function minus(x: number, y: number, size: number) {
97
+ const baseSize = 1.1 * size; // eslint-disable-line no-magic-numbers
98
+ const lineHeight = baseSize - baseSize * 0.3; // eslint-disable-line no-magic-numbers
99
+ const x0 = x - baseSize;
100
+ const y1 = y + lineHeight / 2;
101
+ const distance = x + baseSize - x0;
102
+ return `M ${x0}, ${y1}
103
+ h${distance}
104
+ v-${lineHeight}
105
+ h-${distance}
106
+ z`;
107
+ }
108
+
109
+ export function star(x: number, y: number, size: number) {
110
+ const baseSize = 1.35 * size; // eslint-disable-line no-magic-numbers
111
+ const angle = Math.PI / 5; // eslint-disable-line no-magic-numbers
112
+ // eslint-disable-next-line no-magic-numbers
113
+ const starCoords = range(10).map((index) => {
114
+ const length = index % 2 === 0 ? baseSize : baseSize / 2;
115
+ return `${length * Math.sin(angle * (index + 1)) + x},
116
+ ${length * Math.cos(angle * (index + 1)) + y}`;
117
+ });
118
+ return `M ${starCoords.join("L")} z`;
119
+ }
@@ -1,4 +1,3 @@
1
- /* eslint-disable func-style */
2
1
  /*eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1, 2] }]*/
3
2
  import { isFunction, find, isRegExp } from "lodash";
4
3
  import * as Log from "./log";