react-native-gifted-charts 1.4.11 → 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 +1 -1
  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 -740
  53. package/src/LineChart/index.tsx +0 -2156
  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,383 +0,0 @@
1
- import React, {useEffect} from 'react';
2
- import {
3
- View,
4
- TouchableOpacity,
5
- Text,
6
- LayoutAnimation,
7
- Platform,
8
- UIManager,
9
- } from 'react-native';
10
- import Svg, {Defs, Rect} from 'react-native-svg';
11
- import LinearGradient from "../Components/common/LinearGradient";
12
- import {
13
- useRenderStackBars,
14
- BarDefaults,
15
- StackedBarChartPropsType,
16
- } from 'gifted-charts-core';
17
-
18
- if (Platform.OS === 'android') {
19
- UIManager.setLayoutAnimationEnabledExperimental &&
20
- UIManager.setLayoutAnimationEnabledExperimental(true);
21
- }
22
-
23
- const RenderStackBars = (props: StackedBarChartPropsType) => {
24
- const {
25
- barBackgroundPattern,
26
- patternId,
27
- item,
28
- index,
29
- containerHeight,
30
- spacing,
31
- rotateLabel,
32
- label,
33
- labelTextStyle,
34
- xAxisTextNumberOfLines,
35
- xAxisLabelsVerticalShift,
36
- renderTooltip,
37
- leftShiftForTooltip,
38
- leftShiftForLastIndexTooltip,
39
- selectedIndex,
40
- setSelectedIndex,
41
- activeOpacity,
42
- stackData,
43
- animationDuration = BarDefaults.animationDuration,
44
- barBorderWidth,
45
- barBorderColor,
46
- stackBorderRadius,
47
- stackBorderTopLeftRadius,
48
- stackBorderTopRightRadius,
49
- stackBorderBottomLeftRadius,
50
- stackBorderBottomRightRadius,
51
- showValuesAsTopLabel,
52
- } = props;
53
- const {
54
- cotainsNegative,
55
- noAnimation,
56
- localBarInnerComponent,
57
- borderRadius,
58
- borderTopLeftRadius,
59
- borderTopRightRadius,
60
- borderBottomLeftRadius,
61
- borderBottomRightRadius,
62
- leftSpacing,
63
- disablePress,
64
- totalHeight,
65
- height,
66
- setHeight,
67
- getBarHeight,
68
- getPosition,
69
- lowestBarPosition,
70
- getStackBorderRadii,
71
- } = useRenderStackBars(props);
72
-
73
- const renderLabel = (label: String, labelTextStyle: any) => {
74
- return (
75
- <View
76
- style={[
77
- {
78
- width:
79
- (item.stacks[0].barWidth || props.barWidth || 30) + spacing / 2,
80
- position: 'absolute',
81
- bottom: rotateLabel
82
- ? -40
83
- : -6 - xAxisTextNumberOfLines * 18 + lowestBarPosition,
84
- },
85
- rotateLabel
86
- ? props.horizontal
87
- ? {transform: [{rotate: '330deg'}]}
88
- : {transform: [{rotate: '60deg'}]}
89
- : props.horizontal
90
- ? {transform: [{rotate: '-90deg'}]}
91
- : {},
92
- ]}>
93
- {item.labelComponent ? (
94
- item.labelComponent()
95
- ) : (
96
- <Text style={[labelTextStyle]} numberOfLines={xAxisTextNumberOfLines}>
97
- {label || ''}
98
- </Text>
99
- )}
100
- </View>
101
- );
102
- };
103
-
104
- useEffect(() => {
105
- if (!noAnimation) {
106
- layoutAppear();
107
- }
108
- }, [totalHeight]);
109
-
110
- const elevate = () => {
111
- LayoutAnimation.configureNext({
112
- duration: animationDuration,
113
- update: {type: 'linear', property: 'scaleXY'},
114
- });
115
- setHeight(totalHeight);
116
- };
117
-
118
- const layoutAppear = () => {
119
- LayoutAnimation.configureNext({
120
- duration: Platform.OS == 'ios' ? animationDuration : 20,
121
- create: {type: 'linear', property: 'opacity'},
122
- update: {type: 'linear', property: 'scaleXY'},
123
- });
124
- setTimeout(() => elevate(), Platform.OS == 'ios' ? 10 : 100);
125
- };
126
-
127
- const static2DSimple = () => {
128
- return (
129
- <>
130
- <TouchableOpacity
131
- disabled={disablePress}
132
- activeOpacity={activeOpacity}
133
- onPress={() => {
134
- setSelectedIndex(index);
135
- if (item.onPress) {
136
- item.onPress();
137
- } else if (props.onPress) {
138
- props.onPress(item, index);
139
- }
140
- }}
141
- onLongPress={() => {
142
- if (item.onLongPress) {
143
- item.onLongPress();
144
- } else if (props.onLongPress) {
145
- props.onLongPress(item, index);
146
- }
147
- }}
148
- onPressOut={() => {
149
- if (item.onPressOut) {
150
- item.onPressOut();
151
- } else if (props.onPressOut) {
152
- props.onPressOut(item, index);
153
- }
154
- }}
155
- style={[
156
- {
157
- position: 'absolute',
158
- width: item.stacks[0].barWidth || props.barWidth || 30,
159
- height: '100%',
160
- borderTopLeftRadius:
161
- borderTopLeftRadius ??
162
- borderRadius ??
163
- stackBorderTopLeftRadius ??
164
- stackBorderRadius,
165
- borderTopRightRadius:
166
- borderTopRightRadius ??
167
- borderRadius ??
168
- stackBorderTopRightRadius ??
169
- stackBorderRadius,
170
- borderBottomLeftRadius:
171
- borderBottomLeftRadius ??
172
- borderRadius ??
173
- stackBorderBottomLeftRadius ??
174
- stackBorderRadius,
175
- borderBottomRightRadius:
176
- borderBottomRightRadius ??
177
- borderRadius ??
178
- stackBorderBottomRightRadius ??
179
- stackBorderRadius,
180
- overflow: lowestBarPosition ? 'visible' : 'hidden',
181
- },
182
- ]}>
183
- {item.stacks.map((stackItem, index) => {
184
- const borderRadii = getStackBorderRadii(item, index);
185
- const barHeight = getBarHeight(
186
- stackItem.value,
187
- stackItem.marginBottom,
188
- );
189
-
190
- return (
191
- <TouchableOpacity
192
- key={index}
193
- onPress={stackItem.onPress}
194
- activeOpacity={activeOpacity}
195
- disabled={disablePress || !stackItem.onPress}
196
- style={{
197
- position: 'absolute',
198
- bottom: getPosition(index) + (stackItem.marginBottom || 0),
199
- width: '100%',
200
- height: barHeight,
201
- backgroundColor:
202
- stackItem.color || item.color || props.color || 'black',
203
- borderWidth: barBorderWidth ?? 0,
204
- borderColor: barBorderColor,
205
- ...borderRadii,
206
- }}>
207
- {stackItem.showGradient ||
208
- item.showGradient ||
209
- props.showGradient ? (
210
- <LinearGradient
211
- style={{
212
- position: 'absolute',
213
- width: '100%',
214
- height: '100%',
215
- ...borderRadii,
216
- }}
217
- start={{x: 0, y: 0}}
218
- end={{x: 0, y: 1}}
219
- colors={[
220
- stackItem.gradientColor ||
221
- item.gradientColor ||
222
- props.gradientColor ||
223
- 'white',
224
- stackItem.color || item.color || props.color || 'black',
225
- ]}
226
- />
227
- ) : null}
228
- {stackItem.innerBarComponent && stackItem.innerBarComponent()}
229
- </TouchableOpacity>
230
- );
231
- })}
232
- {(item.barBackgroundPattern || barBackgroundPattern) && (
233
- <Svg>
234
- <Defs>
235
- {item.barBackgroundPattern
236
- ? item.barBackgroundPattern()
237
- : barBackgroundPattern?.()}
238
- </Defs>
239
- <Rect
240
- stroke="transparent"
241
- x="1"
242
- y="1"
243
- width="100%"
244
- height="100%"
245
- fill={`url(#${item.patternId || patternId})`}
246
- />
247
- </Svg>
248
- )}
249
- </TouchableOpacity>
250
- {localBarInnerComponent ? (
251
- <View style={{height: '100%', width: '100%'}}>
252
- {localBarInnerComponent(item, index)}
253
- </View>
254
- ) : null}
255
- {(item.topLabelComponent || showValuesAsTopLabel) && (
256
- <View
257
- style={[
258
- {
259
- position: 'absolute',
260
- top: cotainsNegative
261
- ? 0
262
- : (item.barWidth || props.barWidth || 30) * -1,
263
- height: item.barWidth || props.barWidth || 30,
264
- width: item.barWidth || props.barWidth || 30,
265
- justifyContent: 'center',
266
- alignItems: 'center',
267
- },
268
- cotainsNegative && {transform: [{translateY: totalHeight * 2}]},
269
- props.horizontal &&
270
- !props.intactTopLabel && {transform: [{rotate: '270deg'}]},
271
- item.topLabelContainerStyle,
272
- ]}>
273
- {showValuesAsTopLabel ? (
274
- <Text style={item.topLabelTextStyle}>
275
- {item.stacks.reduce((acc, stack) => acc + stack.value, 0)}
276
- </Text>
277
- ) : (
278
- item.topLabelComponent?.()
279
- )}
280
- </View>
281
- )}
282
- </>
283
- );
284
- };
285
-
286
- const barWrapper = () => {
287
- return noAnimation ? (
288
- static2DSimple()
289
- ) : (
290
- <View
291
- style={{
292
- position: 'absolute',
293
- bottom: 0,
294
- height: height,
295
- width: '100%',
296
- overflow: 'hidden',
297
- }}>
298
- {static2DSimple()}
299
- </View>
300
- );
301
- };
302
-
303
- return (
304
- <>
305
- <View
306
- pointerEvents={
307
- props.pointerConfig
308
- ? props.pointerConfig.pointerEvents ?? 'none'
309
- : 'auto'
310
- }
311
- style={[
312
- {
313
- // overflow: 'visible',
314
- marginBottom: 60 + xAxisLabelsVerticalShift,
315
- width: item.stacks[0].barWidth || props.barWidth || 30,
316
- height: totalHeight,
317
- marginRight: spacing,
318
- },
319
-
320
- props.pointerConfig
321
- ? {
322
- transform: [
323
- {
324
- translateY:
325
- (containerHeight || 200) -
326
- (totalHeight - 10 + xAxisLabelsVerticalShift),
327
- },
328
- ],
329
- }
330
- : null,
331
- ]}>
332
- {/* {props.showVerticalLines && (
333
- <View
334
- style={{
335
- zIndex: props.verticalLinesZIndex,
336
- position: 'absolute',
337
- height: (containerHeight || 200) + 15,
338
- width: props.verticalLinesThickness,
339
- bottom: 0,
340
- left: (item.barWidth || props.barWidth || 30) / 2,
341
- backgroundColor: props.verticalLinesColor,
342
- }}
343
- />
344
- )} */}
345
- {(props.showXAxisIndices || item.showXAxisIndex) && (
346
- <View
347
- style={{
348
- zIndex: 2,
349
- position: 'absolute',
350
- height: props.xAxisIndicesHeight,
351
- width: props.xAxisIndicesWidth,
352
- bottom: props.xAxisIndicesHeight / -2,
353
- left:
354
- ((item.barWidth || props.barWidth || 30) -
355
- props.xAxisIndicesWidth) /
356
- 2,
357
- backgroundColor: props.xAxisIndicesColor,
358
- }}
359
- />
360
- )}
361
- {barWrapper()}
362
- {renderLabel(label || '', labelTextStyle)}
363
- </View>
364
- {renderTooltip && selectedIndex === index && (
365
- <View
366
- style={{
367
- position: 'absolute',
368
- bottom: totalHeight + 60,
369
- left:
370
- index === stackData.length - 1
371
- ? leftSpacing - leftShiftForLastIndexTooltip
372
- : leftSpacing -
373
- (item.leftShiftForTooltip ?? leftShiftForTooltip ?? 0),
374
- zIndex: 1000,
375
- }}>
376
- {renderTooltip(item, index)}
377
- </View>
378
- )}
379
- </>
380
- );
381
- };
382
-
383
- export default RenderStackBars;