gifted-charts-core 0.0.39 → 0.0.40

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gifted-charts-core",
3
- "version": "0.0.39",
3
+ "version": "0.0.40",
4
4
  "description": "Mathematical and logical utilities used by react-gifted-charts and react-native-gifted-charts",
5
5
  "main": "./src/index.js",
6
6
  "files": [
@@ -7,6 +7,7 @@ interface IusePieChart {
7
7
  selectedIndex: number;
8
8
  setSelectedIndex: (index: number) => void;
9
9
  startAngle: number;
10
+ endAngle: number;
10
11
  setStartAngle: (angle: number) => void;
11
12
  total: number;
12
13
  setTotal: (total: number) => void;
@@ -29,5 +30,8 @@ interface IusePieChart {
29
30
  paddingHorizontal: number;
30
31
  paddingVertical: number;
31
32
  }
32
- export declare const usePieChart: (props: PieChartPropsType) => IusePieChart;
33
+ interface IPieChartPropsType extends PieChartPropsType {
34
+ pro?: boolean;
35
+ }
36
+ export declare const usePieChart: (props: IPieChartPropsType) => IusePieChart;
33
37
  export {};
@@ -17,14 +17,14 @@ var __read = (this && this.__read) || function (o, n) {
17
17
  import { useEffect, useState } from 'react';
18
18
  import { getTextSizeForPieLabels } from '../utils';
19
19
  export var usePieChart = function (props) {
20
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
20
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
21
21
  var radius = (_a = props.radius) !== null && _a !== void 0 ? _a : 120;
22
22
  var extraRadiusForFocused = (_b = props.extraRadiusForFocused) !== null && _b !== void 0 ? _b : (((_c = props.focusOnPress) !== null && _c !== void 0 ? _c : props.sectionAutoFocus) ? radius / 10 : 0);
23
23
  var pi = props.semiCircle ? Math.PI / 2 : Math.PI;
24
- var _u = __read(useState(-1), 2), selectedIndex = _u[0], setSelectedIndex = _u[1]; // at the start, nothing is selected
24
+ var _w = __read(useState(-1), 2), selectedIndex = _w[0], setSelectedIndex = _w[1]; // at the start, nothing is selected
25
25
  // because we're going to use a useEffect, we need startAngle and total to be state variables
26
- var _v = __read(useState((_d = props.initialAngle) !== null && _d !== void 0 ? _d : (props.semiCircle ? -pi : 0)), 2), startAngle = _v[0], setStartAngle = _v[1];
27
- var _w = __read(useState(0), 2), total = _w[0], setTotal = _w[1];
26
+ var _x = __read(useState((_d = props.initialAngle) !== null && _d !== void 0 ? _d : (props.semiCircle ? -pi : 0)), 2), startAngle = _x[0], setStartAngle = _x[1];
27
+ var _y = __read(useState(0), 2), total = _y[0], setTotal = _y[1];
28
28
  useEffect(function () {
29
29
  var _a;
30
30
  // Update the total, this could be use to replace the forEach : const newTotal = props.data.reduce((acc, item) => acc + item.value, 0);
@@ -63,7 +63,7 @@ export var usePieChart = function (props) {
63
63
  }
64
64
  }
65
65
  }, [selectedIndex]);
66
- var data = props.data, donut = props.donut, isThreeD = props.isThreeD, semiCircle = props.semiCircle, _x = props.inwardExtraLengthForFocused, inwardExtraLengthForFocused = _x === void 0 ? 0 : _x;
66
+ var pro = props.pro, data = props.data, donut = props.donut, isThreeD = props.isThreeD, semiCircle = props.semiCircle, _z = props.inwardExtraLengthForFocused, inwardExtraLengthForFocused = _z === void 0 ? 0 : _z;
67
67
  var canvasWidth = radius * 2;
68
68
  var canvasHeight = isThreeD ? radius * 2.3 : radius * 2;
69
69
  var strokeWidth = (_e = props.strokeWidth) !== null && _e !== void 0 ? _e : 0;
@@ -93,7 +93,8 @@ export var usePieChart = function (props) {
93
93
  pi: pi,
94
94
  selectedIndex: selectedIndex,
95
95
  setSelectedIndex: setSelectedIndex,
96
- startAngle: startAngle,
96
+ startAngle: pro ? (_u = props.startAngle) !== null && _u !== void 0 ? _u : 0 : startAngle,
97
+ endAngle: (_v = props.endAngle) !== null && _v !== void 0 ? _v : Math.PI * 2,
97
98
  setStartAngle: setStartAngle,
98
99
  total: total,
99
100
  setTotal: setTotal,
@@ -10,6 +10,7 @@ interface IusePieChart {
10
10
  selectedIndex: number
11
11
  setSelectedIndex: (index: number) => void
12
12
  startAngle: number
13
+ endAngle: number
13
14
  setStartAngle: (angle: number) => void
14
15
  total: number
15
16
  setTotal: (total: number) => void
@@ -33,7 +34,11 @@ interface IusePieChart {
33
34
  paddingVertical: number
34
35
  }
35
36
 
36
- export const usePieChart = (props: PieChartPropsType): IusePieChart => {
37
+ interface IPieChartPropsType extends PieChartPropsType {
38
+ pro?: boolean
39
+ }
40
+
41
+ export const usePieChart = (props: IPieChartPropsType): IusePieChart => {
37
42
  const radius = props.radius ?? 120
38
43
  const extraRadiusForFocused =
39
44
  props.extraRadiusForFocused ??
@@ -90,6 +95,7 @@ export const usePieChart = (props: PieChartPropsType): IusePieChart => {
90
95
  }, [selectedIndex])
91
96
 
92
97
  const {
98
+ pro,
93
99
  data,
94
100
  donut,
95
101
  isThreeD,
@@ -137,7 +143,8 @@ export const usePieChart = (props: PieChartPropsType): IusePieChart => {
137
143
  pi,
138
144
  selectedIndex,
139
145
  setSelectedIndex,
140
- startAngle,
146
+ startAngle: pro ? props.startAngle ?? 0 : startAngle,
147
+ endAngle: props.endAngle ?? Math.PI * 2,
141
148
  setStartAngle,
142
149
  total,
143
150
  setTotal,
@@ -48,6 +48,11 @@ export interface PieChartPropsType {
48
48
  pieInnerComponentWidth?: number;
49
49
  paddingHorizontal?: number;
50
50
  paddingVertical?: number;
51
+ isAnimated?: boolean;
52
+ startAngle?: number;
53
+ endAngle?: number;
54
+ curvedEdges?: boolean;
55
+ edgesRadius?: number;
51
56
  }
52
57
  export interface pieDataItem {
53
58
  value: number;
@@ -75,6 +80,10 @@ export interface pieDataItem {
75
80
  focused?: boolean;
76
81
  peripheral?: boolean;
77
82
  pieInnerComponent?: (item?: pieDataItem, index?: number) => any;
83
+ isStartEdgeCurved?: boolean;
84
+ isEndEdgeCurved?: boolean;
85
+ startEdgeRadius?: number;
86
+ endEdgeRadius?: number;
78
87
  }
79
88
  export interface PieChartMainProps extends PieChartPropsType {
80
89
  setSelectedIndex: Function;
@@ -51,6 +51,11 @@ export interface PieChartPropsType {
51
51
  pieInnerComponentWidth?: number
52
52
  paddingHorizontal?: number
53
53
  paddingVertical?: number
54
+ isAnimated?: boolean
55
+ startAngle?: number
56
+ endAngle?: number
57
+ curvedEdges?: boolean
58
+ edgesRadius?: number
54
59
  }
55
60
  export interface pieDataItem {
56
61
  value: number
@@ -78,6 +83,10 @@ export interface pieDataItem {
78
83
  focused?: boolean
79
84
  peripheral?: boolean
80
85
  pieInnerComponent?: (item?: pieDataItem, index?: number) => any
86
+ isStartEdgeCurved?: boolean
87
+ isEndEdgeCurved?: boolean
88
+ startEdgeRadius?: number
89
+ endEdgeRadius?: number
81
90
  }
82
91
 
83
92
  export interface PieChartMainProps extends PieChartPropsType {