victory-pie 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # victory-pie
2
2
 
3
+ ## 37.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Added logic to sort pie chart slices by categories prop ([#2934](https://github.com/FormidableLabs/victory/pull/2934))
8
+
9
+ * Remove duplicate types from interfaces ([#2940](https://github.com/FormidableLabs/victory/pull/2940))
10
+
11
+ ## 37.3.0
12
+
3
13
  ## 37.2.0
4
14
 
5
15
  ### Minor Changes
@@ -77,6 +77,30 @@ const getSlices = (props, data) => {
77
77
  });
78
78
  return layoutFunction(data);
79
79
  };
80
+ const getCategoriesFromProps = props => Array.isArray(props.categories) ? props.categories : props?.categories?.x ?? [];
81
+
82
+ /**
83
+ * Sorts data by props.categories or props.categories.x. If all of the data keys aren't
84
+ * included in categories, any remaining data will be appended to the data array.
85
+ * If extraneous categories are included in the categories prop, the will be ignored and
86
+ * have no effect on the rendered component.
87
+ */
88
+ const getDataSortedByCategories = (props, data) => {
89
+ const sorted = [];
90
+ getCategoriesFromProps(props).forEach(category => {
91
+ const idx = data.findIndex(_ref => {
92
+ let {
93
+ x
94
+ } = _ref;
95
+ return x === category;
96
+ });
97
+ if (idx >= 0) {
98
+ const datum = data.splice(idx, 1)[0];
99
+ sorted.push(datum);
100
+ }
101
+ });
102
+ return [...sorted, ...data];
103
+ };
80
104
  const getCalculatedValues = props => {
81
105
  const {
82
106
  colorScale,
@@ -88,7 +112,7 @@ const getCalculatedValues = props => {
88
112
  const padding = victory_core__WEBPACK_IMPORTED_MODULE_3__.getPadding(props);
89
113
  const defaultRadius = getRadius(props, padding);
90
114
  const origin = getOrigin(props, padding);
91
- const data = victory_core__WEBPACK_IMPORTED_MODULE_5__.getData(props);
115
+ const data = getDataSortedByCategories(props, victory_core__WEBPACK_IMPORTED_MODULE_5__.getData(props));
92
116
  const slices = getSlices(props, data);
93
117
  return Object.assign({}, props, {
94
118
  style,
@@ -6106,7 +6130,7 @@ const VictoryPortal = initialProps => {
6106
6130
  ...defaultProps,
6107
6131
  ...initialProps
6108
6132
  };
6109
- const id = lodash_uniqueId__WEBPACK_IMPORTED_MODULE_0___default()();
6133
+ const [id] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(lodash_uniqueId__WEBPACK_IMPORTED_MODULE_0___default()());
6110
6134
  const portalContext = (0,_portal_context__WEBPACK_IMPORTED_MODULE_3__.usePortalContext)();
6111
6135
  if (!portalContext) {
6112
6136
  const msg = "`renderInPortal` is not supported outside of `VictoryContainer`. " + "Component will be rendered in place";
@@ -6454,20 +6478,16 @@ const orange = {
6454
6478
  "100": "#FEE2D5",
6455
6479
  "300": "#FFA981",
6456
6480
  "500": "#FF6F2C",
6481
+ "700": "#FF4E1B",
6457
6482
  "900": "#D74D26"
6458
6483
  };
6459
6484
  const red = {
6460
6485
  "100": "#FFDCE5",
6461
6486
  "300": "#FF9EB7",
6462
6487
  "500": "#F82B60",
6488
+ "700": "#D31A3D",
6463
6489
  "900": "#BA1E45"
6464
6490
  };
6465
- const pink = {
6466
- "100": "#FFDAF6",
6467
- "300": "#F99DE2",
6468
- "500": "#FF08C2",
6469
- "900": "#B2158B"
6470
- };
6471
6491
  const purple = {
6472
6492
  "100": "#EDE3FE",
6473
6493
  "300": "#CDB0FF",
@@ -6478,6 +6498,7 @@ const blue = {
6478
6498
  "100": "#CFDFFF",
6479
6499
  "300": "#9CC7FF",
6480
6500
  "500": "#2D7FF9",
6501
+ "700": "#0056B3",
6481
6502
  "900": "#2750AE"
6482
6503
  };
6483
6504
  const cyan = {
@@ -6496,27 +6517,28 @@ const green = {
6496
6517
  "100": "#D1F7C4",
6497
6518
  "300": "#93E088",
6498
6519
  "500": "#20C933",
6520
+ "700": "#1B9B2A",
6499
6521
  "900": "#338A17"
6500
6522
  };
6501
6523
  const colors = {
6502
6524
  blue: blue["500"],
6503
- pink: pink["500"],
6504
- teal: teal["500"],
6505
- purple: purple["500"],
6525
+ cyan: cyan["500"],
6506
6526
  green: green["500"],
6527
+ yellow: yellow["500"],
6507
6528
  orange: orange["500"],
6508
- cyan: cyan["500"],
6509
6529
  red: red["500"],
6510
- yellow: yellow["500"]
6530
+ purple: purple["500"],
6531
+ teal: teal["500"]
6511
6532
  };
6512
6533
  const colorScale = Object.values(colors);
6513
- const grayscale = [gray["200"], gray["400"], gray["600"], gray["900"]];
6514
- const warm = [yellow["500"], orange["500"], red["500"], pink["500"]];
6515
- const cool = [cyan["500"], teal["500"], blue["500"], purple["500"]];
6516
- const heatmap = [green["500"], yellow["500"], red["500"]];
6517
- const redPalette = [red["500"], red["300"], red["100"]];
6518
- const greenPalette = [green["500"], green["300"], green["100"]];
6519
- const bluePalette = [blue["500"], blue["300"], blue["100"]];
6534
+ const grayscale = [gray["100"], gray["300"], gray["500"], gray["700"], gray["900"]];
6535
+ const warm = [yellow["300"], yellow["500"], orange["500"], orange["900"], red["500"]];
6536
+ const cool = [purple["500"], blue["500"], cyan["500"], teal["500"], green["500"]];
6537
+ const heatmap = [green["900"], green["500"], yellow["500"], orange["500"], red["500"]];
6538
+ const redPalette = Object.values(red);
6539
+ const greenPalette = Object.values(green);
6540
+ const bluePalette = Object.values(blue);
6541
+ const defaultColor = blue["500"];
6520
6542
 
6521
6543
  // *
6522
6544
  // * Typography
@@ -6531,7 +6553,7 @@ const padding = 8;
6531
6553
  const baseProps = {
6532
6554
  width: 450,
6533
6555
  height: 300,
6534
- padding: 50,
6556
+ padding: 60,
6535
6557
  colorScale
6536
6558
  };
6537
6559
  // *
@@ -6575,7 +6597,7 @@ const clean = {
6575
6597
  area: Object.assign({
6576
6598
  style: {
6577
6599
  data: {
6578
- fill: blue["500"],
6600
+ fill: defaultColor,
6579
6601
  strokeWidth: 2,
6580
6602
  fillOpacity: 0.5
6581
6603
  },
@@ -6592,7 +6614,7 @@ const clean = {
6592
6614
  strokeLinejoin
6593
6615
  },
6594
6616
  axisLabel: Object.assign({}, centeredLabelStyles, {
6595
- padding,
6617
+ padding: 35,
6596
6618
  stroke: "transparent"
6597
6619
  }),
6598
6620
  grid: {
@@ -6657,7 +6679,7 @@ const clean = {
6657
6679
  bar: Object.assign({
6658
6680
  style: {
6659
6681
  data: {
6660
- fill: blue["500"],
6682
+ fill: defaultColor,
6661
6683
  padding,
6662
6684
  strokeWidth: 1,
6663
6685
  fillOpacity: 0.5
@@ -6696,7 +6718,7 @@ const clean = {
6696
6718
  }),
6697
6719
  q1: {
6698
6720
  padding,
6699
- fill: teal["500"],
6721
+ fill: colorScale[0],
6700
6722
  rx: borderRadius,
6701
6723
  strokeWidth: 2
6702
6724
  },
@@ -6705,7 +6727,7 @@ const clean = {
6705
6727
  }),
6706
6728
  q3: {
6707
6729
  padding,
6708
- fill: cyan["500"],
6730
+ fill: colorScale[1],
6709
6731
  rx: borderRadius
6710
6732
  },
6711
6733
  q3Labels: Object.assign({}, baseLabelStyles, {
@@ -6726,8 +6748,8 @@ const clean = {
6726
6748
  })
6727
6749
  },
6728
6750
  candleColors: {
6729
- positive: teal["500"],
6730
- negative: orange["500"]
6751
+ positive: green["500"],
6752
+ negative: red["500"]
6731
6753
  },
6732
6754
  wickStrokeWidth: 2
6733
6755
  }, baseProps),
@@ -6793,7 +6815,7 @@ const clean = {
6793
6815
  data: {
6794
6816
  fill: "transparent",
6795
6817
  opacity: 1,
6796
- stroke: blue["500"],
6818
+ stroke: defaultColor,
6797
6819
  strokeWidth: 2,
6798
6820
  strokeLinecap,
6799
6821
  strokeLinejoin
@@ -6824,7 +6846,7 @@ const clean = {
6824
6846
  scatter: Object.assign({
6825
6847
  style: {
6826
6848
  data: {
6827
- fill: purple["500"],
6849
+ fill: defaultColor,
6828
6850
  opacity: 1,
6829
6851
  stroke: "transparent",
6830
6852
  strokeWidth: 0
@@ -6862,9 +6884,8 @@ const clean = {
6862
6884
  style: {
6863
6885
  data: {
6864
6886
  fill: blue["100"],
6865
- stroke: blue["500"],
6866
- strokeWidth: 2,
6867
- opacity: 0.4
6887
+ stroke: defaultColor,
6888
+ strokeWidth: 2
6868
6889
  },
6869
6890
  labels: Object.assign({}, baseLabelStyles, {
6870
6891
  padding: 5,