react-native-gifted-charts 1.4.10 → 1.4.12

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 (61) hide show
  1. package/README.md +2 -2
  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/common/LinearGradient.js +1 -0
  19. package/dist/Components/common/Pointer.js +1 -0
  20. package/dist/Components/common/StripAndLabel.js +1 -0
  21. package/dist/Components/lineSvg.js +1 -0
  22. package/dist/LineChart/LineChartBicolor.js +1 -0
  23. package/dist/LineChart/index.js +1 -0
  24. package/dist/LineChart/styles.js +1 -0
  25. package/dist/PieChart/index.js +1 -0
  26. package/dist/PieChart/main.js +1 -0
  27. package/dist/PieChartPro/index.js +1 -0
  28. package/dist/PopulationPyramid/index.js +1 -0
  29. package/dist/index.js +1 -0
  30. package/dist/utils/index.js +1 -0
  31. package/package.json +10 -5
  32. package/src/BarChart/Animated2DWithGradient.tsx +0 -197
  33. package/src/BarChart/RenderBars.tsx +0 -454
  34. package/src/BarChart/RenderStackBars.tsx +0 -383
  35. package/src/BarChart/index.tsx +0 -373
  36. package/src/BarChart/styles.tsx +0 -47
  37. package/src/Components/AnimatedThreeDBar/index.tsx +0 -258
  38. package/src/Components/AnimatedThreeDBar/styles.tsx +0 -14
  39. package/src/Components/BarAndLineChartsWrapper/index.tsx +0 -244
  40. package/src/Components/BarAndLineChartsWrapper/renderHorizSections.tsx +0 -590
  41. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.tsx +0 -147
  42. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.tsx +0 -157
  43. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.tsx +0 -86
  44. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.tsx +0 -42
  45. package/src/Components/BarAndLineChartsWrapper/renderVerticalLines.tsx +0 -131
  46. package/src/Components/BarSpecificComponents/barBackgroundPattern.tsx +0 -30
  47. package/src/Components/BarSpecificComponents/cap.tsx +0 -34
  48. package/src/Components/common/LinearGradient.tsx +0 -27
  49. package/src/Components/common/Pointer.tsx +0 -37
  50. package/src/Components/common/StripAndLabel.tsx +0 -98
  51. package/src/Components/lineSvg.tsx +0 -42
  52. package/src/LineChart/LineChartBicolor.tsx +0 -739
  53. package/src/LineChart/index.tsx +0 -2077
  54. package/src/LineChart/styles.tsx +0 -47
  55. package/src/PieChart/index.tsx +0 -165
  56. package/src/PieChart/main.tsx +0 -363
  57. package/src/PieChartPro/index.tsx +0 -267
  58. package/src/PopulationPyramid/index.tsx +0 -603
  59. package/src/index.tsx +0 -25
  60. package/src/todos.md +0 -23
  61. package/src/utils/index.ts +0 -16
