react-native-gifted-charts 1.2.16 → 1.2.19
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/LICENSE +21 -0
- package/package.json +1 -1
- package/src/BarChart/RenderBars.tsx +4 -2
- package/src/BarChart/RenderStackBars.tsx +3 -1
- package/src/BarChart/index.tsx +8 -2
- package/src/LineChart/index.tsx +55 -33
- package/src/PieChart/index.tsx +80 -42
- package/src/todos.md +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Abhinandan Kushwaha
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gifted-charts",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.19",
|
|
4
4
|
"description": "The most complete library for Bar, Line, Area, Pie, Donut and Stacked Bar charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
|
|
5
5
|
"main": "src/index.tsx",
|
|
6
6
|
"files": [
|
|
@@ -64,6 +64,7 @@ type Props = {
|
|
|
64
64
|
patternId?: String;
|
|
65
65
|
barMarginBottom?: number;
|
|
66
66
|
onPress?: Function;
|
|
67
|
+
xAxisTextNumberOfLines: number;
|
|
67
68
|
};
|
|
68
69
|
type itemType = {
|
|
69
70
|
value?: number;
|
|
@@ -112,6 +113,7 @@ const RenderBars = (props: Props) => {
|
|
|
112
113
|
autoShiftLabels,
|
|
113
114
|
label,
|
|
114
115
|
labelTextStyle,
|
|
116
|
+
xAxisTextNumberOfLines,
|
|
115
117
|
} = props;
|
|
116
118
|
|
|
117
119
|
const barMarginBottom =
|
|
@@ -161,7 +163,7 @@ const RenderBars = (props: Props) => {
|
|
|
161
163
|
) : (
|
|
162
164
|
<Text
|
|
163
165
|
style={labelTextStyle || {textAlign: 'center'}}
|
|
164
|
-
numberOfLines={
|
|
166
|
+
numberOfLines={xAxisTextNumberOfLines}>
|
|
165
167
|
{label || ''}
|
|
166
168
|
</Text>
|
|
167
169
|
)}
|
|
@@ -204,7 +206,7 @@ const RenderBars = (props: Props) => {
|
|
|
204
206
|
) : (
|
|
205
207
|
<Text
|
|
206
208
|
style={labelTextStyle || {textAlign: 'center'}}
|
|
207
|
-
numberOfLines={
|
|
209
|
+
numberOfLines={xAxisTextNumberOfLines}>
|
|
208
210
|
{label || ''}
|
|
209
211
|
</Text>
|
|
210
212
|
)}
|
|
@@ -38,6 +38,7 @@ type Props = {
|
|
|
38
38
|
xAxisThickness: number;
|
|
39
39
|
barBackgroundPattern?: Function;
|
|
40
40
|
patternId?: String;
|
|
41
|
+
xAxisTextNumberOfLines: number;
|
|
41
42
|
};
|
|
42
43
|
type itemType = {
|
|
43
44
|
value?: number;
|
|
@@ -69,6 +70,7 @@ const RenderStackBars = (props: Props) => {
|
|
|
69
70
|
xAxisThickness,
|
|
70
71
|
label,
|
|
71
72
|
labelTextStyle,
|
|
73
|
+
xAxisTextNumberOfLines,
|
|
72
74
|
} = props;
|
|
73
75
|
const disablePress = props.disablePress || false;
|
|
74
76
|
const renderLabel = (label: String, labelTextStyle: any) => {
|
|
@@ -92,7 +94,7 @@ const RenderStackBars = (props: Props) => {
|
|
|
92
94
|
{item.labelComponent ? (
|
|
93
95
|
item.labelComponent()
|
|
94
96
|
) : (
|
|
95
|
-
<Text style={[labelTextStyle]} numberOfLines={
|
|
97
|
+
<Text style={[labelTextStyle]} numberOfLines={xAxisTextNumberOfLines}>
|
|
96
98
|
{label || ''}
|
|
97
99
|
</Text>
|
|
98
100
|
)}
|
package/src/BarChart/index.tsx
CHANGED
|
@@ -47,6 +47,8 @@ type PropTypes = {
|
|
|
47
47
|
yAxisLabelContainerStyle?: any;
|
|
48
48
|
horizontalRulesStyle?: any;
|
|
49
49
|
yAxisTextStyle?: any;
|
|
50
|
+
yAxisTextNumberOfLines?: number;
|
|
51
|
+
xAxisTextNumberOfLines?: number;
|
|
50
52
|
yAxisLabelWidth?: number;
|
|
51
53
|
hideYAxisText?: Boolean;
|
|
52
54
|
yAxisSide?: string;
|
|
@@ -372,6 +374,8 @@ export const BarChart = (props: PropTypes) => {
|
|
|
372
374
|
: props.yAxisThickness || 1;
|
|
373
375
|
const yAxisColor = props.yAxisColor || 'black';
|
|
374
376
|
const yAxisTextStyle = props.yAxisTextStyle;
|
|
377
|
+
const yAxisTextNumberOfLines = props.yAxisTextNumberOfLines || 1;
|
|
378
|
+
const xAxisTextNumberOfLines = props.xAxisTextNumberOfLines || 1;
|
|
375
379
|
const yAxisLabelContainerStyle = props.yAxisLabelContainerStyle;
|
|
376
380
|
const horizontalRulesStyle = props.horizontalRulesStyle;
|
|
377
381
|
const showFractionalValues = props.showFractionalValues || false;
|
|
@@ -768,7 +772,7 @@ export const BarChart = (props: PropTypes) => {
|
|
|
768
772
|
yAxisLabelContainerStyle,
|
|
769
773
|
]}>
|
|
770
774
|
<Text
|
|
771
|
-
numberOfLines={
|
|
775
|
+
numberOfLines={yAxisTextNumberOfLines}
|
|
772
776
|
ellipsizeMode={'clip'}
|
|
773
777
|
style={[
|
|
774
778
|
yAxisTextStyle,
|
|
@@ -875,7 +879,7 @@ export const BarChart = (props: PropTypes) => {
|
|
|
875
879
|
yAxisLabelContainerStyle,
|
|
876
880
|
]}>
|
|
877
881
|
<Text
|
|
878
|
-
numberOfLines={
|
|
882
|
+
numberOfLines={yAxisTextNumberOfLines}
|
|
879
883
|
ellipsizeMode={'clip'}
|
|
880
884
|
style={[
|
|
881
885
|
yAxisTextStyle,
|
|
@@ -1399,6 +1403,7 @@ export const BarChart = (props: PropTypes) => {
|
|
|
1399
1403
|
labelTextStyle={
|
|
1400
1404
|
item.labelTextStyle || props.xAxisLabelTextStyle
|
|
1401
1405
|
}
|
|
1406
|
+
xAxisTextNumberOfLines={xAxisTextNumberOfLines}
|
|
1402
1407
|
/>
|
|
1403
1408
|
);
|
|
1404
1409
|
})
|
|
@@ -1460,6 +1465,7 @@ export const BarChart = (props: PropTypes) => {
|
|
|
1460
1465
|
item.labelTextStyle || props.xAxisLabelTextStyle
|
|
1461
1466
|
}
|
|
1462
1467
|
onPress={props.onPress}
|
|
1468
|
+
xAxisTextNumberOfLines={xAxisTextNumberOfLines}
|
|
1463
1469
|
/>
|
|
1464
1470
|
))}
|
|
1465
1471
|
</Fragment>
|
package/src/LineChart/index.tsx
CHANGED
|
@@ -154,6 +154,8 @@ type propTypes = {
|
|
|
154
154
|
yAxisLabelContainerStyle?: any;
|
|
155
155
|
horizontalRulesStyle?: any;
|
|
156
156
|
yAxisTextStyle?: any;
|
|
157
|
+
yAxisTextNumberOfLines?: number;
|
|
158
|
+
xAxisTextNumberOfLines?: number;
|
|
157
159
|
showFractionalValues?: Boolean;
|
|
158
160
|
roundToDigits?: number;
|
|
159
161
|
yAxisLabelWidth?: number;
|
|
@@ -1386,6 +1388,8 @@ export const LineChart = (props: propTypes) => {
|
|
|
1386
1388
|
props.yAxisThickness === 0 ? 0 : props.yAxisThickness || 1;
|
|
1387
1389
|
const yAxisColor = props.yAxisColor || 'black';
|
|
1388
1390
|
const yAxisTextStyle = props.yAxisTextStyle;
|
|
1391
|
+
const yAxisTextNumberOfLines = props.yAxisTextNumberOfLines || 1;
|
|
1392
|
+
const xAxisTextNumberOfLines = props.xAxisTextNumberOfLines || 1;
|
|
1389
1393
|
const yAxisLabelContainerStyle = props.yAxisLabelContainerStyle;
|
|
1390
1394
|
const horizontalRulesStyle = props.horizontalRulesStyle;
|
|
1391
1395
|
const showFractionalValues = props.showFractionalValues || false;
|
|
@@ -1681,7 +1685,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
1681
1685
|
) : (
|
|
1682
1686
|
<Text
|
|
1683
1687
|
style={labelTextStyle || {textAlign: 'center'}}
|
|
1684
|
-
numberOfLines={
|
|
1688
|
+
numberOfLines={xAxisTextNumberOfLines}>
|
|
1685
1689
|
{label || ''}
|
|
1686
1690
|
</Text>
|
|
1687
1691
|
)}
|
|
@@ -1719,7 +1723,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
1719
1723
|
) : (
|
|
1720
1724
|
<Text
|
|
1721
1725
|
style={labelTextStyle || {textAlign: 'center'}}
|
|
1722
|
-
numberOfLines={
|
|
1726
|
+
numberOfLines={xAxisTextNumberOfLines}>
|
|
1723
1727
|
{label || ''}
|
|
1724
1728
|
</Text>
|
|
1725
1729
|
)}
|
|
@@ -1899,7 +1903,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
1899
1903
|
yAxisLabelContainerStyle,
|
|
1900
1904
|
]}>
|
|
1901
1905
|
<Text
|
|
1902
|
-
numberOfLines={
|
|
1906
|
+
numberOfLines={yAxisTextNumberOfLines}
|
|
1903
1907
|
ellipsizeMode={'clip'}
|
|
1904
1908
|
style={[
|
|
1905
1909
|
yAxisTextStyle,
|
|
@@ -2001,7 +2005,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
2001
2005
|
yAxisLabelContainerStyle,
|
|
2002
2006
|
]}>
|
|
2003
2007
|
<Text
|
|
2004
|
-
numberOfLines={
|
|
2008
|
+
numberOfLines={yAxisTextNumberOfLines}
|
|
2005
2009
|
ellipsizeMode={'clip'}
|
|
2006
2010
|
style={[
|
|
2007
2011
|
yAxisTextStyle,
|
|
@@ -2518,6 +2522,48 @@ export const LineChart = (props: propTypes) => {
|
|
|
2518
2522
|
}
|
|
2519
2523
|
pointerYLocal = Math.min(...arr);
|
|
2520
2524
|
|
|
2525
|
+
let left = 0,
|
|
2526
|
+
top = 0;
|
|
2527
|
+
if (autoAdjustPointerLabelPosition) {
|
|
2528
|
+
if (pointerX < pointerLabelWidth / 2) {
|
|
2529
|
+
left = 7;
|
|
2530
|
+
} else {
|
|
2531
|
+
if (
|
|
2532
|
+
!activatePointersOnLongPress &&
|
|
2533
|
+
pointerX >
|
|
2534
|
+
(props.width ||
|
|
2535
|
+
Dimensions.get('window').width - yAxisLabelWidth - 15) -
|
|
2536
|
+
pointerLabelWidth / 2
|
|
2537
|
+
) {
|
|
2538
|
+
left = -pointerLabelWidth - 4;
|
|
2539
|
+
} else if (
|
|
2540
|
+
activatePointersOnLongPress &&
|
|
2541
|
+
pointerX > totalWidth - yAxisLabelWidth - pointerLabelWidth / 2
|
|
2542
|
+
) {
|
|
2543
|
+
left = -pointerLabelWidth - 4;
|
|
2544
|
+
} else {
|
|
2545
|
+
left = -pointerLabelWidth / 2 + 5;
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
} else {
|
|
2549
|
+
left = (pointerRadius || pointerWidth / 2) - 10 + shiftPointerLabelX;
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
if (autoAdjustPointerLabelPosition) {
|
|
2553
|
+
if (pointerLabelHeight - pointerYLocal > 10) {
|
|
2554
|
+
top = 10;
|
|
2555
|
+
} else {
|
|
2556
|
+
top = -pointerLabelHeight;
|
|
2557
|
+
}
|
|
2558
|
+
} else {
|
|
2559
|
+
top =
|
|
2560
|
+
(pointerStripUptoDataPoint
|
|
2561
|
+
? pointerRadius || pointerStripHeight / 2
|
|
2562
|
+
: -pointerYLocal + 8) -
|
|
2563
|
+
pointerLabelWidth / 2 +
|
|
2564
|
+
shiftPointerLabelY;
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2521
2567
|
return (
|
|
2522
2568
|
<View
|
|
2523
2569
|
style={{
|
|
@@ -2569,30 +2615,8 @@ export const LineChart = (props: propTypes) => {
|
|
|
2569
2615
|
style={[
|
|
2570
2616
|
{
|
|
2571
2617
|
position: 'absolute',
|
|
2572
|
-
left:
|
|
2573
|
-
|
|
2574
|
-
? 7
|
|
2575
|
-
: !activatePointersOnLongPress &&
|
|
2576
|
-
pointerX >
|
|
2577
|
-
(props.width ||
|
|
2578
|
-
Dimensions.get('window').width -
|
|
2579
|
-
yAxisLabelWidth -
|
|
2580
|
-
15) -
|
|
2581
|
-
pointerLabelWidth / 2
|
|
2582
|
-
? -pointerLabelWidth - 4
|
|
2583
|
-
: pointerLabelWidth / -2 + 5
|
|
2584
|
-
: (pointerRadius || pointerWidth / 2) -
|
|
2585
|
-
10 +
|
|
2586
|
-
shiftPointerLabelX,
|
|
2587
|
-
top: autoAdjustPointerLabelPosition
|
|
2588
|
-
? pointerLabelHeight - pointerYLocal > 10
|
|
2589
|
-
? 10
|
|
2590
|
-
: -pointerLabelHeight
|
|
2591
|
-
: (pointerStripUptoDataPoint
|
|
2592
|
-
? pointerRadius || pointerStripHeight / 2
|
|
2593
|
-
: -pointerYLocal + 8) -
|
|
2594
|
-
pointerLabelWidth / 2 +
|
|
2595
|
-
shiftPointerLabelY,
|
|
2618
|
+
left: left,
|
|
2619
|
+
top: top,
|
|
2596
2620
|
marginTop: pointerStripUptoDataPoint
|
|
2597
2621
|
? 0
|
|
2598
2622
|
: containerHeight - pointerStripHeight,
|
|
@@ -2791,7 +2815,6 @@ export const LineChart = (props: propTypes) => {
|
|
|
2791
2815
|
2;
|
|
2792
2816
|
setPointerX(z);
|
|
2793
2817
|
let item, y;
|
|
2794
|
-
setPointerX(z);
|
|
2795
2818
|
item = data[factor];
|
|
2796
2819
|
y =
|
|
2797
2820
|
containerHeight -
|
|
@@ -2943,7 +2966,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
2943
2966
|
setResponderActive(false);
|
|
2944
2967
|
setTimeout(() => setPointerX(0), pointerVanishDelay);
|
|
2945
2968
|
}}
|
|
2946
|
-
onResponderTerminationRequest={
|
|
2969
|
+
onResponderTerminationRequest={evt => false}
|
|
2947
2970
|
// onResponderTerminate={evt => {
|
|
2948
2971
|
// console.log('evt...terminate.......',evt);
|
|
2949
2972
|
// }}
|
|
@@ -3015,7 +3038,6 @@ export const LineChart = (props: propTypes) => {
|
|
|
3015
3038
|
2;
|
|
3016
3039
|
setPointerX(z);
|
|
3017
3040
|
let item, y;
|
|
3018
|
-
setPointerX(z);
|
|
3019
3041
|
item = data[factor];
|
|
3020
3042
|
y =
|
|
3021
3043
|
containerHeight -
|
|
@@ -3166,7 +3188,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
3166
3188
|
setResponderActive(false);
|
|
3167
3189
|
setTimeout(() => setPointerX(0), pointerVanishDelay);
|
|
3168
3190
|
}}
|
|
3169
|
-
onResponderTerminationRequest={
|
|
3191
|
+
onResponderTerminationRequest={evt => false}
|
|
3170
3192
|
// onResponderTerminate={evt => {
|
|
3171
3193
|
// console.log('evt...terminate.......',evt);
|
|
3172
3194
|
// }}
|
|
@@ -3428,7 +3450,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
3428
3450
|
strokeDashArray5,
|
|
3429
3451
|
)
|
|
3430
3452
|
: null}
|
|
3431
|
-
{pointerX ? (
|
|
3453
|
+
{pointerX > 0 ? (
|
|
3432
3454
|
<View
|
|
3433
3455
|
style={{
|
|
3434
3456
|
position: 'absolute',
|
package/src/PieChart/index.tsx
CHANGED
|
@@ -210,6 +210,7 @@ export const PieChart = (props: propTypes) => {
|
|
|
210
210
|
{data.map((item, index) => {
|
|
211
211
|
return (
|
|
212
212
|
<RadialGradient
|
|
213
|
+
key={index + ''}
|
|
213
214
|
id={'grad' + index}
|
|
214
215
|
cx="50%"
|
|
215
216
|
cy="50%"
|
|
@@ -232,54 +233,75 @@ export const PieChart = (props: propTypes) => {
|
|
|
232
233
|
);
|
|
233
234
|
})}
|
|
234
235
|
</Defs>
|
|
235
|
-
{data.
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
cx * (1 + Math.sin(2 * pi * pData[index] + initialAngle)) +
|
|
242
|
-
(item.shiftX || 0);
|
|
243
|
-
let sy =
|
|
244
|
-
cy * (1 - Math.cos(2 * pi * pData[index] + initialAngle)) +
|
|
245
|
-
(item.shiftY || 0);
|
|
246
|
-
let ax =
|
|
247
|
-
cx * (1 + Math.sin(2 * pi * nextItem + initialAngle)) +
|
|
248
|
-
(item.shiftX || 0);
|
|
249
|
-
let ay =
|
|
250
|
-
cy * (1 - Math.cos(2 * pi * nextItem + initialAngle)) +
|
|
251
|
-
(item.shiftY || 0);
|
|
252
|
-
|
|
253
|
-
// console.log('sx', sx);
|
|
254
|
-
// console.log('sy', sy);
|
|
255
|
-
// console.log('ax', ax);
|
|
256
|
-
// console.log('ay', ay);
|
|
257
|
-
return (
|
|
258
|
-
<Path
|
|
259
|
-
d={`M ${cx + (item.shiftX || 0)} ${
|
|
260
|
-
cy + (item.shiftY || 0)
|
|
261
|
-
} L ${sx} ${sy} A ${radius} ${radius} 0 ${
|
|
262
|
-
semiCircle ? 0 : data[index].value > total / 2 ? 1 : 0
|
|
263
|
-
} 1 ${ax} ${ay} L ${cx + (item.shiftX || 0)} ${
|
|
264
|
-
cy + (item.shiftY || 0)
|
|
265
|
-
}`}
|
|
266
|
-
stroke={strokeColor}
|
|
267
|
-
strokeWidth={strokeWidth}
|
|
236
|
+
{data.length === 1 ? (
|
|
237
|
+
<>
|
|
238
|
+
<Circle
|
|
239
|
+
cx={cx}
|
|
240
|
+
cy={cy}
|
|
241
|
+
r={radius}
|
|
268
242
|
fill={
|
|
269
|
-
showGradient
|
|
270
|
-
? `url(#grad${index})`
|
|
271
|
-
: item.color || colors[index % 9]
|
|
243
|
+
showGradient ? `url(#grad${0})` : data[0].color || colors[0 % 9]
|
|
272
244
|
}
|
|
273
245
|
onPress={() => {
|
|
274
|
-
|
|
275
|
-
?
|
|
246
|
+
data[0].onPress
|
|
247
|
+
? data[0].onPress
|
|
276
248
|
: props.onPress
|
|
277
|
-
? props.onPress(
|
|
249
|
+
? props.onPress(data[0], 0)
|
|
278
250
|
: null;
|
|
279
251
|
}}
|
|
280
252
|
/>
|
|
281
|
-
|
|
282
|
-
|
|
253
|
+
</>
|
|
254
|
+
) : (
|
|
255
|
+
data.map((item, index) => {
|
|
256
|
+
// console.log('index', index);
|
|
257
|
+
let nextItem;
|
|
258
|
+
if (index === pData.length - 1) nextItem = pData[0];
|
|
259
|
+
else nextItem = pData[index + 1];
|
|
260
|
+
let sx =
|
|
261
|
+
cx * (1 + Math.sin(2 * pi * pData[index] + initialAngle)) +
|
|
262
|
+
(item.shiftX || 0);
|
|
263
|
+
let sy =
|
|
264
|
+
cy * (1 - Math.cos(2 * pi * pData[index] + initialAngle)) +
|
|
265
|
+
(item.shiftY || 0);
|
|
266
|
+
let ax =
|
|
267
|
+
cx * (1 + Math.sin(2 * pi * nextItem + initialAngle)) +
|
|
268
|
+
(item.shiftX || 0);
|
|
269
|
+
let ay =
|
|
270
|
+
cy * (1 - Math.cos(2 * pi * nextItem + initialAngle)) +
|
|
271
|
+
(item.shiftY || 0);
|
|
272
|
+
|
|
273
|
+
// console.log('sx', sx);
|
|
274
|
+
// console.log('sy', sy);
|
|
275
|
+
// console.log('ax', ax);
|
|
276
|
+
// console.log('ay', ay);
|
|
277
|
+
return (
|
|
278
|
+
<Path
|
|
279
|
+
key={index + 'a'}
|
|
280
|
+
d={`M ${cx + (item.shiftX || 0)} ${
|
|
281
|
+
cy + (item.shiftY || 0)
|
|
282
|
+
} L ${sx} ${sy} A ${radius} ${radius} 0 ${
|
|
283
|
+
semiCircle ? 0 : data[index].value > total / 2 ? 1 : 0
|
|
284
|
+
} 1 ${ax} ${ay} L ${cx + (item.shiftX || 0)} ${
|
|
285
|
+
cy + (item.shiftY || 0)
|
|
286
|
+
}`}
|
|
287
|
+
stroke={strokeColor}
|
|
288
|
+
strokeWidth={strokeWidth}
|
|
289
|
+
fill={
|
|
290
|
+
showGradient
|
|
291
|
+
? `url(#grad${index})`
|
|
292
|
+
: item.color || colors[index % 9]
|
|
293
|
+
}
|
|
294
|
+
onPress={() => {
|
|
295
|
+
item.onPress
|
|
296
|
+
? item.onPress
|
|
297
|
+
: props.onPress
|
|
298
|
+
? props.onPress(item, index)
|
|
299
|
+
: null;
|
|
300
|
+
}}
|
|
301
|
+
/>
|
|
302
|
+
);
|
|
303
|
+
})
|
|
304
|
+
)}
|
|
283
305
|
|
|
284
306
|
{showText &&
|
|
285
307
|
data.map((item, index) => {
|
|
@@ -308,6 +330,21 @@ export const PieChart = (props: propTypes) => {
|
|
|
308
330
|
x += item.shiftX || 0;
|
|
309
331
|
y += item.shiftY || 0;
|
|
310
332
|
|
|
333
|
+
if (data.length === 1) {
|
|
334
|
+
if (donut) {
|
|
335
|
+
y =
|
|
336
|
+
(radius -
|
|
337
|
+
innerRadius +
|
|
338
|
+
(item.textBackgroundRadius ||
|
|
339
|
+
props.textBackgroundRadius ||
|
|
340
|
+
item.textSize ||
|
|
341
|
+
textSize)) /
|
|
342
|
+
2;
|
|
343
|
+
} else {
|
|
344
|
+
y = cy;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
311
348
|
// console.log('sx', sx);
|
|
312
349
|
// console.log('sy', sy);
|
|
313
350
|
// console.log('ax', ax);
|
|
@@ -317,6 +354,7 @@ export const PieChart = (props: propTypes) => {
|
|
|
317
354
|
{/* <Line x1={mx} x2={cx} y1={my} y2={cy} stroke="black" /> */}
|
|
318
355
|
{showTextBackground && (
|
|
319
356
|
<Circle
|
|
357
|
+
key={index + 'b'}
|
|
320
358
|
cx={x}
|
|
321
359
|
cy={y - (item.textSize || textSize) / 4}
|
|
322
360
|
r={
|
|
@@ -340,7 +378,7 @@ export const PieChart = (props: propTypes) => {
|
|
|
340
378
|
/>
|
|
341
379
|
)}
|
|
342
380
|
<SvgText
|
|
343
|
-
fill={item.textColor || textColor || colors[(index +
|
|
381
|
+
fill={item.textColor || textColor || colors[(index + 2) % 9]}
|
|
344
382
|
fontSize={item.textSize || textSize}
|
|
345
383
|
fontFamily={item.font || props.font}
|
|
346
384
|
fontWeight={item.fontWeight || props.fontWeight}
|
package/src/todos.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## Features
|
|
2
2
|
|
|
3
|
-
1. Fix the issue
|
|
3
|
+
1. Fix the issue with pointers in Line/Area charts on Android https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/177
|
|
4
4
|
|
|
5
5
|
## To-dos in documentation-
|
|
6
6
|
|