react-native-gifted-charts 1.0.2 → 1.0.5
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": "react-native-gifted-charts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "The most complete library for Bar, Line, Area, Pie and Donut charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
|
|
5
5
|
"main": "src/index.tsx",
|
|
6
6
|
"files": [
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"react-native": "*"
|
|
52
52
|
},
|
|
53
53
|
"keywords": [
|
|
54
|
+
"react-native",
|
|
54
55
|
"chart",
|
|
55
56
|
"charts",
|
|
56
57
|
"graph",
|
|
@@ -58,8 +59,7 @@
|
|
|
58
59
|
"pie",
|
|
59
60
|
"donut",
|
|
60
61
|
"area",
|
|
61
|
-
"line"
|
|
62
|
-
"react native"
|
|
62
|
+
"line"
|
|
63
63
|
],
|
|
64
64
|
"jest": {
|
|
65
65
|
"preset": "react-native"
|
|
@@ -32,6 +32,8 @@ type propTypes = {
|
|
|
32
32
|
horizontal: Boolean;
|
|
33
33
|
intactTopLabel: Boolean;
|
|
34
34
|
barBorderRadius?: number;
|
|
35
|
+
containerHeight?: number;
|
|
36
|
+
maxValue?: number;
|
|
35
37
|
};
|
|
36
38
|
type itemType = {
|
|
37
39
|
value?: number;
|
|
@@ -54,12 +56,19 @@ type itemType = {
|
|
|
54
56
|
};
|
|
55
57
|
|
|
56
58
|
const Animated2DWithGradient = (props: propTypes) => {
|
|
57
|
-
const {
|
|
59
|
+
const {
|
|
60
|
+
item,
|
|
61
|
+
opacity,
|
|
62
|
+
animationDuration,
|
|
63
|
+
noGradient,
|
|
64
|
+
noAnimation,
|
|
65
|
+
containerHeight,
|
|
66
|
+
maxValue,
|
|
67
|
+
} = props;
|
|
58
68
|
const [height, setHeight] = useState(noAnimation ? props.height : 2);
|
|
59
69
|
const [initialRender, setInitialRender] = useState(
|
|
60
70
|
noAnimation ? false : true,
|
|
61
71
|
);
|
|
62
|
-
// console.log('comes to animated2DWithGradient', item);
|
|
63
72
|
|
|
64
73
|
useEffect(() => {
|
|
65
74
|
if (!noAnimation) {
|
|
@@ -97,9 +106,19 @@ const Animated2DWithGradient = (props: propTypes) => {
|
|
|
97
106
|
position: 'absolute',
|
|
98
107
|
bottom: 0,
|
|
99
108
|
width: '100%',
|
|
100
|
-
height:
|
|
109
|
+
height: noAnimation
|
|
110
|
+
? (Math.abs(item.value) * (containerHeight || 200)) /
|
|
111
|
+
(maxValue || 200)
|
|
112
|
+
: height,
|
|
101
113
|
}}>
|
|
102
|
-
<View
|
|
114
|
+
<View
|
|
115
|
+
style={{
|
|
116
|
+
width: '100%',
|
|
117
|
+
height: noAnimation
|
|
118
|
+
? (Math.abs(item.value) * (containerHeight || 200)) /
|
|
119
|
+
(maxValue || 200)
|
|
120
|
+
: height,
|
|
121
|
+
}}>
|
|
103
122
|
{noGradient ? (
|
|
104
123
|
<View
|
|
105
124
|
style={[
|
|
@@ -223,13 +242,14 @@ const Animated2DWithGradient = (props: propTypes) => {
|
|
|
223
242
|
height: item.barWidth || 30,
|
|
224
243
|
width: item.barWidth || 30,
|
|
225
244
|
justifyContent:
|
|
226
|
-
(props.horizontal && !props.intactTopLabel) ||
|
|
245
|
+
(props.horizontal && !props.intactTopLabel) ||
|
|
246
|
+
item.value < 0
|
|
227
247
|
? 'center'
|
|
228
248
|
: 'flex-end',
|
|
229
249
|
alignItems: 'center',
|
|
230
250
|
opacity: opacity,
|
|
231
251
|
},
|
|
232
|
-
item.value < 0 && {transform:[{rotate:'180deg'}]},
|
|
252
|
+
item.value < 0 && {transform: [{rotate: '180deg'}]},
|
|
233
253
|
props.horizontal &&
|
|
234
254
|
!props.intactTopLabel && {transform: [{rotate: '270deg'}]},
|
|
235
255
|
item.topLabelContainerStyle,
|
|
@@ -243,4 +263,4 @@ const Animated2DWithGradient = (props: propTypes) => {
|
|
|
243
263
|
);
|
|
244
264
|
};
|
|
245
265
|
|
|
246
|
-
export default Animated2DWithGradient;
|
|
266
|
+
export default Animated2DWithGradient;
|
|
@@ -121,18 +121,29 @@ const RenderBars = (props: Props) => {
|
|
|
121
121
|
rotateLabel
|
|
122
122
|
? props.horizontal
|
|
123
123
|
? {transform: [{rotate: '330deg'}]}
|
|
124
|
-
: {
|
|
124
|
+
: {
|
|
125
|
+
transform: [
|
|
126
|
+
{rotate: value < 0 ? '240deg' : '60deg'},
|
|
127
|
+
{translateX: value < 0 ? 56 : 0},
|
|
128
|
+
{translateY: value < 0 ? 32 : 0},
|
|
129
|
+
],
|
|
130
|
+
}
|
|
125
131
|
: props.horizontal
|
|
126
132
|
? {transform: [{rotate: '-90deg'}]}
|
|
127
133
|
: value < 0
|
|
128
|
-
?{
|
|
129
|
-
|
|
134
|
+
? {
|
|
135
|
+
transform: [
|
|
136
|
+
{rotate: '180deg'},
|
|
137
|
+
{translateY: autoShiftLabels ? 0 : 32},
|
|
138
|
+
],
|
|
139
|
+
}
|
|
140
|
+
: {},
|
|
130
141
|
]}>
|
|
131
142
|
{item.labelComponent ? (
|
|
132
143
|
item.labelComponent()
|
|
133
144
|
) : (
|
|
134
145
|
<Text
|
|
135
|
-
style={
|
|
146
|
+
style={labelTextStyle || {textAlign: 'center'}}
|
|
136
147
|
numberOfLines={1}>
|
|
137
148
|
{label || ''}
|
|
138
149
|
</Text>
|
|
@@ -141,7 +152,11 @@ const RenderBars = (props: Props) => {
|
|
|
141
152
|
);
|
|
142
153
|
};
|
|
143
154
|
|
|
144
|
-
const renderAnimatedLabel = (
|
|
155
|
+
const renderAnimatedLabel = (
|
|
156
|
+
label: String,
|
|
157
|
+
labelTextStyle: any,
|
|
158
|
+
value: number,
|
|
159
|
+
) => {
|
|
145
160
|
return (
|
|
146
161
|
<Animated.View
|
|
147
162
|
style={[
|
|
@@ -158,7 +173,7 @@ const RenderBars = (props: Props) => {
|
|
|
158
173
|
bottom: rotateLabel ? -40 : -25,
|
|
159
174
|
opacity: appearingOpacity,
|
|
160
175
|
},
|
|
161
|
-
value < 0 && {transform:[{rotate:'180deg'}]},
|
|
176
|
+
value < 0 && {transform: [{rotate: '180deg'}]},
|
|
162
177
|
rotateLabel
|
|
163
178
|
? props.horizontal
|
|
164
179
|
? {transform: [{rotate: '330deg'}]}
|
|
@@ -171,7 +186,7 @@ const RenderBars = (props: Props) => {
|
|
|
171
186
|
item.labelComponent()
|
|
172
187
|
) : (
|
|
173
188
|
<Text
|
|
174
|
-
style={
|
|
189
|
+
style={labelTextStyle || {textAlign: 'center'}}
|
|
175
190
|
numberOfLines={1}>
|
|
176
191
|
{label || ''}
|
|
177
192
|
</Text>
|
|
@@ -255,7 +270,7 @@ const RenderBars = (props: Props) => {
|
|
|
255
270
|
: 'flex-end',
|
|
256
271
|
alignItems: 'center',
|
|
257
272
|
},
|
|
258
|
-
item.value < 0 && {transform:[{rotate:'180deg'}]},
|
|
273
|
+
item.value < 0 && {transform: [{rotate: '180deg'}]},
|
|
259
274
|
props.horizontal &&
|
|
260
275
|
!props.intactTopLabel && {transform: [{rotate: '270deg'}]},
|
|
261
276
|
item.topLabelContainerStyle,
|
|
@@ -277,13 +292,27 @@ const RenderBars = (props: Props) => {
|
|
|
277
292
|
// overflow: 'visible',
|
|
278
293
|
marginBottom: 60,
|
|
279
294
|
width: item.barWidth || props.barWidth || 30,
|
|
280
|
-
height:
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
295
|
+
height:
|
|
296
|
+
item.value >= 0 &&
|
|
297
|
+
(!isThreeD || isAnimated) &&
|
|
298
|
+
item.topLabelComponent
|
|
299
|
+
? (item.topLabelComponentHeight || 30) +
|
|
300
|
+
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
301
|
+
(maxValue || 200)
|
|
302
|
+
: (Math.abs(item.value) * (containerHeight || 200)) /
|
|
303
|
+
(maxValue || 200),
|
|
284
304
|
marginRight: spacing,
|
|
285
305
|
},
|
|
286
|
-
item.value < 0 && {
|
|
306
|
+
item.value < 0 && {
|
|
307
|
+
transform: [
|
|
308
|
+
{
|
|
309
|
+
translateY:
|
|
310
|
+
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
311
|
+
(maxValue || 200),
|
|
312
|
+
},
|
|
313
|
+
{rotateZ: '180deg'},
|
|
314
|
+
],
|
|
315
|
+
},
|
|
287
316
|
// !isThreeD && !item.showGradient && !props.showGradient &&
|
|
288
317
|
// { backgroundColor: item.frontColor || props.frontColor || 'black' },
|
|
289
318
|
side !== 'right' && {zIndex: data.length - index},
|
|
@@ -333,7 +362,10 @@ const RenderBars = (props: Props) => {
|
|
|
333
362
|
topLabelComponent={item.topLabelComponent}
|
|
334
363
|
opacity={opacity || 1}
|
|
335
364
|
animationDuration={animationDuration || 800}
|
|
336
|
-
height={
|
|
365
|
+
height={
|
|
366
|
+
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
367
|
+
(maxValue || 200)
|
|
368
|
+
}
|
|
337
369
|
intactTopLabel={props.intactTopLabel}
|
|
338
370
|
horizontal={props.horizontal}
|
|
339
371
|
/>
|
|
@@ -358,7 +390,10 @@ const RenderBars = (props: Props) => {
|
|
|
358
390
|
opacity={opacity || 1}
|
|
359
391
|
horizontal={props.horizontal}
|
|
360
392
|
intactTopLabel={props.intactTopLabel}
|
|
361
|
-
height={
|
|
393
|
+
height={
|
|
394
|
+
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
395
|
+
(maxValue || 200)
|
|
396
|
+
}
|
|
362
397
|
value={item.value}
|
|
363
398
|
/>
|
|
364
399
|
)
|
|
@@ -373,7 +408,12 @@ const RenderBars = (props: Props) => {
|
|
|
373
408
|
roundedTop={props.roundedTop || false}
|
|
374
409
|
gradientColor={props.gradientColor}
|
|
375
410
|
frontColor={props.frontColor || 'black'}
|
|
376
|
-
|
|
411
|
+
containerHeight={containerHeight}
|
|
412
|
+
maxValue={maxValue}
|
|
413
|
+
height={
|
|
414
|
+
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
415
|
+
(maxValue || 200)
|
|
416
|
+
}
|
|
377
417
|
cappedBars={props.cappedBars}
|
|
378
418
|
capThickness={props.capThickness}
|
|
379
419
|
capColor={props.capColor}
|
|
@@ -396,7 +436,12 @@ const RenderBars = (props: Props) => {
|
|
|
396
436
|
gradientColor={props.gradientColor}
|
|
397
437
|
noGradient
|
|
398
438
|
frontColor={props.frontColor || 'black'}
|
|
399
|
-
|
|
439
|
+
containerHeight={containerHeight}
|
|
440
|
+
maxValue={maxValue}
|
|
441
|
+
height={
|
|
442
|
+
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
443
|
+
(maxValue || 200)
|
|
444
|
+
}
|
|
400
445
|
cappedBars={props.cappedBars}
|
|
401
446
|
capThickness={props.capThickness}
|
|
402
447
|
capColor={props.capColor}
|
|
@@ -417,7 +462,12 @@ const RenderBars = (props: Props) => {
|
|
|
417
462
|
noGradient
|
|
418
463
|
noAnimation
|
|
419
464
|
frontColor={props.frontColor || 'black'}
|
|
420
|
-
|
|
465
|
+
containerHeight={containerHeight}
|
|
466
|
+
maxValue={maxValue}
|
|
467
|
+
height={
|
|
468
|
+
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
469
|
+
(maxValue || 200)
|
|
470
|
+
}
|
|
421
471
|
cappedBars={props.cappedBars}
|
|
422
472
|
capThickness={props.capThickness}
|
|
423
473
|
capColor={props.capColor}
|
|
@@ -428,10 +478,10 @@ const RenderBars = (props: Props) => {
|
|
|
428
478
|
/>
|
|
429
479
|
)}
|
|
430
480
|
{isAnimated
|
|
431
|
-
? renderAnimatedLabel(item.label || '', item.labelTextStyle,item.value)
|
|
432
|
-
: renderLabel(item.label || '', item.labelTextStyle,item.value)}
|
|
481
|
+
? renderAnimatedLabel(item.label || '', item.labelTextStyle, item.value)
|
|
482
|
+
: renderLabel(item.label || '', item.labelTextStyle, item.value)}
|
|
433
483
|
</TouchableOpacity>
|
|
434
484
|
);
|
|
435
485
|
};
|
|
436
486
|
|
|
437
|
-
export default RenderBars;
|
|
487
|
+
export default RenderBars;
|
package/src/BarChart/index.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import React, {
|
|
|
4
4
|
useEffect,
|
|
5
5
|
useMemo,
|
|
6
6
|
useState,
|
|
7
|
+
useRef,
|
|
7
8
|
} from 'react';
|
|
8
9
|
import {
|
|
9
10
|
View,
|
|
@@ -19,7 +20,6 @@ import RenderStackBars from './RenderStackBars';
|
|
|
19
20
|
import Rule from '../Components/lineSvg';
|
|
20
21
|
import {bezierCommand, svgPath} from '../utils';
|
|
21
22
|
import Svg, {Circle, Path, Rect, Text as CanvasText} from 'react-native-svg';
|
|
22
|
-
import { useRef } from 'react';
|
|
23
23
|
|
|
24
24
|
type PropTypes = {
|
|
25
25
|
width?: number;
|
|
@@ -47,6 +47,7 @@ type PropTypes = {
|
|
|
47
47
|
yAxisTextStyle?: any;
|
|
48
48
|
yAxisLabelWidth?: number;
|
|
49
49
|
hideYAxisText?: Boolean;
|
|
50
|
+
yAxisSide?: string;
|
|
50
51
|
initialSpacing?: number;
|
|
51
52
|
barWidth?: number;
|
|
52
53
|
sideWidth?: number;
|
|
@@ -119,7 +120,8 @@ type PropTypes = {
|
|
|
119
120
|
yAxisLabelSuffix?: String;
|
|
120
121
|
autoShiftLabels?: Boolean;
|
|
121
122
|
scrollToEnd?: Boolean;
|
|
122
|
-
scrollAnimation?: Boolean
|
|
123
|
+
scrollAnimation?: Boolean;
|
|
124
|
+
labelsExtraHeight?: number;
|
|
123
125
|
};
|
|
124
126
|
type lineConfigType = {
|
|
125
127
|
curved?: Boolean;
|
|
@@ -230,6 +232,7 @@ export const BarChart = (props: PropTypes) => {
|
|
|
230
232
|
const labelWidth = props.labelWidth || 0;
|
|
231
233
|
const scrollToEnd = props.scrollToEnd || false;
|
|
232
234
|
const scrollAnimation = props.scrollAnimation === false ? false : true;
|
|
235
|
+
const labelsExtraHeight = props.labelsExtraHeight || 0;
|
|
233
236
|
|
|
234
237
|
let totalWidth = spacing;
|
|
235
238
|
let maxItem = 0, minItem = 0;
|
|
@@ -321,6 +324,7 @@ export const BarChart = (props: PropTypes) => {
|
|
|
321
324
|
|
|
322
325
|
const yAxisLabelPrefix = props.yAxisLabelPrefix || '';
|
|
323
326
|
const yAxisLabelSuffix = props.yAxisLabelSuffix || '';
|
|
327
|
+
const yAxisSide = props.yAxisSide || 'left';
|
|
324
328
|
|
|
325
329
|
const xAxisThickness =
|
|
326
330
|
props.xAxisThickness === 0
|
|
@@ -598,6 +602,7 @@ export const BarChart = (props: PropTypes) => {
|
|
|
598
602
|
? props.width || totalWidth
|
|
599
603
|
: props.width || totalWidth + 11,
|
|
600
604
|
},
|
|
605
|
+
yAxisSide === 'right' && {transform:[{rotateY:'180deg'}]}
|
|
601
606
|
]}>
|
|
602
607
|
<View
|
|
603
608
|
style={[
|
|
@@ -623,12 +628,13 @@ export const BarChart = (props: PropTypes) => {
|
|
|
623
628
|
style={[
|
|
624
629
|
yAxisTextStyle,
|
|
625
630
|
index === noOfSections && {marginBottom: stepHeight / -2},
|
|
626
|
-
horizontal
|
|
631
|
+
horizontal ? {
|
|
627
632
|
transform: [
|
|
628
633
|
{rotate: '270deg'},
|
|
629
634
|
{translateY: yAxisAtTop ? 0 : 50},
|
|
630
635
|
],
|
|
631
|
-
}
|
|
636
|
+
}:
|
|
637
|
+
yAxisSide === 'right' && {transform:[{rotateY:'180deg'}]}
|
|
632
638
|
]}>
|
|
633
639
|
{label}
|
|
634
640
|
</Text>
|
|
@@ -1091,8 +1097,12 @@ export const BarChart = (props: PropTypes) => {
|
|
|
1091
1097
|
style={[
|
|
1092
1098
|
styles.container,
|
|
1093
1099
|
{
|
|
1094
|
-
height:
|
|
1100
|
+
height:
|
|
1101
|
+
containerHeight +
|
|
1102
|
+
horizSectionsBelow.length * stepHeight +
|
|
1103
|
+
labelsExtraHeight,
|
|
1095
1104
|
},
|
|
1105
|
+
yAxisSide === 'right' && {marginLeft: yAxisLabelWidth + yAxisThickness},
|
|
1096
1106
|
props.width && {width: props.width},
|
|
1097
1107
|
horizontal && {transform: [{rotate: '90deg'}, {translateY: -15}]},
|
|
1098
1108
|
]}>
|
|
@@ -1106,7 +1116,7 @@ export const BarChart = (props: PropTypes) => {
|
|
|
1106
1116
|
}}
|
|
1107
1117
|
style={[
|
|
1108
1118
|
{
|
|
1109
|
-
marginLeft: yAxisLabelWidth,
|
|
1119
|
+
marginLeft: yAxisSide === 'right' ? -yAxisLabelWidth+10 : yAxisLabelWidth,
|
|
1110
1120
|
position: 'absolute',
|
|
1111
1121
|
bottom: stepHeight * -0.5 - 60 + xAxisThickness,
|
|
1112
1122
|
},
|
|
@@ -1119,7 +1129,7 @@ export const BarChart = (props: PropTypes) => {
|
|
|
1119
1129
|
// backgroundColor: 'yellow',
|
|
1120
1130
|
height: containerHeight + 130 + horizSectionsBelow.length * stepHeight,
|
|
1121
1131
|
paddingLeft: initialSpacing,
|
|
1122
|
-
paddingBottom:horizSectionsBelow.length * stepHeight,
|
|
1132
|
+
paddingBottom:horizSectionsBelow.length * stepHeight + labelsExtraHeight,
|
|
1123
1133
|
alignItems: 'flex-end',
|
|
1124
1134
|
},
|
|
1125
1135
|
!props.width && {width: totalWidth},
|
package/src/LineChart/index.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import React, {
|
|
|
4
4
|
useEffect,
|
|
5
5
|
useMemo,
|
|
6
6
|
useState,
|
|
7
|
+
useRef,
|
|
7
8
|
} from 'react';
|
|
8
9
|
import {
|
|
9
10
|
View,
|
|
@@ -100,6 +101,7 @@ type propTypes = {
|
|
|
100
101
|
xAxisIndicesWidth?: number;
|
|
101
102
|
xAxisIndicesColor?: ColorValue;
|
|
102
103
|
yAxisIndicesColor?: ColorValue;
|
|
104
|
+
yAxisSide?: string;
|
|
103
105
|
|
|
104
106
|
color?: string;
|
|
105
107
|
color1?: string;
|
|
@@ -188,6 +190,8 @@ type propTypes = {
|
|
|
188
190
|
width?: number;
|
|
189
191
|
yAxisLabelPrefix?: String;
|
|
190
192
|
yAxisLabelSuffix?: String;
|
|
193
|
+
scrollToEnd?: Boolean;
|
|
194
|
+
scrollAnimation?: Boolean;
|
|
191
195
|
};
|
|
192
196
|
type referenceConfigType = {
|
|
193
197
|
thickness: number;
|
|
@@ -245,6 +249,7 @@ type sectionType = {
|
|
|
245
249
|
};
|
|
246
250
|
|
|
247
251
|
export const LineChart = (props: propTypes) => {
|
|
252
|
+
const scrollRef = useRef();
|
|
248
253
|
const [points, setPoints] = useState('');
|
|
249
254
|
const [points2, setPoints2] = useState('');
|
|
250
255
|
const [points3, setPoints3] = useState('');
|
|
@@ -257,6 +262,8 @@ export const LineChart = (props: propTypes) => {
|
|
|
257
262
|
let data = useMemo(() => props.data || [], [props.data]);
|
|
258
263
|
const data2 = useMemo(() => props.data2 || [], [props.data2]);
|
|
259
264
|
const data3 = useMemo(() => props.data3 || [], [props.data3]);
|
|
265
|
+
const scrollToEnd = props.scrollToEnd || false;
|
|
266
|
+
const scrollAnimation = props.scrollAnimation === false ? false : true;
|
|
260
267
|
|
|
261
268
|
const opacValue = useMemo(() => new Animated.Value(0), []);
|
|
262
269
|
const widthValue = useMemo(() => new Animated.Value(0), []);
|
|
@@ -271,6 +278,8 @@ export const LineChart = (props: propTypes) => {
|
|
|
271
278
|
|
|
272
279
|
const yAxisLabelPrefix = props.yAxisLabelPrefix || '';
|
|
273
280
|
const yAxisLabelSuffix = props.yAxisLabelSuffix || '';
|
|
281
|
+
const yAxisSide = props.yAxisSide || 'left';
|
|
282
|
+
|
|
274
283
|
|
|
275
284
|
if (!initialData) {
|
|
276
285
|
initialData = [...data];
|
|
@@ -446,7 +455,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
446
455
|
const xAxisThickness = props.xAxisThickness || 1;
|
|
447
456
|
const xAxisColor = props.xAxisColor || 'black';
|
|
448
457
|
|
|
449
|
-
let totalWidth =
|
|
458
|
+
let totalWidth = initialSpacing;
|
|
450
459
|
let maxItem = 0;
|
|
451
460
|
data.forEach((item: itemType) => {
|
|
452
461
|
if (item.value > maxItem) {
|
|
@@ -957,7 +966,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
957
966
|
labelComponent()
|
|
958
967
|
) : (
|
|
959
968
|
<Text
|
|
960
|
-
style={
|
|
969
|
+
style={labelTextStyle || {textAlign: 'center'}}
|
|
961
970
|
numberOfLines={1}>
|
|
962
971
|
{label || ''}
|
|
963
972
|
</Text>
|
|
@@ -995,7 +1004,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
995
1004
|
labelComponent()
|
|
996
1005
|
) : (
|
|
997
1006
|
<Text
|
|
998
|
-
style={
|
|
1007
|
+
style={labelTextStyle || {textAlign: 'center'}}
|
|
999
1008
|
numberOfLines={1}>
|
|
1000
1009
|
{label || ''}
|
|
1001
1010
|
</Text>
|
|
@@ -1067,8 +1076,9 @@ export const LineChart = (props: propTypes) => {
|
|
|
1067
1076
|
style={[
|
|
1068
1077
|
styles.horizBar,
|
|
1069
1078
|
{
|
|
1070
|
-
width: props.width ? props.width + 15
|
|
1079
|
+
width: (props.width ? props.width : totalWidth) + 15,
|
|
1071
1080
|
},
|
|
1081
|
+
yAxisSide === 'right' && {transform:[{rotateY:'180deg'}]}
|
|
1072
1082
|
]}>
|
|
1073
1083
|
<View
|
|
1074
1084
|
style={[
|
|
@@ -1085,6 +1095,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
1085
1095
|
ellipsizeMode={'clip'}
|
|
1086
1096
|
style={[
|
|
1087
1097
|
yAxisTextStyle,
|
|
1098
|
+
yAxisSide === 'right' && {transform:[{rotateY:'180deg'}]},
|
|
1088
1099
|
index === noOfSections && {
|
|
1089
1100
|
marginBottom: stepHeight / -2,
|
|
1090
1101
|
},
|
|
@@ -1668,7 +1679,7 @@ export const LineChart = (props: propTypes) => {
|
|
|
1668
1679
|
};
|
|
1669
1680
|
|
|
1670
1681
|
return (
|
|
1671
|
-
<View style={[styles.container, {height: containerHeight}]}>
|
|
1682
|
+
<View style={[styles.container, {height: containerHeight}, yAxisSide === 'right' && {marginLeft: yAxisLabelWidth + yAxisThickness }]}>
|
|
1672
1683
|
{props.hideAxesAndRules !== true && renderHorizSections()}
|
|
1673
1684
|
{/* {sectionsOverlay()} */}
|
|
1674
1685
|
<ScrollView
|
|
@@ -1676,16 +1687,22 @@ export const LineChart = (props: propTypes) => {
|
|
|
1676
1687
|
contentContainerStyle={[
|
|
1677
1688
|
{
|
|
1678
1689
|
height: containerHeight + 130,
|
|
1679
|
-
width: totalWidth,
|
|
1690
|
+
width: totalWidth -20,
|
|
1680
1691
|
// backgroundColor: 'yellow'
|
|
1681
1692
|
},
|
|
1682
|
-
!props.width && {width: totalWidth},
|
|
1693
|
+
!props.width && {width: totalWidth -20},
|
|
1683
1694
|
]}
|
|
1684
1695
|
scrollEnabled={!disableScroll}
|
|
1696
|
+
ref={scrollRef}
|
|
1697
|
+
onContentSizeChange={()=>{
|
|
1698
|
+
if(scrollRef.current && scrollToEnd){
|
|
1699
|
+
scrollRef.current.scrollToEnd({animated: scrollAnimation});
|
|
1700
|
+
}
|
|
1701
|
+
}}
|
|
1685
1702
|
showsHorizontalScrollIndicator={showScrollIndicator}
|
|
1686
1703
|
style={[
|
|
1687
1704
|
{
|
|
1688
|
-
marginLeft: yAxisLabelWidth + yAxisThickness,
|
|
1705
|
+
marginLeft: yAxisSide === 'right' ? -yAxisLabelWidth - yAxisThickness + 6 : yAxisLabelWidth + yAxisThickness,
|
|
1689
1706
|
position: 'absolute',
|
|
1690
1707
|
bottom: stepHeight * -0.5 - 60, //stepHeight * -0.5 + xAxisThickness,
|
|
1691
1708
|
paddingRight: 100,
|