react-native-gifted-charts 1.2.10 → 1.2.11
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 +1 -1
- package/src/LineChart/index.tsx +71 -18
- package/src/todos.md +2 -2
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.11",
|
|
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": [
|
package/src/LineChart/index.tsx
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
Easing,
|
|
14
14
|
Text,
|
|
15
15
|
ColorValue,
|
|
16
|
+
Dimensions,
|
|
16
17
|
} from 'react-native';
|
|
17
18
|
import {styles} from './styles';
|
|
18
19
|
import Svg, {
|
|
@@ -342,9 +343,11 @@ type Pointer = {
|
|
|
342
343
|
pointerStripColor?: ColorValue;
|
|
343
344
|
pointerStripUptoDataPoint?: boolean;
|
|
344
345
|
pointerLabelComponent?: Function;
|
|
346
|
+
autoAdjustPointerLabelPosition?: boolean;
|
|
345
347
|
shiftPointerLabelX?: number;
|
|
346
348
|
shiftPointerLabelY?: number;
|
|
347
349
|
pointerLabelWidth?: number;
|
|
350
|
+
pointerLabelHeight?: number;
|
|
348
351
|
pointerVanishDelay?: number;
|
|
349
352
|
activatePointersOnLongPress?: boolean;
|
|
350
353
|
activatePointersDelay?: number;
|
|
@@ -476,7 +479,8 @@ export const LineChart = (props: propTypes) => {
|
|
|
476
479
|
? ((props.width || 200) - initialSpacing) / data.length
|
|
477
480
|
: 60);
|
|
478
481
|
|
|
479
|
-
const xAxisThickness =
|
|
482
|
+
const xAxisThickness =
|
|
483
|
+
props.xAxisThickness === 0 ? 0 : props.xAxisThickness || 1;
|
|
480
484
|
const dataPointsHeight1 =
|
|
481
485
|
props.dataPointsHeight1 || props.dataPointsHeight || 2;
|
|
482
486
|
const dataPointsWidth1 = props.dataPointsWidth1 || props.dataPointsWidth || 2;
|
|
@@ -1319,7 +1323,8 @@ export const LineChart = (props: propTypes) => {
|
|
|
1319
1323
|
const xAxisIndicesColor = props.xAxisIndicesColor || 'black';
|
|
1320
1324
|
const yAxisIndicesColor = props.yAxisIndicesColor || 'black';
|
|
1321
1325
|
|
|
1322
|
-
const yAxisThickness =
|
|
1326
|
+
const yAxisThickness =
|
|
1327
|
+
props.yAxisThickness === 0 ? 0 : props.yAxisThickness || 1;
|
|
1323
1328
|
const yAxisColor = props.yAxisColor || 'black';
|
|
1324
1329
|
const yAxisTextStyle = props.yAxisTextStyle;
|
|
1325
1330
|
const yAxisLabelContainerStyle = props.yAxisLabelContainerStyle;
|
|
@@ -1344,7 +1349,9 @@ export const LineChart = (props: propTypes) => {
|
|
|
1344
1349
|
pointerLabelComponent: null,
|
|
1345
1350
|
shiftPointerLabelX: 0,
|
|
1346
1351
|
shiftPointerLabelY: 0,
|
|
1347
|
-
pointerLabelWidth:
|
|
1352
|
+
pointerLabelWidth: 20,
|
|
1353
|
+
pointerLabelHeight: 20,
|
|
1354
|
+
autoAdjustPointerLabelPosition: true,
|
|
1348
1355
|
pointerVanishDelay: 150,
|
|
1349
1356
|
activatePointersOnLongPress: false,
|
|
1350
1357
|
activatePointersDelay: 150,
|
|
@@ -1412,6 +1419,14 @@ export const LineChart = (props: propTypes) => {
|
|
|
1412
1419
|
pointerConfig && pointerConfig.pointerLabelWidth
|
|
1413
1420
|
? pointerConfig.pointerLabelWidth
|
|
1414
1421
|
: defaultPointerConfig.pointerLabelWidth;
|
|
1422
|
+
const pointerLabelHeight =
|
|
1423
|
+
pointerConfig && pointerConfig.pointerLabelHeight
|
|
1424
|
+
? pointerConfig.pointerLabelHeight
|
|
1425
|
+
: defaultPointerConfig.pointerLabelHeight;
|
|
1426
|
+
const autoAdjustPointerLabelPosition =
|
|
1427
|
+
pointerConfig && pointerConfig.autoAdjustPointerLabelPosition
|
|
1428
|
+
? pointerConfig.autoAdjustPointerLabelPosition
|
|
1429
|
+
: defaultPointerConfig.autoAdjustPointerLabelPosition;
|
|
1415
1430
|
const pointerVanishDelay =
|
|
1416
1431
|
pointerConfig && pointerConfig.pointerVanishDelay
|
|
1417
1432
|
? pointerConfig.pointerVanishDelay
|
|
@@ -2487,21 +2502,39 @@ export const LineChart = (props: propTypes) => {
|
|
|
2487
2502
|
|
|
2488
2503
|
{pointerLabelComponent && (
|
|
2489
2504
|
<View
|
|
2490
|
-
style={
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
+
style={[
|
|
2506
|
+
{
|
|
2507
|
+
position: 'absolute',
|
|
2508
|
+
left: autoAdjustPointerLabelPosition
|
|
2509
|
+
? pointerX < pointerLabelWidth / 2
|
|
2510
|
+
? 7
|
|
2511
|
+
: !activatePointersOnLongPress &&
|
|
2512
|
+
pointerX >
|
|
2513
|
+
(props.width ||
|
|
2514
|
+
Dimensions.get('window').width -
|
|
2515
|
+
yAxisLabelWidth -
|
|
2516
|
+
15) -
|
|
2517
|
+
pointerLabelWidth / 2
|
|
2518
|
+
? -pointerLabelWidth - 4
|
|
2519
|
+
: pointerLabelWidth / -2 + 5
|
|
2520
|
+
: (pointerRadius || pointerWidth / 2) -
|
|
2521
|
+
10 +
|
|
2522
|
+
shiftPointerLabelX,
|
|
2523
|
+
top: autoAdjustPointerLabelPosition
|
|
2524
|
+
? pointerLabelHeight - pointerYLocal > 10
|
|
2525
|
+
? 10
|
|
2526
|
+
: -pointerLabelHeight
|
|
2527
|
+
: (pointerStripUptoDataPoint
|
|
2528
|
+
? pointerRadius || pointerStripHeight / 2
|
|
2529
|
+
: -pointerYLocal + 8) -
|
|
2530
|
+
pointerLabelWidth / 2 +
|
|
2531
|
+
shiftPointerLabelY,
|
|
2532
|
+
marginTop: pointerStripUptoDataPoint
|
|
2533
|
+
? 0
|
|
2534
|
+
: containerHeight - pointerStripHeight,
|
|
2535
|
+
width: pointerLabelWidth,
|
|
2536
|
+
},
|
|
2537
|
+
]}>
|
|
2505
2538
|
{pointerLabelComponent(pointerItemLocal)}
|
|
2506
2539
|
</View>
|
|
2507
2540
|
)}
|
|
@@ -2678,6 +2711,11 @@ export const LineChart = (props: propTypes) => {
|
|
|
2678
2711
|
return;
|
|
2679
2712
|
}
|
|
2680
2713
|
let x = evt.nativeEvent.locationX;
|
|
2714
|
+
if (
|
|
2715
|
+
!activatePointersOnLongPress &&
|
|
2716
|
+
x > (props.width || Dimensions.get('window').width)
|
|
2717
|
+
)
|
|
2718
|
+
return;
|
|
2681
2719
|
let factor = (x - initialSpacing) / spacing;
|
|
2682
2720
|
factor = Math.round(factor);
|
|
2683
2721
|
factor = Math.min(factor, data.length - 1);
|
|
@@ -2758,6 +2796,11 @@ export const LineChart = (props: propTypes) => {
|
|
|
2758
2796
|
setResponderActive(true);
|
|
2759
2797
|
}
|
|
2760
2798
|
let x = evt.nativeEvent.locationX;
|
|
2799
|
+
if (
|
|
2800
|
+
!activatePointersOnLongPress &&
|
|
2801
|
+
x > (props.width || Dimensions.get('window').width)
|
|
2802
|
+
)
|
|
2803
|
+
return;
|
|
2761
2804
|
let factor = (x - initialSpacing) / spacing;
|
|
2762
2805
|
factor = Math.round(factor);
|
|
2763
2806
|
factor = Math.min(factor, data.length - 1);
|
|
@@ -2878,6 +2921,11 @@ export const LineChart = (props: propTypes) => {
|
|
|
2878
2921
|
return;
|
|
2879
2922
|
}
|
|
2880
2923
|
let x = evt.nativeEvent.locationX;
|
|
2924
|
+
if (
|
|
2925
|
+
!activatePointersOnLongPress &&
|
|
2926
|
+
x > (props.width || Dimensions.get('window').width)
|
|
2927
|
+
)
|
|
2928
|
+
return;
|
|
2881
2929
|
let factor = (x - initialSpacing) / spacing;
|
|
2882
2930
|
factor = Math.round(factor);
|
|
2883
2931
|
factor = Math.min(factor, data.length - 1);
|
|
@@ -2958,6 +3006,11 @@ export const LineChart = (props: propTypes) => {
|
|
|
2958
3006
|
setResponderActive(true);
|
|
2959
3007
|
}
|
|
2960
3008
|
let x = evt.nativeEvent.locationX;
|
|
3009
|
+
if (
|
|
3010
|
+
!activatePointersOnLongPress &&
|
|
3011
|
+
x > (props.width || Dimensions.get('window').width)
|
|
3012
|
+
)
|
|
3013
|
+
return;
|
|
2961
3014
|
let factor = (x - initialSpacing) / spacing;
|
|
2962
3015
|
factor = Math.round(factor);
|
|
2963
3016
|
factor = Math.min(factor, data.length - 1);
|
package/src/todos.md
CHANGED