react-native-gifted-charts 1.2.22 → 1.2.23
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/BarChart/RenderBars.tsx +211 -187
- package/src/BarChart/RenderStackBars.tsx +72 -38
- package/src/BarChart/index.tsx +17 -1
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.23",
|
|
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": [
|
|
@@ -65,6 +65,10 @@ type Props = {
|
|
|
65
65
|
barMarginBottom?: number;
|
|
66
66
|
onPress?: Function;
|
|
67
67
|
xAxisTextNumberOfLines: number;
|
|
68
|
+
renderTooltip: Function;
|
|
69
|
+
initialSpacing: number;
|
|
70
|
+
selectedIndex: number;
|
|
71
|
+
setSelectedIndex: Function;
|
|
68
72
|
};
|
|
69
73
|
type itemType = {
|
|
70
74
|
value?: number;
|
|
@@ -114,6 +118,10 @@ const RenderBars = (props: Props) => {
|
|
|
114
118
|
label,
|
|
115
119
|
labelTextStyle,
|
|
116
120
|
xAxisTextNumberOfLines,
|
|
121
|
+
renderTooltip,
|
|
122
|
+
initialSpacing,
|
|
123
|
+
selectedIndex,
|
|
124
|
+
setSelectedIndex,
|
|
117
125
|
} = props;
|
|
118
126
|
|
|
119
127
|
const barMarginBottom =
|
|
@@ -318,139 +326,200 @@ const RenderBars = (props: Props) => {
|
|
|
318
326
|
);
|
|
319
327
|
};
|
|
320
328
|
|
|
329
|
+
const barHeight =
|
|
330
|
+
(item.value >= 0 && (!isThreeD || isAnimated) && item.topLabelComponent
|
|
331
|
+
? (item.topLabelComponentHeight || 30) +
|
|
332
|
+
(Math.abs(item.value) * (containerHeight || 200)) / (maxValue || 200)
|
|
333
|
+
: (Math.abs(item.value) * (containerHeight || 200)) / (maxValue || 200)) -
|
|
334
|
+
barMarginBottom;
|
|
335
|
+
|
|
321
336
|
return (
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
item.
|
|
341
|
-
|
|
337
|
+
<>
|
|
338
|
+
<TouchableOpacity
|
|
339
|
+
disabled={item.disablePress || props.disablePress}
|
|
340
|
+
activeOpacity={props.activeOpacity || 0.2}
|
|
341
|
+
onPress={() => {
|
|
342
|
+
if (renderTooltip) {
|
|
343
|
+
setSelectedIndex(index);
|
|
344
|
+
}
|
|
345
|
+
item.onPress
|
|
346
|
+
? item.onPress()
|
|
347
|
+
: props.onPress
|
|
348
|
+
? props.onPress(item, index)
|
|
349
|
+
: null;
|
|
350
|
+
}}
|
|
351
|
+
style={[
|
|
352
|
+
{
|
|
353
|
+
// overflow: 'visible',
|
|
354
|
+
marginBottom: 60 + barMarginBottom,
|
|
355
|
+
width: item.barWidth || props.barWidth || 30,
|
|
356
|
+
height: barHeight,
|
|
357
|
+
marginRight: spacing,
|
|
358
|
+
},
|
|
359
|
+
item.value < 0 && {
|
|
360
|
+
transform: [
|
|
361
|
+
{
|
|
362
|
+
translateY:
|
|
363
|
+
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
364
|
+
(maxValue || 200),
|
|
365
|
+
},
|
|
366
|
+
{rotateZ: '180deg'},
|
|
367
|
+
],
|
|
368
|
+
},
|
|
369
|
+
// !isThreeD && !item.showGradient && !props.showGradient &&
|
|
370
|
+
// { backgroundColor: item.frontColor || props.frontColor || 'black' },
|
|
371
|
+
side !== 'right' && {zIndex: data.length - index},
|
|
372
|
+
]}>
|
|
373
|
+
{props.showVerticalLines && (
|
|
374
|
+
<View
|
|
375
|
+
style={{
|
|
376
|
+
zIndex: props.verticalLinesZIndex,
|
|
377
|
+
position: 'absolute',
|
|
378
|
+
height: (containerHeight || 200) + 15,
|
|
379
|
+
width: props.verticalLinesThickness,
|
|
380
|
+
bottom: 0,
|
|
381
|
+
left: (item.barWidth || props.barWidth || 30) / 2,
|
|
382
|
+
backgroundColor: props.verticalLinesColor,
|
|
383
|
+
}}
|
|
384
|
+
/>
|
|
385
|
+
)}
|
|
386
|
+
{props.showXAxisIndices && (
|
|
387
|
+
<View
|
|
388
|
+
style={{
|
|
389
|
+
zIndex: 2,
|
|
390
|
+
position: 'absolute',
|
|
391
|
+
height: props.xAxisIndicesHeight,
|
|
392
|
+
width: props.xAxisIndicesWidth,
|
|
393
|
+
bottom: 0,
|
|
394
|
+
left: (item.barWidth || props.barWidth || 30) / 2,
|
|
395
|
+
backgroundColor: props.xAxisIndicesColor,
|
|
396
|
+
}}
|
|
397
|
+
/>
|
|
398
|
+
)}
|
|
399
|
+
{isThreeD ? (
|
|
400
|
+
isAnimated ? (
|
|
401
|
+
<AnimatedBar
|
|
402
|
+
barBackgroundPattern={
|
|
403
|
+
item.barBackgroundPattern || props.barBackgroundPattern
|
|
404
|
+
}
|
|
405
|
+
patternId={item.patternId || props.patternId}
|
|
406
|
+
topLabelContainerStyle={item.topLabelContainerStyle}
|
|
407
|
+
width={item.barWidth || props.barWidth || 30}
|
|
408
|
+
sideWidth={
|
|
409
|
+
item.sideWidth ||
|
|
410
|
+
props.sideWidth ||
|
|
411
|
+
(item.barWidth || props.barWidth || 30) / 2
|
|
412
|
+
}
|
|
413
|
+
side={side || 'left'}
|
|
414
|
+
frontColor={item.frontColor || props.frontColor || ''}
|
|
415
|
+
sideColor={item.sideColor || props.sideColor || ''}
|
|
416
|
+
topColor={item.topColor || props.topColor || ''}
|
|
417
|
+
showGradient={item.showGradient || props.showGradient || false}
|
|
418
|
+
gradientColor={item.gradientColor || props.gradientColor}
|
|
419
|
+
topLabelComponent={item.topLabelComponent}
|
|
420
|
+
opacity={opacity || 1}
|
|
421
|
+
animationDuration={animationDuration || 800}
|
|
422
|
+
height={
|
|
342
423
|
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
343
|
-
(maxValue || 200)
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
424
|
+
(maxValue || 200) -
|
|
425
|
+
barMarginBottom
|
|
426
|
+
}
|
|
427
|
+
intactTopLabel={props.intactTopLabel}
|
|
428
|
+
horizontal={props.horizontal}
|
|
429
|
+
/>
|
|
430
|
+
) : (
|
|
431
|
+
<ThreeDBar
|
|
432
|
+
barBackgroundPattern={
|
|
433
|
+
item.barBackgroundPattern || props.barBackgroundPattern
|
|
434
|
+
}
|
|
435
|
+
patternId={item.patternId || props.patternId}
|
|
436
|
+
style={{}}
|
|
437
|
+
color={''}
|
|
438
|
+
topLabelContainerStyle={item.topLabelContainerStyle}
|
|
439
|
+
width={item.barWidth || props.barWidth || 30}
|
|
440
|
+
sideWidth={
|
|
441
|
+
item.sideWidth ||
|
|
442
|
+
props.sideWidth ||
|
|
443
|
+
(item.barWidth || props.barWidth || 30) / 2
|
|
444
|
+
}
|
|
445
|
+
side={side || 'left'}
|
|
446
|
+
frontColor={item.frontColor || props.frontColor || ''}
|
|
447
|
+
sideColor={item.sideColor || props.sideColor || ''}
|
|
448
|
+
topColor={item.topColor || props.topColor || ''}
|
|
449
|
+
showGradient={item.showGradient || props.showGradient || false}
|
|
450
|
+
gradientColor={item.gradientColor || props.gradientColor}
|
|
451
|
+
topLabelComponent={item.topLabelComponent || Function}
|
|
452
|
+
opacity={opacity || 1}
|
|
453
|
+
horizontal={props.horizontal}
|
|
454
|
+
intactTopLabel={props.intactTopLabel}
|
|
455
|
+
height={
|
|
352
456
|
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
sideWidth={
|
|
398
|
-
item.sideWidth ||
|
|
399
|
-
props.sideWidth ||
|
|
400
|
-
(item.barWidth || props.barWidth || 30) / 2
|
|
401
|
-
}
|
|
402
|
-
side={side || 'left'}
|
|
403
|
-
frontColor={item.frontColor || props.frontColor || ''}
|
|
404
|
-
sideColor={item.sideColor || props.sideColor || ''}
|
|
405
|
-
topColor={item.topColor || props.topColor || ''}
|
|
406
|
-
showGradient={item.showGradient || props.showGradient || false}
|
|
407
|
-
gradientColor={item.gradientColor || props.gradientColor}
|
|
408
|
-
topLabelComponent={item.topLabelComponent}
|
|
409
|
-
opacity={opacity || 1}
|
|
457
|
+
(maxValue || 200) -
|
|
458
|
+
barMarginBottom
|
|
459
|
+
}
|
|
460
|
+
value={item.value}
|
|
461
|
+
/>
|
|
462
|
+
)
|
|
463
|
+
) : item.showGradient || props.showGradient ? (
|
|
464
|
+
isAnimated ? (
|
|
465
|
+
<Animated2DWithGradient
|
|
466
|
+
barBackgroundPattern={props.barBackgroundPattern}
|
|
467
|
+
patternId={props.patternId}
|
|
468
|
+
barWidth={props.barWidth}
|
|
469
|
+
item={item}
|
|
470
|
+
opacity={opacity}
|
|
471
|
+
animationDuration={animationDuration || 800}
|
|
472
|
+
roundedBottom={props.roundedBottom || false}
|
|
473
|
+
roundedTop={props.roundedTop || false}
|
|
474
|
+
gradientColor={props.gradientColor}
|
|
475
|
+
frontColor={props.frontColor || 'black'}
|
|
476
|
+
containerHeight={containerHeight}
|
|
477
|
+
maxValue={maxValue}
|
|
478
|
+
height={
|
|
479
|
+
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
480
|
+
(maxValue || 200)
|
|
481
|
+
}
|
|
482
|
+
barMarginBottom={barMarginBottom}
|
|
483
|
+
cappedBars={props.cappedBars}
|
|
484
|
+
capThickness={props.capThickness}
|
|
485
|
+
capColor={props.capColor}
|
|
486
|
+
capRadius={props.capRadius}
|
|
487
|
+
horizontal={props.horizontal}
|
|
488
|
+
intactTopLabel={props.intactTopLabel}
|
|
489
|
+
barBorderRadius={props.barBorderRadius || 0}
|
|
490
|
+
/>
|
|
491
|
+
) : (
|
|
492
|
+
static2DWithGradient(item)
|
|
493
|
+
)
|
|
494
|
+
) : isAnimated ? (
|
|
495
|
+
<Animated2DWithGradient
|
|
496
|
+
barBackgroundPattern={props.barBackgroundPattern}
|
|
497
|
+
patternId={props.patternId}
|
|
498
|
+
barWidth={props.barWidth}
|
|
499
|
+
item={item}
|
|
500
|
+
opacity={opacity}
|
|
410
501
|
animationDuration={animationDuration || 800}
|
|
502
|
+
roundedBottom={props.roundedBottom || false}
|
|
503
|
+
roundedTop={props.roundedTop || false}
|
|
504
|
+
gradientColor={props.gradientColor}
|
|
505
|
+
noGradient
|
|
506
|
+
frontColor={props.frontColor || 'black'}
|
|
507
|
+
containerHeight={containerHeight}
|
|
508
|
+
maxValue={maxValue}
|
|
411
509
|
height={
|
|
412
510
|
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
413
|
-
|
|
414
|
-
barMarginBottom
|
|
415
|
-
}
|
|
416
|
-
intactTopLabel={props.intactTopLabel}
|
|
417
|
-
horizontal={props.horizontal}
|
|
418
|
-
/>
|
|
419
|
-
) : (
|
|
420
|
-
<ThreeDBar
|
|
421
|
-
barBackgroundPattern={
|
|
422
|
-
item.barBackgroundPattern || props.barBackgroundPattern
|
|
423
|
-
}
|
|
424
|
-
patternId={item.patternId || props.patternId}
|
|
425
|
-
style={{}}
|
|
426
|
-
color={''}
|
|
427
|
-
topLabelContainerStyle={item.topLabelContainerStyle}
|
|
428
|
-
width={item.barWidth || props.barWidth || 30}
|
|
429
|
-
sideWidth={
|
|
430
|
-
item.sideWidth ||
|
|
431
|
-
props.sideWidth ||
|
|
432
|
-
(item.barWidth || props.barWidth || 30) / 2
|
|
511
|
+
(maxValue || 200)
|
|
433
512
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
gradientColor={item.gradientColor || props.gradientColor}
|
|
440
|
-
topLabelComponent={item.topLabelComponent || Function}
|
|
441
|
-
opacity={opacity || 1}
|
|
513
|
+
barMarginBottom={barMarginBottom}
|
|
514
|
+
cappedBars={props.cappedBars}
|
|
515
|
+
capThickness={props.capThickness}
|
|
516
|
+
capColor={props.capColor}
|
|
517
|
+
capRadius={props.capRadius}
|
|
442
518
|
horizontal={props.horizontal}
|
|
443
519
|
intactTopLabel={props.intactTopLabel}
|
|
444
|
-
|
|
445
|
-
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
446
|
-
(maxValue || 200) -
|
|
447
|
-
barMarginBottom
|
|
448
|
-
}
|
|
449
|
-
value={item.value}
|
|
520
|
+
barBorderRadius={props.barBorderRadius || 0}
|
|
450
521
|
/>
|
|
451
|
-
)
|
|
452
|
-
) : item.showGradient || props.showGradient ? (
|
|
453
|
-
isAnimated ? (
|
|
522
|
+
) : (
|
|
454
523
|
<Animated2DWithGradient
|
|
455
524
|
barBackgroundPattern={props.barBackgroundPattern}
|
|
456
525
|
patternId={props.patternId}
|
|
@@ -461,6 +530,8 @@ const RenderBars = (props: Props) => {
|
|
|
461
530
|
roundedBottom={props.roundedBottom || false}
|
|
462
531
|
roundedTop={props.roundedTop || false}
|
|
463
532
|
gradientColor={props.gradientColor}
|
|
533
|
+
noGradient
|
|
534
|
+
noAnimation
|
|
464
535
|
frontColor={props.frontColor || 'black'}
|
|
465
536
|
containerHeight={containerHeight}
|
|
466
537
|
maxValue={maxValue}
|
|
@@ -477,71 +548,24 @@ const RenderBars = (props: Props) => {
|
|
|
477
548
|
intactTopLabel={props.intactTopLabel}
|
|
478
549
|
barBorderRadius={props.barBorderRadius || 0}
|
|
479
550
|
/>
|
|
480
|
-
)
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
containerHeight={containerHeight}
|
|
497
|
-
maxValue={maxValue}
|
|
498
|
-
height={
|
|
499
|
-
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
500
|
-
(maxValue || 200)
|
|
501
|
-
}
|
|
502
|
-
barMarginBottom={barMarginBottom}
|
|
503
|
-
cappedBars={props.cappedBars}
|
|
504
|
-
capThickness={props.capThickness}
|
|
505
|
-
capColor={props.capColor}
|
|
506
|
-
capRadius={props.capRadius}
|
|
507
|
-
horizontal={props.horizontal}
|
|
508
|
-
intactTopLabel={props.intactTopLabel}
|
|
509
|
-
barBorderRadius={props.barBorderRadius || 0}
|
|
510
|
-
/>
|
|
511
|
-
) : (
|
|
512
|
-
<Animated2DWithGradient
|
|
513
|
-
barBackgroundPattern={props.barBackgroundPattern}
|
|
514
|
-
patternId={props.patternId}
|
|
515
|
-
barWidth={props.barWidth}
|
|
516
|
-
item={item}
|
|
517
|
-
opacity={opacity}
|
|
518
|
-
animationDuration={animationDuration || 800}
|
|
519
|
-
roundedBottom={props.roundedBottom || false}
|
|
520
|
-
roundedTop={props.roundedTop || false}
|
|
521
|
-
gradientColor={props.gradientColor}
|
|
522
|
-
noGradient
|
|
523
|
-
noAnimation
|
|
524
|
-
frontColor={props.frontColor || 'black'}
|
|
525
|
-
containerHeight={containerHeight}
|
|
526
|
-
maxValue={maxValue}
|
|
527
|
-
height={
|
|
528
|
-
(Math.abs(item.value) * (containerHeight || 200)) /
|
|
529
|
-
(maxValue || 200)
|
|
530
|
-
}
|
|
531
|
-
barMarginBottom={barMarginBottom}
|
|
532
|
-
cappedBars={props.cappedBars}
|
|
533
|
-
capThickness={props.capThickness}
|
|
534
|
-
capColor={props.capColor}
|
|
535
|
-
capRadius={props.capRadius}
|
|
536
|
-
horizontal={props.horizontal}
|
|
537
|
-
intactTopLabel={props.intactTopLabel}
|
|
538
|
-
barBorderRadius={props.barBorderRadius || 0}
|
|
539
|
-
/>
|
|
551
|
+
)}
|
|
552
|
+
{isAnimated
|
|
553
|
+
? renderAnimatedLabel(label, labelTextStyle, item.value)
|
|
554
|
+
: renderLabel(label, labelTextStyle, item.value)}
|
|
555
|
+
</TouchableOpacity>
|
|
556
|
+
{renderTooltip && selectedIndex === index && (
|
|
557
|
+
<View
|
|
558
|
+
style={{
|
|
559
|
+
position: 'absolute',
|
|
560
|
+
bottom: barHeight + 60,
|
|
561
|
+
left:
|
|
562
|
+
(item.barWidth || props.barWidth || 30) * index + initialSpacing,
|
|
563
|
+
zIndex: 1000,
|
|
564
|
+
}}>
|
|
565
|
+
{renderTooltip(item, index)}
|
|
566
|
+
</View>
|
|
540
567
|
)}
|
|
541
|
-
|
|
542
|
-
? renderAnimatedLabel(label, labelTextStyle, item.value)
|
|
543
|
-
: renderLabel(label, labelTextStyle, item.value)}
|
|
544
|
-
</TouchableOpacity>
|
|
568
|
+
</>
|
|
545
569
|
);
|
|
546
570
|
};
|
|
547
571
|
|
|
@@ -39,6 +39,11 @@ type Props = {
|
|
|
39
39
|
barBackgroundPattern?: Function;
|
|
40
40
|
patternId?: String;
|
|
41
41
|
xAxisTextNumberOfLines: number;
|
|
42
|
+
renderTooltip: Function;
|
|
43
|
+
initialSpacing: number;
|
|
44
|
+
selectedIndex: number;
|
|
45
|
+
setSelectedIndex: Function;
|
|
46
|
+
activeOpacity: number;
|
|
42
47
|
};
|
|
43
48
|
type itemType = {
|
|
44
49
|
value?: number;
|
|
@@ -63,6 +68,7 @@ const RenderStackBars = (props: Props) => {
|
|
|
63
68
|
barBackgroundPattern,
|
|
64
69
|
patternId,
|
|
65
70
|
item,
|
|
71
|
+
index,
|
|
66
72
|
containerHeight,
|
|
67
73
|
maxValue,
|
|
68
74
|
spacing,
|
|
@@ -71,6 +77,11 @@ const RenderStackBars = (props: Props) => {
|
|
|
71
77
|
label,
|
|
72
78
|
labelTextStyle,
|
|
73
79
|
xAxisTextNumberOfLines,
|
|
80
|
+
renderTooltip,
|
|
81
|
+
initialSpacing,
|
|
82
|
+
selectedIndex,
|
|
83
|
+
setSelectedIndex,
|
|
84
|
+
activeOpacity,
|
|
74
85
|
} = props;
|
|
75
86
|
const disablePress = props.disablePress || false;
|
|
76
87
|
const renderLabel = (label: String, labelTextStyle: any) => {
|
|
@@ -123,7 +134,15 @@ const RenderStackBars = (props: Props) => {
|
|
|
123
134
|
const cotainsNegative = item.stacks.some(item => item.value < 0);
|
|
124
135
|
return (
|
|
125
136
|
<>
|
|
126
|
-
<
|
|
137
|
+
<TouchableOpacity
|
|
138
|
+
disabled={disablePress}
|
|
139
|
+
activeOpacity={activeOpacity}
|
|
140
|
+
onPress={() => {
|
|
141
|
+
setSelectedIndex(index);
|
|
142
|
+
if(item.onPress){
|
|
143
|
+
item.onPress();
|
|
144
|
+
}
|
|
145
|
+
}}
|
|
127
146
|
style={[
|
|
128
147
|
{
|
|
129
148
|
position: 'absolute',
|
|
@@ -142,7 +161,8 @@ const RenderStackBars = (props: Props) => {
|
|
|
142
161
|
<TouchableOpacity
|
|
143
162
|
key={index}
|
|
144
163
|
onPress={stackItem.onPress}
|
|
145
|
-
|
|
164
|
+
activeOpacity={activeOpacity}
|
|
165
|
+
disabled={disablePress || !stackItem.onPress}
|
|
146
166
|
style={[
|
|
147
167
|
{
|
|
148
168
|
position: 'absolute',
|
|
@@ -187,7 +207,7 @@ const RenderStackBars = (props: Props) => {
|
|
|
187
207
|
/>
|
|
188
208
|
</Svg>
|
|
189
209
|
)}
|
|
190
|
-
</
|
|
210
|
+
</TouchableOpacity>
|
|
191
211
|
{item.topLabelComponent && (
|
|
192
212
|
<View
|
|
193
213
|
style={[
|
|
@@ -214,45 +234,59 @@ const RenderStackBars = (props: Props) => {
|
|
|
214
234
|
};
|
|
215
235
|
|
|
216
236
|
return (
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
{
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
237
|
+
<>
|
|
238
|
+
<View
|
|
239
|
+
style={[
|
|
240
|
+
{
|
|
241
|
+
// overflow: 'visible',
|
|
242
|
+
marginBottom: 60,
|
|
243
|
+
width: item.stacks[0].barWidth || props.barWidth || 30,
|
|
244
|
+
height: totalHeight,
|
|
245
|
+
marginRight: spacing,
|
|
246
|
+
},
|
|
247
|
+
]}>
|
|
248
|
+
{props.showVerticalLines && (
|
|
249
|
+
<View
|
|
250
|
+
style={{
|
|
251
|
+
zIndex: props.verticalLinesZIndex,
|
|
252
|
+
position: 'absolute',
|
|
253
|
+
height: (containerHeight || 200) + 15,
|
|
254
|
+
width: props.verticalLinesThickness,
|
|
255
|
+
bottom: 0,
|
|
256
|
+
left: (item.barWidth || props.barWidth || 30) / 2,
|
|
257
|
+
backgroundColor: props.verticalLinesColor,
|
|
258
|
+
}}
|
|
259
|
+
/>
|
|
260
|
+
)}
|
|
261
|
+
{props.showXAxisIndices && (
|
|
262
|
+
<View
|
|
263
|
+
style={{
|
|
264
|
+
zIndex: 2,
|
|
265
|
+
position: 'absolute',
|
|
266
|
+
height: props.xAxisIndicesHeight,
|
|
267
|
+
width: props.xAxisIndicesWidth,
|
|
268
|
+
bottom: 0,
|
|
269
|
+
left: (item.barWidth || props.barWidth || 30) / 2,
|
|
270
|
+
backgroundColor: props.xAxisIndicesColor,
|
|
271
|
+
}}
|
|
272
|
+
/>
|
|
273
|
+
)}
|
|
274
|
+
{static2DSimple(item)}
|
|
275
|
+
{renderLabel(label || '', labelTextStyle)}
|
|
276
|
+
</View>
|
|
277
|
+
{renderTooltip && selectedIndex === index && (
|
|
241
278
|
<View
|
|
242
279
|
style={{
|
|
243
|
-
zIndex: 2,
|
|
244
280
|
position: 'absolute',
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
|
|
281
|
+
bottom: totalHeight + 60,
|
|
282
|
+
left:
|
|
283
|
+
(item.barWidth || props.barWidth || 30) * index + initialSpacing,
|
|
284
|
+
zIndex: 1000,
|
|
285
|
+
}}>
|
|
286
|
+
{renderTooltip(item, index)}
|
|
287
|
+
</View>
|
|
252
288
|
)}
|
|
253
|
-
|
|
254
|
-
{renderLabel(label || '', labelTextStyle)}
|
|
255
|
-
</View>
|
|
289
|
+
</>
|
|
256
290
|
);
|
|
257
291
|
};
|
|
258
292
|
|
package/src/BarChart/index.tsx
CHANGED
|
@@ -133,6 +133,7 @@ type PropTypes = {
|
|
|
133
133
|
patternId?: String;
|
|
134
134
|
barMarginBottom?: number;
|
|
135
135
|
onPress?: Function;
|
|
136
|
+
renderTooltip?: Function;
|
|
136
137
|
};
|
|
137
138
|
type lineConfigType = {
|
|
138
139
|
initialSpacing?: number;
|
|
@@ -192,6 +193,7 @@ type itemType = {
|
|
|
192
193
|
export const BarChart = (props: PropTypes) => {
|
|
193
194
|
const scrollRef = useRef();
|
|
194
195
|
const [points, setPoints] = useState('');
|
|
196
|
+
const [selectedIndex, setSelectedIndex] = useState(-1);
|
|
195
197
|
const showLine = props.showLine || false;
|
|
196
198
|
const initialSpacing =
|
|
197
199
|
props.initialSpacing === 0 ? 0 : props.initialSpacing || 40;
|
|
@@ -1329,6 +1331,11 @@ export const BarChart = (props: PropTypes) => {
|
|
|
1329
1331
|
{props.hideAxesAndRules !== true && renderHorizSections()}
|
|
1330
1332
|
<ScrollView
|
|
1331
1333
|
ref={scrollRef}
|
|
1334
|
+
onTouchStart={evt => {
|
|
1335
|
+
if (props.renderTooltip) {
|
|
1336
|
+
setSelectedIndex(-1);
|
|
1337
|
+
}
|
|
1338
|
+
}}
|
|
1332
1339
|
onContentSizeChange={() => {
|
|
1333
1340
|
if (scrollRef.current && scrollToEnd) {
|
|
1334
1341
|
scrollRef.current.scrollToEnd({animated: scrollAnimation});
|
|
@@ -1383,7 +1390,7 @@ export const BarChart = (props: PropTypes) => {
|
|
|
1383
1390
|
xAxisThickness={xAxisThickness}
|
|
1384
1391
|
barWidth={props.barWidth}
|
|
1385
1392
|
opacity={opacity}
|
|
1386
|
-
disablePress={props.disablePress}
|
|
1393
|
+
disablePress={item.disablePress || props.disablePress}
|
|
1387
1394
|
rotateLabel={rotateLabel}
|
|
1388
1395
|
showVerticalLines={showVerticalLines}
|
|
1389
1396
|
verticalLinesThickness={verticalLinesThickness}
|
|
@@ -1408,6 +1415,11 @@ export const BarChart = (props: PropTypes) => {
|
|
|
1408
1415
|
item.labelTextStyle || props.xAxisLabelTextStyle
|
|
1409
1416
|
}
|
|
1410
1417
|
xAxisTextNumberOfLines={xAxisTextNumberOfLines}
|
|
1418
|
+
renderTooltip={props.renderTooltip}
|
|
1419
|
+
initialSpacing={initialSpacing}
|
|
1420
|
+
selectedIndex={selectedIndex}
|
|
1421
|
+
setSelectedIndex={setSelectedIndex}
|
|
1422
|
+
activeOpacity={props.activeOpacity || 0.2}
|
|
1411
1423
|
/>
|
|
1412
1424
|
);
|
|
1413
1425
|
})
|
|
@@ -1470,6 +1482,10 @@ export const BarChart = (props: PropTypes) => {
|
|
|
1470
1482
|
}
|
|
1471
1483
|
onPress={props.onPress}
|
|
1472
1484
|
xAxisTextNumberOfLines={xAxisTextNumberOfLines}
|
|
1485
|
+
renderTooltip={props.renderTooltip}
|
|
1486
|
+
initialSpacing={initialSpacing}
|
|
1487
|
+
selectedIndex={selectedIndex}
|
|
1488
|
+
setSelectedIndex={setSelectedIndex}
|
|
1473
1489
|
/>
|
|
1474
1490
|
))}
|
|
1475
1491
|
</Fragment>
|