victory-core 36.4.1 → 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 (227) hide show
  1. package/dist/victory-core.js +874 -879
  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 +8 -16
  9. package/es/victory-animation/util.d.ts +66 -0
  10. package/es/victory-animation/util.js +2 -1
  11. package/es/victory-animation/victory-animation.d.ts +69 -0
  12. package/es/victory-animation/victory-animation.js +59 -67
  13. package/es/victory-clip-container/victory-clip-container.d.ts +76 -0
  14. package/es/victory-clip-container/victory-clip-container.js +15 -21
  15. package/es/victory-container/victory-container.d.ts +99 -0
  16. package/es/victory-container/victory-container.js +31 -31
  17. package/es/victory-label/victory-label.d.ts +61 -0
  18. package/es/victory-label/victory-label.js +13 -8
  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 +25 -33
  23. package/es/victory-portal/victory-portal.d.ts +31 -0
  24. package/es/victory-portal/victory-portal.js +23 -22
  25. package/es/victory-primitives/arc.d.ts +21 -0
  26. package/es/victory-primitives/arc.js +3 -5
  27. package/es/victory-primitives/background.d.ts +22 -0
  28. package/es/victory-primitives/background.js +4 -6
  29. package/es/victory-primitives/border.d.ts +18 -0
  30. package/es/victory-primitives/border.js +3 -5
  31. package/es/victory-primitives/circle.d.ts +2 -0
  32. package/es/victory-primitives/circle.js +11 -8
  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 +3 -5
  39. package/es/victory-primitives/line.d.ts +2 -0
  40. package/es/victory-primitives/line.js +11 -8
  41. package/es/victory-primitives/path.d.ts +2 -0
  42. package/es/victory-primitives/path.js +9 -6
  43. package/es/victory-primitives/point.d.ts +21 -0
  44. package/es/victory-primitives/point.js +9 -19
  45. package/es/victory-primitives/rect.d.ts +2 -0
  46. package/es/victory-primitives/rect.js +11 -8
  47. package/es/victory-primitives/text.d.ts +16 -0
  48. package/es/victory-primitives/text.js +7 -6
  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 +3 -5
  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 +19 -23
  65. package/es/victory-util/add-events.js +6 -3
  66. package/es/victory-util/axis.js +0 -1
  67. package/es/victory-util/collection.js +0 -2
  68. package/es/victory-util/data.js +0 -2
  69. package/es/victory-util/default-transitions.js +0 -1
  70. package/es/victory-util/domain.js +0 -2
  71. package/es/victory-util/helpers.js +0 -2
  72. package/es/victory-util/immutable.js +0 -1
  73. package/es/victory-util/label-helpers.js +0 -2
  74. package/es/victory-util/log.js +0 -1
  75. package/es/victory-util/point-path-helpers.d.ts +9 -0
  76. package/es/victory-util/point-path-helpers.js +59 -61
  77. package/es/victory-util/selection.d.ts +23 -0
  78. package/es/victory-util/selection.js +0 -2
  79. package/es/victory-util/style.js +0 -2
  80. package/es/victory-util/textsize.d.ts +8 -0
  81. package/es/victory-util/timer-context.d.ts +11 -0
  82. package/es/victory-util/timer.d.ts +16 -0
  83. package/es/victory-util/timer.js +13 -8
  84. package/es/victory-util/types.d.ts +188 -0
  85. package/es/victory-util/types.js +1 -0
  86. package/lib/index.d.ts +38 -941
  87. package/lib/index.js +195 -193
  88. package/lib/types.d.ts +33 -0
  89. package/lib/types.js +1 -0
  90. package/lib/victory-accessible-group/victory-accessible-group.d.ts +25 -0
  91. package/lib/victory-accessible-group/victory-accessible-group.js +9 -15
  92. package/lib/victory-animation/util.d.ts +66 -0
  93. package/lib/victory-animation/util.js +2 -1
  94. package/lib/victory-animation/victory-animation.d.ts +69 -0
  95. package/lib/victory-animation/victory-animation.js +60 -65
  96. package/lib/victory-clip-container/victory-clip-container.d.ts +76 -0
  97. package/lib/victory-clip-container/victory-clip-container.js +19 -22
  98. package/lib/victory-container/victory-container.d.ts +99 -0
  99. package/lib/victory-container/victory-container.js +34 -31
  100. package/lib/victory-label/victory-label.d.ts +61 -0
  101. package/lib/victory-label/victory-label.js +19 -13
  102. package/lib/victory-portal/portal-context.d.ts +11 -0
  103. package/lib/victory-portal/portal-context.js +3 -4
  104. package/lib/victory-portal/portal.d.ts +28 -0
  105. package/lib/victory-portal/portal.js +26 -31
  106. package/lib/victory-portal/victory-portal.d.ts +31 -0
  107. package/lib/victory-portal/victory-portal.js +24 -20
  108. package/lib/victory-primitives/arc.d.ts +21 -0
  109. package/lib/victory-primitives/arc.js +5 -6
  110. package/lib/victory-primitives/background.d.ts +22 -0
  111. package/lib/victory-primitives/background.js +7 -8
  112. package/lib/victory-primitives/border.d.ts +18 -0
  113. package/lib/victory-primitives/border.js +5 -6
  114. package/lib/victory-primitives/circle.d.ts +2 -0
  115. package/lib/victory-primitives/circle.js +11 -6
  116. package/lib/victory-primitives/clip-path.d.ts +14 -0
  117. package/lib/victory-primitives/clip-path.js +7 -5
  118. package/lib/victory-primitives/index.d.ts +14 -0
  119. package/lib/victory-primitives/index.js +187 -0
  120. package/lib/victory-primitives/line-segment.d.ts +19 -0
  121. package/lib/victory-primitives/line-segment.js +5 -6
  122. package/lib/victory-primitives/line.d.ts +2 -0
  123. package/lib/victory-primitives/line.js +11 -6
  124. package/lib/victory-primitives/path.d.ts +2 -0
  125. package/lib/victory-primitives/path.js +9 -4
  126. package/lib/victory-primitives/point.d.ts +21 -0
  127. package/lib/victory-primitives/point.js +13 -21
  128. package/lib/victory-primitives/rect.d.ts +2 -0
  129. package/lib/victory-primitives/rect.js +11 -6
  130. package/lib/victory-primitives/text.d.ts +16 -0
  131. package/lib/victory-primitives/text.js +8 -5
  132. package/lib/victory-primitives/tspan.d.ts +2 -0
  133. package/lib/victory-primitives/tspan.js +7 -4
  134. package/lib/victory-primitives/types.d.ts +7 -0
  135. package/lib/victory-primitives/types.js +1 -0
  136. package/lib/victory-primitives/whisker.d.ts +24 -0
  137. package/lib/victory-primitives/whisker.js +5 -6
  138. package/lib/victory-theme/grayscale.d.ts +2 -0
  139. package/lib/victory-theme/grayscale.js +3 -3
  140. package/lib/victory-theme/material.d.ts +2 -0
  141. package/lib/victory-theme/material.js +3 -3
  142. package/lib/victory-theme/victory-theme-definition.d.ts +244 -0
  143. package/lib/victory-theme/victory-theme-definition.js +1 -0
  144. package/lib/victory-theme/victory-theme.d.ts +5 -0
  145. package/lib/victory-theme/victory-theme.js +22 -8
  146. package/lib/victory-transition/victory-transition.d.ts +59 -0
  147. package/lib/victory-transition/victory-transition.js +21 -23
  148. package/lib/victory-util/add-events.js +8 -4
  149. package/lib/victory-util/collection.js +0 -2
  150. package/lib/victory-util/default-transitions.js +0 -1
  151. package/lib/victory-util/helpers.js +0 -2
  152. package/lib/victory-util/immutable.js +0 -2
  153. package/lib/victory-util/label-helpers.js +0 -2
  154. package/lib/victory-util/log.js +0 -1
  155. package/lib/victory-util/point-path-helpers.d.ts +9 -0
  156. package/lib/victory-util/point-path-helpers.js +86 -73
  157. package/lib/victory-util/selection.d.ts +23 -0
  158. package/lib/victory-util/selection.js +0 -2
  159. package/lib/victory-util/style.js +0 -2
  160. package/lib/victory-util/textsize.d.ts +8 -0
  161. package/lib/victory-util/timer-context.d.ts +11 -0
  162. package/lib/victory-util/timer.d.ts +16 -0
  163. package/lib/victory-util/timer.js +13 -8
  164. package/lib/victory-util/types.d.ts +188 -0
  165. package/lib/victory-util/types.js +1 -0
  166. package/package.json +4 -4
  167. package/src/index.ts +42 -0
  168. package/src/types.ts +45 -0
  169. package/src/victory-accessible-group/{victory-accessible-group.js → victory-accessible-group.tsx} +10 -3
  170. package/src/victory-animation/{util.js → util.ts} +4 -3
  171. package/src/victory-animation/{victory-animation.js → victory-animation.tsx} +89 -12
  172. package/src/victory-clip-container/{victory-clip-container.js → victory-clip-container.tsx} +29 -5
  173. package/src/victory-container/{victory-container.js → victory-container.tsx} +70 -26
  174. package/src/victory-label/{victory-label.js → victory-label.tsx} +71 -14
  175. package/src/victory-portal/portal-context.ts +14 -0
  176. package/src/victory-portal/{portal.js → portal.tsx} +23 -12
  177. package/src/victory-portal/{victory-portal.js → victory-portal.tsx} +21 -6
  178. package/src/victory-primitives/{arc.js → arc.tsx} +15 -5
  179. package/src/victory-primitives/{background.js → background.tsx} +17 -7
  180. package/src/victory-primitives/{border.js → border.tsx} +12 -5
  181. package/src/victory-primitives/{circle.js → circle.tsx} +4 -3
  182. package/src/victory-primitives/clip-path.tsx +25 -0
  183. package/src/victory-primitives/index.ts +14 -0
  184. package/src/victory-primitives/{line-segment.js → line-segment.tsx} +13 -5
  185. package/src/victory-primitives/{line.js → line.tsx} +4 -3
  186. package/src/victory-primitives/{path.js → path.tsx} +4 -3
  187. package/src/victory-primitives/{point.js → point.tsx} +25 -20
  188. package/src/victory-primitives/{rect.js → rect.tsx} +4 -2
  189. package/src/victory-primitives/{text.js → text.tsx} +9 -3
  190. package/src/victory-primitives/tspan.tsx +7 -0
  191. package/src/victory-primitives/types.ts +19 -0
  192. package/src/victory-primitives/{whisker.js → whisker.tsx} +20 -7
  193. package/src/victory-theme/{grayscale.js → grayscale.tsx} +2 -1
  194. package/src/victory-theme/{material.js → material.tsx} +2 -1
  195. package/src/victory-theme/victory-theme-definition.ts +261 -0
  196. package/src/victory-theme/victory-theme.tsx +5 -0
  197. package/src/victory-transition/{victory-transition.js → victory-transition.tsx} +68 -19
  198. package/src/victory-util/add-events.js +6 -1
  199. package/src/victory-util/axis.js +0 -1
  200. package/src/victory-util/collection.js +0 -1
  201. package/src/victory-util/data.js +0 -1
  202. package/src/victory-util/default-transitions.js +0 -1
  203. package/src/victory-util/domain.js +0 -1
  204. package/src/victory-util/events.js +1 -1
  205. package/src/victory-util/helpers.js +0 -1
  206. package/src/victory-util/immutable.js +0 -1
  207. package/src/victory-util/label-helpers.js +0 -1
  208. package/src/victory-util/log.js +0 -1
  209. package/src/victory-util/point-path-helpers.ts +119 -0
  210. package/src/victory-util/prop-types.js +0 -1
  211. package/src/victory-util/scale.js +0 -1
  212. package/src/victory-util/selection.d.ts +23 -0
  213. package/src/victory-util/selection.js +0 -1
  214. package/src/victory-util/style.js +0 -1
  215. package/src/victory-util/textsize.d.ts +8 -0
  216. package/src/victory-util/{timer-context.js → timer-context.ts} +0 -0
  217. package/src/victory-util/{timer.js → timer.ts} +19 -4
  218. package/src/victory-util/transitions.js +0 -1
  219. package/src/victory-util/types.ts +247 -0
  220. package/src/victory-util/wrapper.js +0 -1
  221. package/src/index.d.ts +0 -941
  222. package/src/index.js +0 -51
  223. package/src/victory-portal/portal-context.js +0 -10
  224. package/src/victory-primitives/clip-path.js +0 -18
  225. package/src/victory-primitives/tspan.js +0 -5
  226. package/src/victory-theme/victory-theme.js +0 -7
  227. package/src/victory-util/point-path-helpers.js +0 -121
