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