@@ -1,454 +0,0 @@
1
- import React from 'react';
2
- import {View, TouchableOpacity, Animated, Text} from 'react-native';
3
- import AnimatedThreeDBar from '../Components/AnimatedThreeDBar';
4
- import Animated2DWithGradient from './Animated2DWithGradient';
5
- import Cap from '../Components/BarSpecificComponents/cap';
6
- import BarBackgroundPattern from '../Components/BarSpecificComponents/barBackgroundPattern';
7
- import LinearGradient from "../Components/common/LinearGradient";
8
- import {
9
- getPropsForAnimated2DWithGradient,
10
- RenderBarsPropsType,
11
- barDataItem,
12
- AxesAndRulesDefaults,
13
- } from 'gifted-charts-core';
14
-
15
- const RenderBars = (props: RenderBarsPropsType) => {
16
- const {
17
- item,
18
- index,
19
- containerHeight,
20
- maxValue,
21
- minHeight,
22
- spacing,
23
- propSpacing,
24
- side,
25
- data,
26
- barBorderWidth,
27
- barBorderColor,
28
- isThreeD,
29
- isAnimated,
30
- rotateLabel,
31
- appearingOpacity,
32
- animationDuration,
33
- autoShiftLabels,
34
- label,
35
- labelTextStyle,
36
- xAxisTextNumberOfLines,
37
- xAxisLabelsVerticalShift,
38
- renderTooltip,
39
- leftShiftForTooltip,
40
- leftShiftForLastIndexTooltip,
41
- initialSpacing,
42
- selectedIndex,
43
- setSelectedIndex,
44
- xAxisThickness = AxesAndRulesDefaults.xAxisThickness,
45
- horizontal,
46
- rtl,
47
- intactTopLabel,
48
- showValuesAsTopLabel,
49
- topLabelContainerStyle,
50
- topLabelTextStyle,
51
- pointerConfig,
52
- noOfSectionsBelowXAxis,
53
- yAxisOffset,
54
- } = props;
55
-
56
- const barHeight = Math.max(
57
- minHeight,
58
- (Math.abs(item.value) * (containerHeight || 200)) / (maxValue || 200) -
59
- xAxisThickness,
60
- );
61
-
62
- const {
63
- commonStyleForBar,
64
- barStyleWithBackground,
65
- commonPropsFor2Dand3Dbars,
66
- isFocused,
67
- focusedBarConfig,
68
- localFrontColor,
69
- } = getPropsForAnimated2DWithGradient({...props, barHeight});
70
-
71
- const itemOrPropsBarInnerComponent =
72
- item.barInnerComponent ?? props.barInnerComponent;
73
- const localBarInnerComponent = isFocused
74
- ? focusedBarConfig?.barInnerComponent ?? itemOrPropsBarInnerComponent
75
- : itemOrPropsBarInnerComponent;
76
-
77
- const barMarginBottom =
78
- item.barMarginBottom === 0
79
- ? 0
80
- : item.barMarginBottom || props.barMarginBottom || 0;
81
-
82
- const renderLabel = (label: String, labelTextStyle: any, value: number) => {
83
- return (
84
- <View
85
- style={[
86
- {
87
- width:
88
- (item.labelWidth ||
89
- props.labelWidth ||
90
- item.barWidth ||
91
- props.barWidth ||
92
- 30) + spacing,
93
- left: spacing / -2,
94
- position: 'absolute',
95
- height: props.xAxisLabelsHeight ?? xAxisTextNumberOfLines * 18,
96
- bottom:
97
- (rotateLabel
98
- ? -40
99
- : -6 - xAxisTextNumberOfLines * 18 - xAxisLabelsVerticalShift) -
100
- barMarginBottom,
101
- },
102
- rotateLabel
103
- ? horizontal
104
- ? {transform: [{rotate: '330deg'}]}
105
- : {
106
- transform: [
107
- {rotate: value < 0 ? '240deg' : '60deg'},
108
- {translateX: value < 0 ? 56 : 0},
109
- {translateY: value < 0 ? 32 : 0},
110
- ],
111
- }
112
- : horizontal
113
- ? {transform: [{rotate: '-90deg'}]}
114
- : value < 0
115
- ? {
116
- transform: [
117
- {rotate: '180deg'},
118
- {
119
- translateY: autoShiftLabels
120
- ? 0
121
- : 16.5 * xAxisTextNumberOfLines + 14,
122
- },
123
- ],
124
- }
125
- : {},
126
- ]}>
127
- {item.labelComponent ? (
128
- item.labelComponent()
129
- ) : (
130
- <Text
131
- style={[
132
- {textAlign: 'center'},
133
- rtl && horizontal && {transform: [{rotate: '180deg'}]},
134
- labelTextStyle,
135
- ]}
136
- numberOfLines={xAxisTextNumberOfLines}>
137
- {label || ''}
138
- </Text>
139
- )}
140
- </View>
141
- );
142
- };
143
-
144
- const renderAnimatedLabel = (
145
- label: String,
146
- labelTextStyle: any,
147
- value: number,
148
- ) => {
149
- return (
150
- <Animated.View
151
- style={[
152
- {
153
- width:
154
- (item.labelWidth ||
155
- props.labelWidth ||
156
- item.barWidth ||
157
- props.barWidth ||
158
- 30) + spacing,
159
- left: spacing / -2,
160
- position: 'absolute',
161
- height: props.xAxisLabelsHeight ?? xAxisTextNumberOfLines * 18,
162
- bottom:
163
- (rotateLabel
164
- ? -40
165
- : -6 - xAxisTextNumberOfLines * 18 - xAxisLabelsVerticalShift) -
166
- barMarginBottom,
167
- opacity: appearingOpacity,
168
- },
169
- value < 0 && {transform: [{rotate: '180deg'}]},
170
- rotateLabel
171
- ? horizontal
172
- ? {transform: [{rotate: '330deg'}]}
173
- : {transform: [{rotate: '60deg'}]}
174
- : horizontal
175
- ? {transform: [{rotate: '-90deg'}]}
176
- : value < 0
177
- ? {
178
- transform: [
179
- {rotate: '180deg'},
180
- {
181
- translateY: autoShiftLabels
182
- ? 0
183
- : 16.5 * xAxisTextNumberOfLines + 14,
184
- },
185
- ],
186
- }
187
- : {},
188
- ]}>
189
- {item.labelComponent ? (
190
- item.labelComponent()
191
- ) : (
192
- <Text
193
- style={[
194
- {textAlign: 'center'},
195
- rtl && horizontal && {transform: [{rotate: '180deg'}]},
196
- labelTextStyle,
197
- ]}
198
- numberOfLines={xAxisTextNumberOfLines}>
199
- {label || ''}
200
- </Text>
201
- )}
202
- </Animated.View>
203
- );
204
- };
205
-
206
- let leftSpacing = initialSpacing;
207
- for (let i = 0; i < index; i++) {
208
- leftSpacing +=
209
- (data[i].spacing ?? propSpacing) +
210
- (data[i].barWidth || props.barWidth || 30);
211
- }
212
-
213
- const static2DWithGradient = (item: barDataItem) => {
214
- const localGradientColor =
215
- item.gradientColor || props.gradientColor || 'white';
216
- return (
217
- <>
218
- <LinearGradient
219
- style={commonStyleForBar}
220
- start={{x: 0, y: 0}}
221
- end={{x: 0, y: 1}}
222
- colors={[
223
- isFocused
224
- ? focusedBarConfig?.gradientColor ?? localGradientColor
225
- : localGradientColor,
226
- localFrontColor,
227
- ]}>
228
- {props.cappedBars && item.value ? (
229
- <Cap
230
- capThicknessFromItem={item.capThickness}
231
- capThicknessFromProps={props.capThickness}
232
- capColorFromItem={item.capColor}
233
- capColorFromProps={props.capColor}
234
- capRadiusFromItem={item.capRadius}
235
- capRadiusFromProps={props.capRadius}
236
- />
237
- ) : null}
238
- </LinearGradient>
239
- {(item.barBackgroundPattern || props.barBackgroundPattern) && (
240
- <BarBackgroundPattern
241
- barBackgroundPatternFromItem={item.barBackgroundPattern}
242
- barBackgroundPatternFromProps={props.barBackgroundPattern}
243
- patternIdFromItem={item.patternId}
244
- patternIdFromProps={props.patternId}
245
- />
246
- )}
247
- {(item.topLabelComponent || showValuesAsTopLabel) && (
248
- <View
249
- style={[
250
- {
251
- position: 'absolute',
252
- top: (item.barWidth || props.barWidth || 30) * -1,
253
- height: item.barWidth || props.barWidth || 30,
254
- width: item.barWidth || props.barWidth || 30,
255
- justifyContent:
256
- (horizontal && !intactTopLabel) || item.value < 0
257
- ? 'center'
258
- : 'flex-end',
259
- alignItems: 'center',
260
- },
261
- item.value < 0 && {transform: [{rotate: '180deg'}]},
262
- horizontal &&
263
- !intactTopLabel && {transform: [{rotate: '270deg'}]},
264
- topLabelContainerStyle ?? item.topLabelContainerStyle,
265
- ]}>
266
- {showValuesAsTopLabel ? (
267
- <Text style={topLabelTextStyle}>{item.value + yAxisOffset}</Text>
268
- ) : (
269
- item.topLabelComponent?.()
270
- )}
271
- </View>
272
- )}
273
- {localBarInnerComponent ? (
274
- <View style={{height: '100%', width: '100%'}}>
275
- {localBarInnerComponent(item, index)}
276
- </View>
277
- ) : null}
278
- </>
279
- );
280
- };
281
-
282
- const barWrapperStyle = [
283
- {
284
- // overflow: 'visible',
285
- marginBottom: 60 + barMarginBottom + xAxisLabelsVerticalShift - 0.5,
286
- width: commonPropsFor2Dand3Dbars.barWidth,
287
- height: barHeight,
288
- marginRight: spacing,
289
- },
290
- item.value < 0
291
- ? {
292
- transform: [
293
- {
294
- translateY:
295
- (Math.abs(item.value) * (containerHeight || 200)) /
296
- (maxValue || 200),
297
- },
298
- {rotateZ: '180deg'},
299
- ],
300
- }
301
- : pointerConfig
302
- ? {
303
- transform: [
304
- {
305
- translateY:
306
- (containerHeight || 200) -
307
- (barHeight - 10 + xAxisLabelsVerticalShift),
308
- },
309
- ],
310
- }
311
- : null,
312
- side !== 'right' && {zIndex: data.length - index},
313
- ];
314
-
315
- const pressDisabled =
316
- item.disablePress ||
317
- props.disablePress ||
318
- (pointerConfig && pointerConfig.barTouchable !== true);
319
-
320
- const barContent = () => {
321
- const isBarBelowXaxisAndInvisible =
322
- item.value < 0 && !noOfSectionsBelowXAxis;
323
- const animated2DWithGradient = (noGradient, noAnimation) => (
324
- <Animated2DWithGradient
325
- {...commonPropsFor2Dand3Dbars}
326
- animationDuration={animationDuration || 800}
327
- roundedBottom={props.roundedBottom || false}
328
- roundedTop={props.roundedTop || false}
329
- noGradient={noGradient}
330
- noAnimation={noAnimation}
331
- containerHeight={containerHeight}
332
- maxValue={maxValue}
333
- minHeight={minHeight ?? 0}
334
- barMarginBottom={barMarginBottom}
335
- cappedBars={props.cappedBars}
336
- capThickness={props.capThickness}
337
- capColor={props.capColor}
338
- capRadius={props.capRadius}
339
- horizontal={horizontal}
340
- barBorderWidth={barBorderWidth}
341
- barBorderColor={barBorderColor}
342
- commonStyleForBar={commonStyleForBar}
343
- barStyleWithBackground={barStyleWithBackground}
344
- />
345
- );
346
- return (
347
- <>
348
- {(props.showXAxisIndices || item.showXAxisIndex) && (
349
- <View
350
- style={{
351
- zIndex: 2,
352
- position: 'absolute',
353
- height: props.xAxisIndicesHeight,
354
- width: props.xAxisIndicesWidth,
355
- bottom: props.xAxisIndicesHeight / -2,
356
- left:
357
- ((item.barWidth || props.barWidth || 30) -
358
- props.xAxisIndicesWidth) /
359
- 2,
360
- backgroundColor: props.xAxisIndicesColor,
361
- }}
362
- />
363
- )}
364
- {isBarBelowXaxisAndInvisible ? null : isThreeD ? (
365
- <AnimatedThreeDBar
366
- {...commonPropsFor2Dand3Dbars}
367
- sideWidth={
368
- item.sideWidth ||
369
- props.sideWidth ||
370
- (item.barWidth || props.barWidth || 30) / 2
371
- }
372
- side={side || 'left'}
373
- sideColor={item.sideColor || props.sideColor || ''}
374
- topColor={item.topColor || props.topColor || ''}
375
- horizontal={horizontal}
376
- isAnimated={isAnimated}
377
- animationDuration={animationDuration || 800}
378
- selectedIndex={selectedIndex}
379
- />
380
- ) : item.showGradient || props.showGradient ? (
381
- isAnimated ? (
382
- animated2DWithGradient(false, false)
383
- ) : (
384
- static2DWithGradient(item)
385
- )
386
- ) : isAnimated ? (
387
- animated2DWithGradient(true, false)
388
- ) : (
389
- animated2DWithGradient(true, true)
390
- )}
391
- {isAnimated
392
- ? renderAnimatedLabel(label, labelTextStyle, item.value)
393
- : renderLabel(label, labelTextStyle, item.value)}
394
- </>
395
- );
396
- };
397
-
398
- return (
399
- <>
400
- {pressDisabled ? (
401
- <View pointerEvents="none" style={barWrapperStyle}>
402
- {barContent()}
403
- </View>
404
- ) : (
405
- <TouchableOpacity
406
- activeOpacity={props.activeOpacity || 0.2}
407
- onPress={() => {
408
- if (renderTooltip || props.focusBarOnPress) {
409
- setSelectedIndex(index);
410
- }
411
- item.onPress
412
- ? item.onPress()
413
- : props.onPress
414
- ? props.onPress(item, index)
415
- : null;
416
- }}
417
- onLongPress={() => {
418
- item.onLongPress
419
- ? item.onLongPress()
420
- : props.onLongPress
421
- ? props.onLongPress(item, index)
422
- : null;
423
- }}
424
- onPressOut={() => {
425
- item.onPressOut
426
- ? item.onPressOut()
427
- : props.onPressOut
428
- ? props.onPressOut(item, index)
429
- : null;
430
- }}
431
- style={barWrapperStyle}>
432
- {barContent()}
433
- </TouchableOpacity>
434
- )}
435
- {renderTooltip && selectedIndex === index && (
436
- <View
437
- style={{
438
- position: 'absolute',
439
- bottom: barHeight + 60,
440
- left:
441
- index === data.length - 1
442
- ? leftSpacing - leftShiftForLastIndexTooltip
443
- : leftSpacing -
444
- (item?.leftShiftForTooltip ?? leftShiftForTooltip ?? 0),
445
- zIndex: 1000,
446
- }}>
447
- {renderTooltip(item, index)}
448
- </View>
449
- )}
450
- </>
451
- );
452
- };
453
-
454
- export default RenderBars;