@@ -1,15 +1,16 @@
1
1
  import React from "react";
2
+ import { VictoryPrimitiveShapeProps } from "./types";
2
3
 
3
- const Line = (props) => {
4
+ export const Line = (props: VictoryPrimitiveShapeProps) => {
4
5
  // eslint-disable-next-line react/prop-types
5
6
  const { desc, ...rest } = props;
6
7
  return desc ? (
8
+ // @ts-expect-error FIXME: "id cannot be a number"
7
9
  <line vectorEffect="non-scaling-stroke" {...rest}>
8
10
  <desc>{desc}</desc>
9
11
  </line>
10
12
  ) : (
13
+ // @ts-expect-error FIXME: "id cannot be a number"
11
14
  <line vectorEffect="non-scaling-stroke" {...rest} />
12
15
  );
13
16
  };
14
-
15
- export default Line;
@@ -1,15 +1,16 @@
1
1
  import React from "react";
2
+ import { VictoryPrimitiveShapeProps } from "./types";
2
3
 
3
- const Path = (props) => {
4
+ export const Path = (props: VictoryPrimitiveShapeProps) => {
4
5
  // eslint-disable-next-line react/prop-types
5
6
  const { desc, ...rest } = props;
6
7
  return desc ? (
8
+ // @ts-expect-error FIXME: "id cannot be a number"
7
9
  <path {...rest}>
8
10
  <desc>{desc}</desc>
9
11
  </path>
10
12
  ) : (
13
+ // @ts-expect-error FIXME: "id cannot be a number"
11
14
  <path {...rest} />
12
15
  );
13
16
  };
14
-
15
- export default Path;
@@ -1,27 +1,32 @@
1
- import React from "react";
2
- import PropTypes from "prop-types";
3
1
  import { assign } from "lodash";
2
+ import PropTypes from "prop-types";
3
+ import React from "react";
4
4
  import * as Helpers from "../victory-util/helpers";
5
- import pathHelpers from "../victory-util/point-path-helpers";
5
+ import * as pathHelpers from "../victory-util/point-path-helpers";
6
6
  import * as CommonProps from "../victory-util/common-props";
7
- import Path from "./path";
7
+ import * as UserProps from "../victory-util/user-props";
8
+ import { Path } from "./path";
9
+ import { VictoryCommonPrimitiveProps } from "../victory-util/types";
10
+ import { ScatterSymbolType } from "./types";
11
+
12
+ export interface PointProps extends VictoryCommonPrimitiveProps {
13
+ datum?: any;
14
+ getPath?: (x: number, y: number, size: number) => string;
15
+ pathComponent?: React.ReactElement;
16
+ // eslint-disable-next-line @typescript-eslint/ban-types
17
+ size?: number | Function;
18
+ // eslint-disable-next-line @typescript-eslint/ban-types
19
+ symbol?: ScatterSymbolType | Function;
20
+ x?: number;
21
+ y?: number;
22
+ }
8
23
 
9
24
  const getPath = (props) => {
10
25
  const { x, y, size, symbol } = props;
11
26
  if (props.getPath) {
12
27
  return props.getPath(x, y, size);
13
28
  }
14
- const pathFunctions = {
15
- circle: pathHelpers.circle,
16
- square: pathHelpers.square,
17
- diamond: pathHelpers.diamond,
18
- triangleDown: pathHelpers.triangleDown,
19
- triangleUp: pathHelpers.triangleUp,
20
- plus: pathHelpers.plus,
21
- minus: pathHelpers.minus,
22
- star: pathHelpers.star,
23
- cross: pathHelpers.cross
24
- };
29
+ const pathFunctions = pathHelpers;
25
30
  const symbolFunction =
26
31
  typeof pathFunctions[symbol] === "function"
27
32
  ? pathFunctions[symbol]
@@ -59,10 +64,11 @@ const evaluateProps = (props) => {
59
64
  });
60
65
  };
61
66
 
62
- const Point = (props) => {
67
+ export const Point = (props: PointProps) => {
63
68
  props = evaluateProps(props);
69
+ const userProps = UserProps.getSafeUserProps(props);
64
70
 
65
- return React.cloneElement(props.pathComponent, {
71
+ return React.cloneElement(props.pathComponent!, {
66
72
  ...props.events,
67
73
  "aria-label": props.ariaLabel,
68
74
  d: getPath(props),
@@ -73,7 +79,8 @@ const Point = (props) => {
73
79
  shapeRendering: props.shapeRendering,
74
80
  className: props.className,
75
81
  transform: props.transform,
76
- clipPath: props.clipPath
82
+ clipPath: props.clipPath,
83
+ ...userProps
77
84
  });
78
85
  };
79
86
 
@@ -106,5 +113,3 @@ Point.defaultProps = {
106
113
  role: "presentation",
107
114
  shapeRendering: "auto"
108
115
  };
109
-
110
- export default Point;
@@ -1,14 +1,16 @@
1
1
  import React from "react";
2
+ import { VictoryPrimitiveShapeProps } from "./types";
2
3
 
3
- const Rect = (props) => {
4
+ export const Rect = (props: VictoryPrimitiveShapeProps) => {
4
5
  // eslint-disable-next-line react/prop-types
5
6
  const { desc, ...rest } = props;
6
7
  return desc ? (
8
+ // @ts-expect-error FIXME: "id cannot be a number"
7
9
  <rect vectorEffect="non-scaling-stroke" {...rest}>
8
10
  <desc>{desc}</desc>
9
11
  </rect>
10
12
  ) : (
13
+ // @ts-expect-error FIXME: "id cannot be a number"
11
14
  <rect vectorEffect="non-scaling-stroke" {...rest} />
12
15
  );
13
16
  };
14
- export default Rect;
@@ -1,9 +1,17 @@
1
1
  import React from "react";
2
2
  import PropTypes from "prop-types";
3
+ import { VictoryCommonPrimitiveProps } from "../victory-util/types";
3
4
 
4
- const Text = (props) => {
5
+ export interface TextProps extends VictoryCommonPrimitiveProps {
6
+ children?: React.ReactNode;
7
+ desc?: string;
8
+ title?: string;
9
+ }
10
+
11
+ export const Text = (props: TextProps) => {
5
12
  const { children, title, desc, ...rest } = props;
6
13
  return (
14
+ // @ts-expect-error FIXME: "id cannot be a number"
7
15
  <text {...rest}>
8
16
  {title && <title>{title}</title>}
9
17
  {desc && <desc>{desc}</desc>}
@@ -17,5 +25,3 @@ Text.propTypes = {
17
25
  desc: PropTypes.string,
18
26
  title: PropTypes.string
19
27
  };
20
-
21
- export default Text;
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { VictoryCommonPrimitiveProps } from "../victory-util/types";
3
+
4
+ export const TSpan = (props: VictoryCommonPrimitiveProps) => (
5
+ // @ts-expect-error FIXME: "id cannot be a number"
6
+ <tspan {...props} />
7
+ );
@@ -0,0 +1,19 @@
1
+ import { VictoryCommonPrimitiveProps } from "../victory-util/types";
2
+
3
+ export type ScatterSymbolType =
4
+ | "circle"
5
+ | "cross"
6
+ | "diamond"
7
+ | "plus"
8
+ | "minus"
9
+ | "square"
10
+ | "star"
11
+ | "triangleDown"
12
+ | "triangleUp";
13
+
14
+ export interface VictoryPrimitiveShapeProps
15
+ extends VictoryCommonPrimitiveProps {
16
+ desc?: string;
17
+ rx?: number;
18
+ ry?: number;
19
+ }
@@ -3,7 +3,22 @@ import { assign } from "lodash";
3
3
  import PropTypes from "prop-types";
4
4
  import * as Helpers from "../victory-util/helpers";
5
5
  import * as CommonProps from "../victory-util/common-props";
6
- import Line from "./line";
6
+ import { Line } from "./line";
7
+ import { VictoryCommonPrimitiveProps } from "../victory-util/types";
8
+
9
+ export type WhiskerAxes = {
10
+ x1?: number;
11
+ x2?: number;
12
+ y1?: number;
13
+ y2?: number;
14
+ };
15
+
16
+ export interface WhiskerProps extends VictoryCommonPrimitiveProps {
17
+ groupComponent?: React.ReactElement;
18
+ lineComponent?: React.ReactElement;
19
+ majorWhisker?: WhiskerAxes;
20
+ minorWhisker?: WhiskerAxes;
21
+ }
7
22
 
8
23
  const evaluateProps = (props) => {
9
24
  /**
@@ -23,7 +38,7 @@ const evaluateProps = (props) => {
23
38
  return assign({}, props, { ariaLabel, desc, id, style, tabIndex });
24
39
  };
25
40
 
26
- const Whisker = (props) => {
41
+ export const Whisker = (props: WhiskerProps) => {
27
42
  props = evaluateProps(props);
28
43
  const {
29
44
  ariaLabel,
@@ -53,9 +68,9 @@ const Whisker = (props) => {
53
68
  shapeRendering
54
69
  };
55
70
 
56
- return React.cloneElement(groupComponent, {}, [
71
+ return React.cloneElement(groupComponent!, {}, [
57
72
  React.cloneElement(
58
- lineComponent,
73
+ lineComponent!,
59
74
  assign(
60
75
  { key: "major-whisker", "aria-label": ariaLabel },
61
76
  baseProps,
@@ -63,7 +78,7 @@ const Whisker = (props) => {
63
78
  )
64
79
  ),
65
80
  React.cloneElement(
66
- lineComponent,
81
+ lineComponent!,
67
82
  assign(
68
83
  { key: "minor-whisker", "aria-label": ariaLabel },
69
84
  baseProps,
@@ -97,5 +112,3 @@ Whisker.defaultProps = {
97
112
  role: "presentation",
98
113
  shapeRendering: "auto"
99
114
  };
100
-
101
- export default Whisker;
@@ -1,4 +1,5 @@
1
1
  import { assign } from "lodash";
2
+ import { VictoryThemeDefinition } from "./victory-theme-definition";
2
3
 
3
4
  // *
4
5
  // * Colors
@@ -49,7 +50,7 @@ const centeredLabelStyles = assign({ textAnchor: "middle" }, baseLabelStyles);
49
50
  const strokeLinecap = "round";
50
51
  const strokeLinejoin = "round";
51
52
 
52
- export default {
53
+ export const grayscale: VictoryThemeDefinition = {
53
54
  area: assign(
54
55
  {
55
56
  style: {
@@ -1,4 +1,5 @@
1
1
  import { assign } from "lodash";
2
+ import { VictoryThemeDefinition } from "./victory-theme-definition";
2
3
 
3
4
  // *
4
5
  // * Colors
@@ -57,7 +58,7 @@ const strokeDasharray = "10, 5";
57
58
  const strokeLinecap = "round";
58
59
  const strokeLinejoin = "round";
59
60
 
60
- export default {
61
+ export const material: VictoryThemeDefinition = {
61
62
  area: assign(
62
63
  {
63
64
  style: {
@@ -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 };