react-native-gifted-charts 1.4.20 → 1.4.21

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.
Files changed (63) hide show
  1. package/README.md +4 -3
  2. package/dist/BarChart/Animated2DWithGradient.js +1 -0
  3. package/dist/BarChart/RenderBars.js +1 -0
  4. package/dist/BarChart/RenderStackBars.js +1 -0
  5. package/dist/BarChart/index.js +1 -0
  6. package/dist/BarChart/styles.js +1 -0
  7. package/dist/Components/AnimatedThreeDBar/index.js +1 -0
  8. package/dist/Components/AnimatedThreeDBar/styles.js +1 -0
  9. package/dist/Components/BarAndLineChartsWrapper/index.js +1 -0
  10. package/dist/Components/BarAndLineChartsWrapper/renderHorizSections.js +1 -0
  11. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +1 -0
  12. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +1 -0
  13. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.js +1 -0
  14. package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.js +1 -0
  15. package/dist/Components/BarAndLineChartsWrapper/renderVerticalLines.js +1 -0
  16. package/dist/Components/BarSpecificComponents/barBackgroundPattern.js +1 -0
  17. package/dist/Components/BarSpecificComponents/cap.js +1 -0
  18. package/dist/Components/BarSpecificComponents/tooltip.js +1 -0
  19. package/dist/Components/common/LinearGradient.js +1 -0
  20. package/dist/Components/common/Pointer.js +1 -0
  21. package/dist/Components/common/StripAndLabel.js +1 -0
  22. package/dist/Components/lineSvg.js +1 -0
  23. package/dist/LineChart/LineChartBicolor.js +1 -0
  24. package/dist/LineChart/index.js +1 -0
  25. package/dist/LineChart/styles.js +1 -0
  26. package/dist/PieChart/index.js +1 -0
  27. package/dist/PieChart/main.js +1 -0
  28. package/dist/PieChartPro/index.js +1 -0
  29. package/dist/PopulationPyramid/index.js +1 -0
  30. package/dist/index.js +1 -0
  31. package/dist/utils/index.js +1 -0
  32. package/package.json +21 -20
  33. package/src/BarChart/Animated2DWithGradient.tsx +0 -197
  34. package/src/BarChart/RenderBars.tsx +0 -527
  35. package/src/BarChart/RenderStackBars.tsx +0 -359
  36. package/src/BarChart/index.tsx +0 -391
  37. package/src/BarChart/styles.tsx +0 -47
  38. package/src/Components/AnimatedThreeDBar/index.tsx +0 -258
  39. package/src/Components/AnimatedThreeDBar/styles.tsx +0 -14
  40. package/src/Components/BarAndLineChartsWrapper/index.tsx +0 -246
  41. package/src/Components/BarAndLineChartsWrapper/renderHorizSections.tsx +0 -607
  42. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.tsx +0 -151
  43. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.tsx +0 -175
  44. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.tsx +0 -86
  45. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.tsx +0 -42
  46. package/src/Components/BarAndLineChartsWrapper/renderVerticalLines.tsx +0 -131
  47. package/src/Components/BarSpecificComponents/barBackgroundPattern.tsx +0 -30
  48. package/src/Components/BarSpecificComponents/cap.tsx +0 -34
  49. package/src/Components/BarSpecificComponents/tooltip.tsx +0 -59
  50. package/src/Components/common/LinearGradient.tsx +0 -27
  51. package/src/Components/common/Pointer.tsx +0 -37
  52. package/src/Components/common/StripAndLabel.tsx +0 -98
  53. package/src/Components/lineSvg.tsx +0 -42
  54. package/src/LineChart/LineChartBicolor.tsx +0 -740
  55. package/src/LineChart/index.tsx +0 -2231
  56. package/src/LineChart/styles.tsx +0 -47
  57. package/src/PieChart/index.tsx +0 -168
  58. package/src/PieChart/main.tsx +0 -363
  59. package/src/PieChartPro/index.tsx +0 -267
  60. package/src/PopulationPyramid/index.tsx +0 -603
  61. package/src/index.tsx +0 -26
  62. package/src/todos.md +0 -24
  63. package/src/utils/index.ts +0 -16
