victory-core 37.2.0 → 37.3.1

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.
@@ -28,20 +28,16 @@ const orange = {
28
28
  "100": "#FEE2D5",
29
29
  "300": "#FFA981",
30
30
  "500": "#FF6F2C",
31
+ "700": "#FF4E1B",
31
32
  "900": "#D74D26",
32
33
  };
33
34
  const red = {
34
35
  "100": "#FFDCE5",
35
36
  "300": "#FF9EB7",
36
37
  "500": "#F82B60",
38
+ "700": "#D31A3D",
37
39
  "900": "#BA1E45",
38
40
  };
39
- const pink = {
40
- "100": "#FFDAF6",
41
- "300": "#F99DE2",
42
- "500": "#FF08C2",
43
- "900": "#B2158B",
44
- };
45
41
  const purple = {
46
42
  "100": "#EDE3FE",
47
43
  "300": "#CDB0FF",
@@ -52,6 +48,7 @@ const blue = {
52
48
  "100": "#CFDFFF",
53
49
  "300": "#9CC7FF",
54
50
  "500": "#2D7FF9",
51
+ "700": "#0056B3",
55
52
  "900": "#2750AE",
56
53
  };
57
54
  const cyan = {
@@ -70,29 +67,55 @@ const green = {
70
67
  "100": "#D1F7C4",
71
68
  "300": "#93E088",
72
69
  "500": "#20C933",
70
+ "700": "#1B9B2A",
73
71
  "900": "#338A17",
74
72
  };
75
73
 
76
74
  const colors = {
77
75
  blue: blue["500"],
78
- pink: pink["500"],
79
- teal: teal["500"],
80
- purple: purple["500"],
76
+ cyan: cyan["500"],
81
77
  green: green["500"],
78
+ yellow: yellow["500"],
82
79
  orange: orange["500"],
83
- cyan: cyan["500"],
84
80
  red: red["500"],
85
- yellow: yellow["500"],
81
+ purple: purple["500"],
82
+ teal: teal["500"],
86
83
  };
87
84
 
88
85
  const colorScale = Object.values(colors);
89
- const grayscale = [gray["200"], gray["400"], gray["600"], gray["900"]];
90
- const warm = [yellow["500"], orange["500"], red["500"], pink["500"]];
91
- const cool = [cyan["500"], teal["500"], blue["500"], purple["500"]];
92
- const heatmap = [green["500"], yellow["500"], red["500"]];
93
- const redPalette = [red["500"], red["300"], red["100"]];
94
- const greenPalette = [green["500"], green["300"], green["100"]];
95
- const bluePalette = [blue["500"], blue["300"], blue["100"]];
86
+ const grayscale = [
87
+ gray["100"],
88
+ gray["300"],
89
+ gray["500"],
90
+ gray["700"],
91
+ gray["900"],
92
+ ];
93
+ const warm = [
94
+ yellow["300"],
95
+ yellow["500"],
96
+ orange["500"],
97
+ orange["900"],
98
+ red["500"],
99
+ ];
100
+ const cool = [
101
+ purple["500"],
102
+ blue["500"],
103
+ cyan["500"],
104
+ teal["500"],
105
+ green["500"],
106
+ ];
107
+ const heatmap = [
108
+ green["900"],
109
+ green["500"],
110
+ yellow["500"],
111
+ orange["500"],
112
+ red["500"],
113
+ ];
114
+ const redPalette = Object.values(red);
115
+ const greenPalette = Object.values(green);
116
+ const bluePalette = Object.values(blue);
117
+
118
+ const defaultColor = blue["500"];
96
119
 
97
120
  // *
98
121
  // * Typography
@@ -108,7 +131,7 @@ const padding = 8;
108
131
  const baseProps = {
109
132
  width: 450,
110
133
  height: 300,
111
- padding: 50,
134
+ padding: 60,
112
135
  colorScale,
113
136
  };
114
137
  // *
@@ -155,7 +178,7 @@ export const clean: VictoryThemeDefinition = {
155
178
  {
156
179
  style: {
157
180
  data: {
158
- fill: blue["500"],
181
+ fill: defaultColor,
159
182
  strokeWidth: 2,
160
183
  fillOpacity: 0.5,
161
184
  },
@@ -175,7 +198,7 @@ export const clean: VictoryThemeDefinition = {
175
198
  strokeLinejoin,
176
199
  },
177
200
  axisLabel: Object.assign({}, centeredLabelStyles, {
178
- padding,
201
+ padding: 35,
179
202
  stroke: "transparent",
180
203
  }),
181
204
  grid: {
@@ -243,7 +266,7 @@ export const clean: VictoryThemeDefinition = {
243
266
  {
244
267
  style: {
245
268
  data: {
246
- fill: blue["500"],
269
+ fill: defaultColor,
247
270
  padding,
248
271
  strokeWidth: 1,
249
272
  fillOpacity: 0.5,
@@ -263,9 +286,9 @@ export const clean: VictoryThemeDefinition = {
263
286
  medianLabels: Object.assign({}, baseLabelStyles, { padding: 3 }),
264
287
  min: { padding, stroke: gray["400"], strokeWidth: 2 },
265
288
  minLabels: Object.assign({}, baseLabelStyles, { padding: 3 }),
266
- q1: { padding, fill: teal["500"], rx: borderRadius, strokeWidth: 2 },
289
+ q1: { padding, fill: colorScale[0], rx: borderRadius, strokeWidth: 2 },
267
290
  q1Labels: Object.assign({}, baseLabelStyles, { padding: 3 }),
268
- q3: { padding, fill: cyan["500"], rx: borderRadius },
291
+ q3: { padding, fill: colorScale[1], rx: borderRadius },
269
292
  q3Labels: Object.assign({}, baseLabelStyles, { padding: 3 }),
270
293
  },
271
294
  boxWidth: 20,
@@ -283,8 +306,8 @@ export const clean: VictoryThemeDefinition = {
283
306
  labels: Object.assign({}, baseLabelStyles, { padding: 5 }),
284
307
  },
285
308
  candleColors: {
286
- positive: teal["500"],
287
- negative: orange["500"],
309
+ positive: green["500"],
310
+ negative: red["500"],
288
311
  },
289
312
  wickStrokeWidth: 2,
290
313
  },
@@ -350,7 +373,7 @@ export const clean: VictoryThemeDefinition = {
350
373
  data: {
351
374
  fill: "transparent",
352
375
  opacity: 1,
353
- stroke: blue["500"],
376
+ stroke: defaultColor,
354
377
  strokeWidth: 2,
355
378
  strokeLinecap,
356
379
  strokeLinejoin,
@@ -387,7 +410,7 @@ export const clean: VictoryThemeDefinition = {
387
410
  {
388
411
  style: {
389
412
  data: {
390
- fill: purple["500"],
413
+ fill: defaultColor,
391
414
  opacity: 1,
392
415
  stroke: "transparent",
393
416
  strokeWidth: 0,
@@ -426,9 +449,8 @@ export const clean: VictoryThemeDefinition = {
426
449
  style: {
427
450
  data: {
428
451
  fill: blue["100"],
429
- stroke: blue["500"],
452
+ stroke: defaultColor,
430
453
  strokeWidth: 2,
431
- opacity: 0.4,
432
454
  },
433
455
  labels: Object.assign({}, baseLabelStyles, {
434
456
  padding: 5,
@@ -9,6 +9,7 @@ import {
9
9
  PaddingOrCallback,
10
10
  StringOrNumberOrCallback,
11
11
  } from "../types/callbacks";
12
+ import { DomainPropType } from "../types/prop-types";
12
13
 
13
14
  export type BlockProps = {
14
15
  top?: number;
@@ -49,7 +50,7 @@ export interface VictoryAxisCommonProps {
49
50
  axisLabelComponent?: React.ReactElement;
50
51
  axisValue?: number | string | object | Date;
51
52
  dependentAxis?: boolean;
52
- disableInlineStyles?: boolean;
53
+ domain?: DomainPropType;
53
54
  gridComponent?: React.ReactElement;
54
55
  invertAxis?: boolean;
55
56
  style?: {
@@ -356,19 +356,13 @@ export function getChildStyle(child, index, calculatedProps, theme) {
356
356
  };
357
357
  }
358
358
 
359
- export function getStringsFromCategories(childComponents, axis) {
359
+ export function getStringsFromChildrenCategories(childComponents, axis) {
360
360
  const iteratee = (child) => {
361
- const childProps = child.props || {};
362
- if (!Domain.isDomainComponent(child) || !childProps.categories) {
361
+ if (!Domain.isDomainComponent(child)) {
363
362
  return null;
364
363
  }
365
- const categories =
366
- childProps.categories && !Array.isArray(childProps.categories)
367
- ? childProps.categories[axis]
368
- : childProps.props.categories;
369
- const categoryStrings =
370
- categories && categories.filter((val) => typeof val === "string");
371
- return categoryStrings ? Collection.removeUndefined(categoryStrings) : [];
364
+ const childProps = child.props || {};
365
+ return Data.getStringsFromCategories(childProps, axis);
372
366
  };
373
367
  return Helpers.reduceChildren(childComponents.slice(0), iteratee);
374
368
  }
@@ -417,15 +411,14 @@ export function getCategoryAndAxisStringsFromChildren(
417
411
  axis,
418
412
  childComponents,
419
413
  ) {
420
- const categories = isPlainObject(props.categories)
421
- ? props.categories[axis]
422
- : props.categories;
414
+ const categories = Data.getStringsFromCategories(props, axis);
423
415
  const axisComponent = Axis.getAxisComponent(childComponents, axis);
424
416
  const axisStrings = axisComponent
425
417
  ? Data.getStringsFromAxes(axisComponent.props, axis)
426
418
  : [];
427
- const categoryStrings =
428
- categories || getStringsFromCategories(childComponents, axis);
419
+ const categoryStrings = categories.length
420
+ ? categories
421
+ : getStringsFromChildrenCategories(childComponents, axis);
429
422
  return uniq([...categoryStrings, ...axisStrings].flat());
430
423
  }
431
424
 
@@ -445,15 +438,9 @@ export function getStringsFromChildren(props, childComponents) {
445
438
 
446
439
  export function getCategories(props, childComponents, allStrings?) {
447
440
  const xPropCategories =
448
- props.categories && !Array.isArray(props.categories)
449
- ? props.categories.x
450
- : props.categories;
451
-
441
+ props.categories && Data.getStringsFromCategories(props, "x");
452
442
  const yPropCategories =
453
- props.categories && !Array.isArray(props.categories)
454
- ? props.categories.y
455
- : props.categories;
456
-
443
+ props.categories && Data.getStringsFromCategories(props, "y");
457
444
  const fallbackRequired = !xPropCategories || !yPropCategories;
458
445
 
459
446
  const fallbackProps = fallbackRequired