@@ -1,607 +0,0 @@
1
- import React from 'react';
2
- import {Text, View} from 'react-native';
3
- import Rule from '../lineSvg';
4
- import {styles} from '../../LineChart/styles';
5
- import {
6
- getHorizSectionVals,
7
- yAxisSides,
8
- HorizSectionsType,
9
- horizSectionPropTypes,
10
- chartTypes,
11
- } from 'gifted-charts-core';
12
-
13
- export const renderHorizSections = (props: horizSectionPropTypes) => {
14
- const {
15
- chartType,
16
- width,
17
- noOfSectionsBelowXAxis,
18
- totalWidth,
19
- endSpacing,
20
- yAxisSide,
21
- horizontalRulesStyle,
22
- noOfSections,
23
- sectionColors,
24
- stepHeight,
25
- negativeStepHeight,
26
- yAxisLabelWidth,
27
- yAxisLabelContainerStyle,
28
- yAxisThickness,
29
- yAxisColor,
30
- xAxisThickness,
31
- xAxisColor,
32
- xAxisLength,
33
- xAxisType,
34
- dashWidth,
35
- dashGap,
36
- backgroundColor,
37
- hideRules,
38
- rulesLength,
39
- rulesType,
40
- rulesThickness,
41
- rulesColor,
42
- rulesConfigArray,
43
- spacing,
44
- showYAxisIndices,
45
- yAxisIndicesHeight,
46
- yAxisIndicesWidth,
47
- yAxisIndicesColor,
48
-
49
- hideOrigin,
50
- hideYAxisText,
51
- yAxisTextNumberOfLines,
52
- yAxisTextStyle,
53
- rotateYAxisTexts,
54
- rtl,
55
-
56
- containerHeight,
57
- maxValue,
58
- yAxisOffset,
59
-
60
- horizontal,
61
- yAxisAtTop,
62
- secondaryYAxis,
63
- onlyReferenceLines,
64
- renderReferenceLines,
65
- secondaryXAxis,
66
- } = props;
67
-
68
- const {
69
- secondaryYAxisConfig,
70
- horizSections,
71
- yAxisExtraHeightAtTop,
72
- secondaryHorizSections,
73
- showReferenceLine1,
74
- referenceLine1Config,
75
- referenceLine1Position,
76
- showReferenceLine2,
77
- referenceLine2Config,
78
- referenceLine2Position,
79
- showReferenceLine3,
80
- referenceLine3Config,
81
- referenceLine3Position,
82
- horizSectionsBelow,
83
- secondaryHorizSectionsBelow,
84
- getLabelTexts,
85
- getLabelTextsForSecondaryYAxis,
86
- } = getHorizSectionVals(props);
87
-
88
- const renderAxesAndRules = (index: number) => {
89
- const invertedIndex = horizSections.length - index - 1;
90
- return (
91
- <View
92
- style={[
93
- index === noOfSections
94
- ? styles.lastLeftPart
95
- : !index
96
- ? {justifyContent: 'flex-start'}
97
- : styles.leftPart,
98
- {
99
- borderColor: yAxisColor,
100
- backgroundColor: sectionColors?.[invertedIndex] ?? backgroundColor,
101
- width: (props.width || totalWidth - spacing) + endSpacing,
102
- },
103
- !index ? {height: stepHeight / 2, marginTop: stepHeight / 2} : null,
104
- yAxisSide === yAxisSides.RIGHT
105
- ? {borderRightWidth: yAxisThickness}
106
- : {borderLeftWidth: yAxisThickness},
107
- ]}>
108
- {index === noOfSections ? (
109
- <Rule
110
- config={{
111
- thickness: xAxisThickness,
112
- color: xAxisColor,
113
- width:
114
- xAxisLength ||
115
- (props.width || totalWidth - spacing) + endSpacing,
116
- dashWidth: dashWidth,
117
- dashGap: dashGap,
118
- type: xAxisType,
119
- }}
120
- />
121
- ) : hideRules ? null : (
122
- <Rule
123
- config={{
124
- thickness:
125
- rulesConfigArray[invertedIndex]?.rulesThickness ??
126
- rulesThickness,
127
- color: rulesConfigArray[invertedIndex]?.rulesColor ?? rulesColor,
128
- width:
129
- rulesConfigArray[invertedIndex]?.rulesLength ??
130
- rulesLength ??
131
- (props.width || totalWidth - spacing) + endSpacing,
132
- dashWidth:
133
- rulesConfigArray[invertedIndex]?.dashWidth ?? dashWidth,
134
- dashGap: rulesConfigArray[invertedIndex]?.dashGap ?? dashGap,
135
- type: rulesConfigArray[invertedIndex]?.rulesType ?? rulesType,
136
- }}
137
- />
138
- )}
139
- {showYAxisIndices && index !== noOfSections ? (
140
- <View
141
- style={{
142
- position: 'absolute',
143
- height: yAxisIndicesHeight,
144
- width: yAxisIndicesWidth,
145
- left:
146
- yAxisIndicesWidth / -2 +
147
- (yAxisSide === yAxisSides.RIGHT
148
- ? (width ?? totalWidth) +
149
- yAxisLabelWidth / 2 +
150
- yAxisIndicesWidth / 4
151
- : 0),
152
- backgroundColor: yAxisIndicesColor,
153
- }}
154
- />
155
- ) : null}
156
- </View>
157
- );
158
- };
159
-
160
- const renderExtraHeightOfYAxisAtTop = () => (
161
- <View
162
- style={[
163
- styles.horizBar,
164
- {
165
- width: (width ?? totalWidth) + endSpacing,
166
- top: stepHeight / 2,
167
- },
168
- horizontal &&
169
- !yAxisAtTop && {
170
- transform: [{rotateY: '180deg'}],
171
- },
172
- horizontalRulesStyle,
173
- ]}>
174
- <View
175
- style={[
176
- styles.leftLabel,
177
- {
178
- height: yAxisExtraHeightAtTop,
179
- width: yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
180
- },
181
- yAxisLabelContainerStyle,
182
- ]}
183
- />
184
- <View
185
- style={[
186
- styles.leftPart,
187
- {
188
- borderLeftColor: yAxisColor,
189
- borderRightColor: yAxisColor,
190
- borderTopColor: secondaryXAxis?.color ?? xAxisColor,
191
- borderTopWidth: secondaryXAxis
192
- ? secondaryXAxis.thickness ?? xAxisThickness
193
- : 0,
194
- backgroundColor: backgroundColor,
195
- width: (props.width || totalWidth - spacing) + endSpacing,
196
- },
197
- yAxisSide === yAxisSides.RIGHT
198
- ? {borderRightWidth: yAxisThickness}
199
- : {borderLeftWidth: yAxisThickness},
200
- ]}
201
- />
202
- </View>
203
- );
204
-
205
- const renderSecondaryYaxisLabels = (
206
- horizSections: HorizSectionsType,
207
- isBelow: boolean,
208
- ) =>
209
- horizSections.map((sectionItems, index) => {
210
- let label = getLabelTextsForSecondaryYAxis(sectionItems.value, index);
211
- if (secondaryYAxisConfig.hideOrigin && index === 0) {
212
- label = '';
213
- }
214
- return (
215
- <View
216
- key={index}
217
- style={[
218
- styles.horizBar,
219
- styles.leftLabel,
220
- {
221
- position: 'absolute',
222
- zIndex: 1,
223
- bottom:
224
- (secondaryYAxisConfig.stepHeight ?? 0) *
225
- ((isBelow ? 0 : noOfSectionsBelowXAxis) +
226
- index -
227
- (noOfSectionsBelowXAxis ? 0 : 0.5)),
228
- width: secondaryYAxisConfig.yAxisLabelWidth,
229
- height: secondaryYAxisConfig.stepHeight ?? 0,
230
- },
231
- yAxisLabelContainerStyle,
232
- ]}>
233
- {secondaryYAxisConfig.showYAxisIndices && index !== 0 ? (
234
- <View
235
- style={{
236
- height: secondaryYAxisConfig.yAxisIndicesHeight,
237
- width: secondaryYAxisConfig.yAxisIndicesWidth,
238
- position: 'absolute',
239
- left: (secondaryYAxisConfig.yAxisIndicesWidth ?? 0) / -2,
240
- backgroundColor: secondaryYAxisConfig.yAxisIndicesColor,
241
- }}
242
- />
243
- ) : null}
244
- <Text
245
- numberOfLines={secondaryYAxisConfig.yAxisTextNumberOfLines}
246
- ellipsizeMode={'clip'}
247
- style={[secondaryYAxisConfig.yAxisTextStyle]}>
248
- {label}
249
- </Text>
250
- </View>
251
- );
252
- });
253
-
254
- const referenceLines = () => {
255
- return (
256
- <>
257
- {showReferenceLine1 ? (
258
- <View
259
- style={{
260
- position: 'absolute',
261
- zIndex: referenceLine1Config.zIndex,
262
- bottom:
263
- ((referenceLine1Position - (yAxisOffset ?? 0)) *
264
- containerHeight) /
265
- maxValue,
266
- left:
267
- yAxisSide === yAxisSides.RIGHT
268
- ? 0
269
- : yAxisLabelWidth + yAxisThickness,
270
- }}>
271
- <Rule config={referenceLine1Config} />
272
- {referenceLine1Config.labelText ? (
273
- <Text
274
- style={[
275
- {position: 'absolute'},
276
- referenceLine1Config.labelTextStyle,
277
- ]}>
278
- {referenceLine1Config.labelText}
279
- </Text>
280
- ) : null}
281
- </View>
282
- ) : null}
283
- {showReferenceLine2 ? (
284
- <View
285
- style={{
286
- position: 'absolute',
287
- zIndex: referenceLine2Config.zIndex,
288
- bottom:
289
- ((referenceLine2Position - (yAxisOffset ?? 0)) *
290
- containerHeight) /
291
- maxValue,
292
- left:
293
- yAxisSide === yAxisSides.RIGHT
294
- ? 0
295
- : yAxisLabelWidth + yAxisThickness,
296
- }}>
297
- <Rule config={referenceLine2Config} />
298
- {referenceLine2Config.labelText ? (
299
- <Text
300
- style={[
301
- {position: 'absolute'},
302
- referenceLine2Config.labelTextStyle,
303
- ]}>
304
- {referenceLine2Config.labelText}
305
- </Text>
306
- ) : null}
307
- </View>
308
- ) : null}
309
- {showReferenceLine3 ? (
310
- <View
311
- style={{
312
- position: 'absolute',
313
- zIndex: referenceLine3Config.zIndex,
314
- bottom:
315
- ((referenceLine3Position - (yAxisOffset ?? 0)) *
316
- containerHeight) /
317
- maxValue,
318
- left:
319
- yAxisSide === yAxisSides.RIGHT
320
- ? 0
321
- : yAxisLabelWidth + yAxisThickness,
322
- }}>
323
- <Rule config={referenceLine3Config} />
324
- {referenceLine3Config.labelText ? (
325
- <Text
326
- style={[
327
- {position: 'absolute'},
328
- referenceLine3Config.labelTextStyle,
329
- ]}>
330
- {referenceLine3Config.labelText}
331
- </Text>
332
- ) : null}
333
- </View>
334
- ) : null}
335
- </>
336
- );
337
- };
338
-
339
- const leftShiftForRIghtYaxis =
340
- (width ? width + 20 : totalWidth) +
341
- yAxisLabelWidth / 2 +
342
- endSpacing -
343
- (chartType === chartTypes.BAR ? 40 : 60);
344
-
345
- return (
346
- <>
347
- {onlyReferenceLines ? (
348
- <View
349
- style={{
350
- flexDirection: 'row',
351
- backgroundColor: 'green',
352
- }}>
353
- <View style={{width: (width ?? totalWidth) + endSpacing}}>
354
- {referenceLines()}
355
- </View>
356
- </View>
357
- ) : (
358
- <View
359
- pointerEvents="none"
360
- style={{
361
- flexDirection: 'row',
362
- marginTop: stepHeight / -2,
363
- }}>
364
- <View style={{width: (width ?? totalWidth) + endSpacing}}>
365
- {yAxisExtraHeightAtTop ? renderExtraHeightOfYAxisAtTop() : null}
366
- {horizSections.map((sectionItems, index) => {
367
- return (
368
- <View
369
- key={index}
370
- style={[
371
- styles.horizBar,
372
- {
373
- width: (width ?? totalWidth) + endSpacing,
374
- },
375
- horizontal &&
376
- !yAxisAtTop && {
377
- transform: [{rotateY: '180deg'}],
378
- },
379
- horizontalRulesStyle,
380
- ]}>
381
- <View
382
- style={[
383
- styles.leftLabel,
384
- {
385
- height:
386
- index === noOfSections ? stepHeight / 2 : stepHeight,
387
- width:
388
- yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
389
- },
390
- yAxisLabelContainerStyle,
391
- ]}
392
- />
393
- {renderAxesAndRules(index)}
394
- </View>
395
- );
396
- })}
397
-
398
- {
399
- /***********************************************************************************************/
400
- /************************** Render the y axis labels separately **********************/
401
- /***********************************************************************************************/
402
-
403
- !hideYAxisText &&
404
- horizSections.map((sectionItems, index) => {
405
- let label = getLabelTexts(sectionItems.value, index);
406
- if (hideOrigin && index === horizSections.length - 1) {
407
- label = '';
408
- }
409
- return (
410
- <View
411
- key={index}
412
- style={[
413
- styles.horizBar,
414
- styles.leftLabel,
415
- {
416
- position: 'absolute',
417
- zIndex: 1,
418
- top: stepHeight * index + yAxisExtraHeightAtTop,
419
- width: yAxisLabelWidth,
420
- height:
421
- index === noOfSections
422
- ? stepHeight / 2
423
- : stepHeight,
424
- },
425
- yAxisSide === yAxisSides.RIGHT && {
426
- left: leftShiftForRIghtYaxis,
427
- },
428
- horizontal &&
429
- !yAxisAtTop && {
430
- transform: [
431
- {
432
- translateX:
433
- (width ?? totalWidth) - 30 + endSpacing,
434
- },
435
- ],
436
- },
437
- yAxisLabelContainerStyle,
438
- ]}>
439
- <Text
440
- numberOfLines={yAxisTextNumberOfLines}
441
- ellipsizeMode={'clip'}
442
- style={[
443
- yAxisTextStyle,
444
- horizontal && {
445
- transform: [
446
- {
447
- rotate: `${
448
- rotateYAxisTexts ?? (rtl ? 90 : -90)
449
- }deg`,
450
- },
451
- ],
452
- },
453
- index === noOfSections && {
454
- marginBottom: stepHeight / -2,
455
- },
456
- ]}>
457
- {label}
458
- </Text>
459
- </View>
460
- );
461
- })
462
- /***********************************************************************************************/
463
- /***********************************************************************************************/
464
- }
465
-
466
- {horizSectionsBelow.map((sectionItems, index) => {
467
- return (
468
- <View
469
- key={index}
470
- style={[
471
- styles.horizBar,
472
- {
473
- width: (width ?? totalWidth) + 15,
474
- },
475
- index === 0 && {marginTop: negativeStepHeight / 2},
476
- ]}>
477
- <View
478
- style={[
479
- styles.leftLabel,
480
- {
481
- borderRightWidth: yAxisThickness,
482
- borderColor: yAxisColor,
483
- marginLeft: yAxisThickness,
484
- },
485
- {
486
- height:
487
- index === 0
488
- ? negativeStepHeight * 1.5
489
- : negativeStepHeight,
490
- width:
491
- yAxisSide === yAxisSides.RIGHT ? 0 : yAxisLabelWidth,
492
- },
493
- index === 0 && {marginTop: -negativeStepHeight / 2},
494
- ]}
495
- />
496
- <View
497
- style={[
498
- styles.leftPart,
499
- {backgroundColor: backgroundColor},
500
- ]}>
501
- {hideRules ? null : (
502
- <Rule
503
- config={{
504
- thickness: rulesThickness,
505
- color: rulesColor,
506
- width:
507
- rulesLength ||
508
- (props.width || totalWidth - spacing) + endSpacing,
509
- dashWidth: dashWidth,
510
- dashGap: dashGap,
511
- type: rulesType,
512
- }}
513
- />
514
- )}
515
- </View>
516
- </View>
517
- );
518
- })}
519
-
520
- {
521
- /***********************************************************************************************/
522
- /************************* Render the y axis labels below origin *********************/
523
- /***********************************************************************************************/
524
-
525
- !hideYAxisText &&
526
- horizSectionsBelow.map((sectionItems, index) => {
527
- let label = getLabelTexts(
528
- horizSectionsBelow[horizSectionsBelow.length - 1 - index]
529
- .value,
530
- index,
531
- );
532
- return (
533
- <View
534
- key={index}
535
- style={[
536
- styles.horizBar,
537
- styles.leftLabel,
538
- {
539
- position: 'absolute',
540
- zIndex: 1,
541
- bottom: negativeStepHeight * index,
542
- width: yAxisLabelWidth,
543
- height:
544
- index === noOfSectionsBelowXAxis
545
- ? negativeStepHeight / 2
546
- : negativeStepHeight,
547
- },
548
- yAxisSide === yAxisSides.RIGHT && {
549
- left: (width ?? totalWidth) + yAxisLabelWidth,
550
- },
551
- yAxisLabelContainerStyle,
552
- ]}>
553
- <Text
554
- numberOfLines={yAxisTextNumberOfLines}
555
- ellipsizeMode={'clip'}
556
- style={[
557
- yAxisTextStyle,
558
- index === noOfSectionsBelowXAxis && {
559
- marginBottom: negativeStepHeight / -2,
560
- },
561
- ]}>
562
- {label}
563
- </Text>
564
- </View>
565
- );
566
- })
567
- /***********************************************************************************************/
568
- /***********************************************************************************************/
569
- }
570
-
571
- {/***********************************************************************************************/
572
- /************************* Render the reference lines separately *********************/
573
- /***********************************************************************************************/}
574
-
575
- {renderReferenceLines ? referenceLines() : null}
576
- </View>
577
- {
578
- /***********************************************************************************************/
579
- /************************* Render the secondary Y Axis *********************/
580
- /***********************************************************************************************/
581
- secondaryYAxis ? (
582
- <View
583
- style={{
584
- width: secondaryYAxisConfig.yAxisLabelWidth,
585
- left: width ? yAxisLabelWidth : yAxisLabelWidth - spacing,
586
- borderColor: secondaryYAxisConfig.yAxisColor,
587
- borderLeftWidth: secondaryYAxisConfig.yAxisThickness,
588
- height: containerHeight + yAxisExtraHeightAtTop,
589
- bottom: stepHeight / -2,
590
- }}>
591
- {!secondaryYAxisConfig.hideYAxisText
592
- ? renderSecondaryYaxisLabels(secondaryHorizSections, false)
593
- : null}
594
- {noOfSectionsBelowXAxis && !secondaryYAxisConfig.hideYAxisText
595
- ? renderSecondaryYaxisLabels(
596
- secondaryHorizSectionsBelow,
597
- true,
598
- )
599
- : null}
600
- </View>
601
- ) : null
602
- }
603
- </View>
604
- )}
605
- </>
606
- );
607
- };