react-native-gifted-charts 1.3.33 → 1.4.0

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 (31) hide show
  1. package/README.md +9 -2
  2. package/package.json +2 -1
  3. package/src/BarChart/Animated2DWithGradient.tsx +13 -154
  4. package/src/BarChart/RenderBars.tsx +29 -179
  5. package/src/BarChart/RenderStackBars.tsx +22 -104
  6. package/src/BarChart/index.tsx +87 -686
  7. package/src/Components/AnimatedThreeDBar/index.tsx +16 -48
  8. package/src/Components/BarAndLineChartsWrapper/index.tsx +38 -283
  9. package/src/Components/BarAndLineChartsWrapper/renderHorizSections.tsx +17 -339
  10. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.tsx +147 -0
  11. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.tsx +157 -0
  12. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificDataPoints.tsx +86 -0
  13. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderSpecificVerticalLines.tsx +42 -0
  14. package/src/Components/BarAndLineChartsWrapper/renderVerticalLines.tsx +1 -1
  15. package/src/Components/BarSpecificComponents/cap.tsx +1 -1
  16. package/src/Components/common/StripAndLabel.tsx +3 -56
  17. package/src/Components/lineSvg.tsx +1 -1
  18. package/src/LineChart/LineChartBicolor.tsx +80 -516
  19. package/src/LineChart/index.tsx +266 -1778
  20. package/src/PieChart/index.tsx +20 -84
  21. package/src/PieChart/main.tsx +47 -119
  22. package/src/PopulationPyramid/index.tsx +90 -203
  23. package/src/index.tsx +2 -14
  24. package/src/BarChart/types.ts +0 -394
  25. package/src/Components/BarAndLineChartsWrapper/renderLineInBarChart.tsx +0 -402
  26. package/src/LineChart/types.ts +0 -575
  27. package/src/PieChart/types.ts +0 -77
  28. package/src/PopulationPyramid/types.ts +0 -200
  29. package/src/utils/constants.ts +0 -333
  30. package/src/utils/index.tsx +0 -1137
  31. package/src/utils/types.ts +0 -360
@@ -1,200 +0,0 @@
1
- import { ColorValue } from "react-native";
2
- import { RuleTypes } from "../utils/types";
3
- import { FontStyle, FontWeight } from "react-native-svg";
4
-
5
- export type popnPyramidDataItem = {
6
- left: number;
7
- right: number;
8
- leftBarColor?: ColorValue;
9
- rightBarColor?: ColorValue;
10
- leftBarBorderColor?: ColorValue;
11
- rightBarBorderColor?: ColorValue;
12
- barBorderWidth?: number;
13
- leftBarBorderWidth?: number;
14
- rightBarBorderWidth?: number;
15
- barBorderRadius?: number;
16
- leftBarBorderRadius?: number;
17
- rightBarBorderRadius?: number;
18
-
19
- barLabelWidth?: number;
20
- barLabelFontSize?: number;
21
- barLabelColor?: ColorValue;
22
- barLabelFontStyle?: FontStyle;
23
- barLabelFontWeight?: FontWeight;
24
- barLabelFontFamily?: string;
25
-
26
- leftBarLabel?: string;
27
- leftBarLabelWidth?: number;
28
- leftBarLabelFontSize?: number;
29
- leftBarLabelColor?: ColorValue;
30
- leftBarLabelFontStyle?: FontStyle;
31
- leftBarLabelFontWeight?: FontWeight;
32
- leftBarLabelFontFamily?: string;
33
- leftBarLabelShift?: number;
34
-
35
- rightBarLabel?: string;
36
- rightBarLabelWidth?: number;
37
- rightBarLabelFontSize?: number;
38
- rightBarLabelColor?: ColorValue;
39
- rightBarLabelFontStyle?: FontStyle;
40
- rightBarLabelFontWeight?: FontWeight;
41
- rightBarLabelFontFamily?: string;
42
- rightBarLabelShift?: number;
43
-
44
- yAxisLabel?: string;
45
- midAxisLabel?: string;
46
- midAxisLabelFontSize?: number;
47
- midAxisLabelColor?: ColorValue;
48
- midAxisLabelFontStyle?: FontStyle;
49
- midAxisLabelFontWeight?: FontWeight;
50
- midAxisLabelFontFamily?: string;
51
-
52
- showSurplus?: boolean;
53
- showSurplusLeft?: boolean;
54
- showSurplusRight?: boolean;
55
- leftSurplusColor?: ColorValue;
56
- leftSurplusBorderColor?: ColorValue;
57
- rightSurplusColor?: ColorValue;
58
- rightSurplusBorderColor?: ColorValue;
59
- leftSurplusBorderWidth?: number;
60
- rightSurplusBorderWidth?: number;
61
- }
62
-
63
- export type RulesProps = {
64
- x1?: number;
65
- y1?: number;
66
- x2?: number;
67
- y2?: number;
68
- stroke?: ColorValue;
69
- strokeWidth?: number;
70
- strokeDasharray?: Array<number>;
71
- }
72
-
73
- export type PopulationPyramidPropsType = {
74
- height?: number;
75
- width?: number;
76
- data: Array<popnPyramidDataItem>;
77
- hideRules?: boolean;
78
- stepHeight?: number;
79
- verticalMarginBetweenBars?: number;
80
- hideYAxisText?: boolean;
81
- yAxisLabelWidth?: number;
82
- yAxisColor?: ColorValue;
83
- yAxisThickness?: number;
84
- yAxisStrokeDashArray?: Array<number>;
85
- xAxisColor?: ColorValue;
86
- xAxisThickness?: number;
87
- xAxisType?: RuleTypes;
88
- xAxisNoOfSections?: number;
89
- showXAxisIndices?: boolean;
90
- xAxisIndicesWidth?: number;
91
- xAxisIndicesHeight?: number;
92
- xAxisIndicesColor?: ColorValue;
93
- xAxisIndicesShiftY?: number;
94
- showXAxisLabelTexts?: boolean;
95
- xAxisLabelFontSize?: number;
96
- xAxisLabelColor?: ColorValue;
97
- xAxisLabelFontStyle?: FontStyle;
98
- xAxisLabelFontWeight?: FontWeight;
99
- xAxisLabelFontFamily?: string;
100
- xAxisLabelShiftX?: number;
101
- xAxisLabelShiftY?: number;
102
- xAxisRoundToDigits?: number;
103
- xAxisLabelPrefix?: string;
104
- xAxisLabelSuffix?: string;
105
- formatXAxisLabels?: (label: string) => string;
106
-
107
- showVerticalLines?: boolean;
108
- verticalLinesColor?: ColorValue;
109
- verticalLinesThickness?: number;
110
- verticalLinesType?: RuleTypes;
111
- verticalLinesStrokeDashArray?: Array<number>;
112
-
113
- noOfSections?: number;
114
- barsMapToYAxisSections?: boolean;
115
-
116
- showYAxisIndices?: boolean;
117
- yAxisIndicesWidth?: number;
118
- yAxisIndicesHeight?: number;
119
- yAxisIndicesColor?: ColorValue;
120
- yAxisLabelColor?: ColorValue;
121
- yAxisLabelFontSize?: number;
122
- yAxisLabelTextMarginRight?: number;
123
- yAxisLabelTexts?: Array<string>;
124
- yAxisLabelFontStyle?: FontStyle;
125
- yAxisLabelFontWeight?: FontWeight;
126
- yAxisLabelFontFamily?: string;
127
-
128
- showValuesAsBarLabels?: boolean;
129
-
130
-
131
- rulesThickness?: number;
132
- rulesColor?: ColorValue;
133
- rulesType?: RuleTypes;
134
- dashWidth?: number;
135
- dashGap?: number;
136
-
137
- showMidAxis?: boolean;
138
- midAxisThickness?: number;
139
- midAxisLabelWidth?: number;
140
- midAxisColor?: ColorValue;
141
- midAxisLeftColor?: ColorValue;
142
- midAxisRightColor?: ColorValue;
143
- midAxisStrokeDashArray?: Array<number>;
144
- midAxisLabelFontSize?: number;
145
- midAxisLabelColor?: ColorValue;
146
- midAxisLabelFontStyle?: FontStyle;
147
- midAxisLabelFontWeight?: FontWeight;
148
- midAxisLabelFontFamily?: string;
149
-
150
- barLabelWidth?: number;
151
- barLabelFontSize?: number;
152
- barLabelColor?: ColorValue;
153
- barLabelFontStyle?: FontStyle;
154
- barLabelFontWeight?: FontWeight;
155
- barLabelFontFamily?: string;
156
-
157
- leftBarLabelWidth?: number;
158
- leftBarLabelFontSize?: number;
159
- leftBarLabelColor?: ColorValue;
160
- leftBarLabelFontStyle?: FontStyle;
161
- leftBarLabelFontWeight?: FontWeight;
162
- leftBarLabelFontFamily?: string;
163
- leftBarLabelShift?: number;
164
- leftBarLabelPrefix?: string;
165
- leftBarLabelSuffix?: string;
166
-
167
- rightBarLabelWidth?: number;
168
- rightBarLabelFontSize?: number;
169
- rightBarLabelColor?: ColorValue;
170
- rightBarLabelFontStyle?: FontStyle;
171
- rightBarLabelFontWeight?: FontWeight;
172
- rightBarLabelFontFamily?: string;
173
- rightBarLabelShift?: number;
174
- rightBarLabelPrefix?: string;
175
- rightBarLabelSuffix?: string;
176
- formatBarLabels?: (label: string) => string;
177
-
178
- leftBarColor?: ColorValue;
179
- rightBarColor?: ColorValue;
180
- leftBarBorderColor?: ColorValue;
181
- rightBarBorderColor?: ColorValue;
182
- barBorderWidth?: number;
183
- leftBarBorderWidth?: number;
184
- rightBarBorderWidth?: number;
185
- barBorderRadius?: number;
186
- leftBarBorderRadius?: number;
187
- rightBarBorderRadius?: number;
188
- allCornersRounded?: boolean;
189
-
190
- showSurplus?: boolean;
191
- showSurplusLeft?: boolean;
192
- showSurplusRight?: boolean;
193
- leftSurplusColor?: ColorValue;
194
- leftSurplusBorderColor?: ColorValue;
195
- rightSurplusColor?: ColorValue;
196
- rightSurplusBorderColor?: ColorValue;
197
- leftSurplusBorderWidth?: number;
198
- rightSurplusBorderWidth?: number;
199
-
200
- }
@@ -1,333 +0,0 @@
1
- import {defaultLineConfigType} from '../BarChart/types';
2
- import {CurveType, EdgePosition, RuleTypes} from './types';
3
- import {Dimensions} from 'react-native';
4
- import {FontStyle} from 'react-native-svg';
5
-
6
- // Global
7
-
8
- export enum chartTypes {
9
- BAR,
10
- LINE,
11
- LINE_BI_COLOR,
12
- }
13
-
14
- export const screenWidth = Dimensions.get('window').width;
15
-
16
- const defaultCurvature = 0.2;
17
- const defaultCurveType = CurveType.CUBIC;
18
- const defaultAnimationDuration = 800;
19
- const defaultScrollEventThrottle = 0;
20
-
21
- // Bar and Line chart Specific
22
-
23
- export enum yAxisSides {
24
- LEFT,
25
- RIGHT,
26
- }
27
-
28
- export enum loc {
29
- IN,
30
- UP,
31
- DOWN,
32
- }
33
-
34
- export const SEGMENT_START = 'segmentStart';
35
- export const SEGMENT_END = 'segmentEnd';
36
- export const RANGE_ENTER = 'RangeEnter';
37
- export const RANGE_EXIT = 'RangeExit';
38
- export const STOP = 'stop';
39
-
40
- export const ruleTypes: RuleTypes = {
41
- SOLID: 'solid',
42
- DASHED: 'dashed',
43
- DOTTED: 'dotted',
44
- };
45
-
46
- export const AxesAndRulesDefaults = {
47
- yAxisSide: yAxisSides.LEFT,
48
- yAxisColor: 'black',
49
- yAxisExtraHeight: 0,
50
- yAxisThickness: 1,
51
- trimYAxisAtTop: false,
52
- overflowTop: 0,
53
- xAxisColor: 'black',
54
- xAxisThickness: 1,
55
- xAxisType: ruleTypes.SOLID,
56
- xAxisTextNumberOfLines: 1,
57
- xAxisLabelsVerticalShift: 0,
58
- dashWidth: 4,
59
- dashGap: 8,
60
- backgroundColor: 'transparent',
61
-
62
- hideRules: false,
63
- rulesType: ruleTypes.DASHED,
64
- rulesThickness: 1,
65
- rulesColor: 'lightgray',
66
- rulesConfigArray: [],
67
-
68
- rotateLabel: false,
69
-
70
- showYAxisIndices: false,
71
- yAxisIndicesHeight: 2,
72
- yAxisIndicesWidth: 4,
73
- yAxisIndicesColor: 'black',
74
-
75
- showXAxisIndices: false,
76
- xAxisIndicesHeight: 2,
77
- xAxisIndicesWidth: 4,
78
- xAxisIndicesColor: 'black',
79
-
80
- hideOrigin: false,
81
- hideYAxisText: false,
82
- yAxisTextNumberOfLines: 1,
83
-
84
- showVerticalLines: false,
85
- verticalLinesThickness: 1,
86
- verticalLinesColor: 'lightgray',
87
- verticalLinesStrokeDashArray: '',
88
- verticalLinesShift: 0,
89
- verticalLinesZIndex: -1,
90
- verticalLinesSpacing: 0,
91
- verticalLinesUptoDataPoint: false,
92
-
93
- noOfSections: 10,
94
- containerHeight: 200,
95
- width: 200,
96
-
97
- labelWidth: 0,
98
- labelsExtraHeight: 0,
99
-
100
- yAxisLabelWidth: 35,
101
- yAxisEmptyLabelWidth: 10,
102
-
103
- showFractionalValues: false,
104
- roundToDigits: 1,
105
- referenceLinesOverChartContent: true,
106
- };
107
-
108
- export const defaultArrowConfig = {
109
- length: 10,
110
- width: 10,
111
- strokeWidth: 1,
112
- strokeColor: 'black',
113
- fillColor: 'none',
114
- showArrowBase: true,
115
- };
116
-
117
- // Bar chart specific
118
-
119
- export const BarDefaults = {
120
- barWidth: 30,
121
- spacing: 20,
122
- capThickness: 6,
123
- capColor: 'gray',
124
- capRadius: 0,
125
- barBorderColor: 'gray',
126
-
127
- horizontal: false,
128
- rtl: false,
129
- labelsWidthForHorizontal: 30,
130
- yAxisAtTop: false,
131
- rotateYAxisTexts: undefined,
132
- intactTopLabel: false,
133
-
134
- showLine: false,
135
- lineBehindBars: false,
136
-
137
- disableScroll: false,
138
- scrollToEnd: false,
139
- scrollAnimation: true,
140
- showScrollIndicator: false,
141
- scrollEventThrottle: defaultScrollEventThrottle,
142
-
143
- side: '',
144
- isAnimated: false,
145
- animationDuration: 800,
146
- opacity: 1,
147
- isThreeD: false,
148
- };
149
-
150
- export const defaultLineConfig: defaultLineConfigType = {
151
- initialSpacing: BarDefaults.spacing, // gets updated to spacing before being used
152
- curved: false,
153
- curvature: defaultCurvature,
154
- curveType: defaultCurveType,
155
- isAnimated: false,
156
- animationDuration: defaultAnimationDuration,
157
- thickness: 1,
158
- color: 'black',
159
- hideDataPoints: false,
160
- dataPointsShape: 'circular',
161
- dataPointsWidth: 4,
162
- dataPointsHeight: 4,
163
- dataPointsColor: 'black',
164
- dataPointsRadius: 3,
165
- textColor: 'gray',
166
- textFontSize: 10,
167
- textShiftX: 0,
168
- textShiftY: 0,
169
- shiftX: 0,
170
- shiftY: 0,
171
- delay: 0,
172
- startIndex: 0,
173
- endIndex: 0, // gets updated to lineData.length - 1
174
- showArrow: false,
175
- arrowConfig: defaultArrowConfig,
176
- isSecondary: false,
177
- };
178
-
179
- // Line chart specific
180
-
181
- export const LineDefaults = {
182
- color: 'black',
183
- curvature: defaultCurvature,
184
- curveType: defaultCurveType,
185
- thickness: 2,
186
- isAnimated: false,
187
- hideDataPoints: false,
188
- spacing: 50,
189
- initialSpacing: 20,
190
- endSpacing: 20,
191
- animationDuration: defaultAnimationDuration,
192
- animateTogether: false,
193
- disableScroll: false,
194
- scrollToEnd: false,
195
- scrollAnimation: true,
196
- showScrollIndicator: false,
197
- scrollEventThrottle: defaultScrollEventThrottle,
198
- showValuesAsDataPointsText: false,
199
-
200
- dataPointsHeight: 4,
201
- dataPointsWidth: 4,
202
- dataPointsRadius: 3,
203
- dataPointsColor: 'black',
204
- dataPointsColor2: 'blue',
205
- dataPointsColor3: 'red',
206
- dataPointsShape: 'circular',
207
-
208
- textFontSize: 10,
209
- textColor: 'gray',
210
-
211
- startFillColor: 'gray',
212
- endFillColor: 'white',
213
- lineGradient: false,
214
- lineGradientStartColor: 'lightgreen',
215
- lineGradientEndColor: 'orange',
216
- startOpacity: 1,
217
- endOpacity: 1,
218
-
219
- focusEnabled: false,
220
- showDataPointOnFocus: false,
221
- showStripOnFocus: false,
222
- showTextOnFocus: false,
223
- stripWidth: 2,
224
- unFocusOnPressOut: true,
225
- delayBeforeUnFocus: 300,
226
- edgePosition: EdgePosition.AT_DATA_POINT,
227
- };
228
-
229
- export const defaultPointerConfig = {
230
- height: 0,
231
- width: 0,
232
- radius: 5,
233
- pointerColor: 'red',
234
- pointerComponent: null,
235
- showPointerStrip: true,
236
- pointerStripHeight: AxesAndRulesDefaults.containerHeight, // gets updated to actual containerHeight
237
- pointerStripWidth: 1,
238
- pointerStripColor: 'black',
239
- pointerStripUptoDataPoint: false,
240
- pointerLabelComponent: null,
241
- stripOverPointer: false,
242
- shiftPointerLabelX: 0,
243
- shiftPointerLabelY: 0,
244
- pointerLabelWidth: 20,
245
- pointerLabelHeight: 20,
246
- autoAdjustPointerLabelPosition: false,
247
- pointerVanishDelay: 150,
248
- activatePointersOnLongPress: false,
249
- activatePointersDelay: 150,
250
- initialPointerIndex: -1,
251
- initialPointerAppearDelay: 0,
252
- persistPointer: false,
253
- hidePointer1: false,
254
- hidePointer2: false,
255
- hidePointer3: false,
256
- hidePointer4: false,
257
- hidePointer5: false,
258
- hideSecondaryPointer: false,
259
- barTouchable: false,
260
- stripBehindBars: true,
261
- resetPointerOnDataChange: true,
262
- // pointerEvents: PointerEvent
263
- };
264
-
265
- // Pie chart specific
266
-
267
- export const pieColors = [
268
- 'cyan',
269
- 'green',
270
- 'orange',
271
- 'purple',
272
- '#bbff00',
273
- 'red',
274
- 'blue',
275
- 'pink',
276
- ];
277
-
278
- export const populationDefaults = {
279
- height: 200,
280
- width: screenWidth,
281
- verticalMarginBetweenBars : 1,
282
- barsMapToYAxisSections: true,
283
-
284
- xAxisNoOfSections: 4,
285
- showXAxisIndices: true,
286
- xAxisIndicesWidth: 2,
287
- xAxisIndicesHeight: 4,
288
- xAxisIndicesColor: 'black',
289
- showXAxisLabelTexts: true,
290
- xAxisRoundToDigits: 0,
291
-
292
- showVerticalLines: true,
293
- verticalLinesColor: 'lightgray',
294
- verticalLinesThickness: 1,
295
- verticalLinesType: ruleTypes.DASHED,
296
- verticalLinesStrokeDashArray: [4,8],
297
-
298
- defaultFontSize: 12,
299
- defaultFontColor: 'black',
300
- defaultFontStyle: <FontStyle>'normal',
301
- defaultFontWeight: 1,
302
- defaultFontFamily: '',
303
-
304
- yAxisLabelTextMarginRight: 4,
305
- showValuesAsBarLabels: false,
306
- showMidAxis: false,
307
- midAxisLabelWidth: 35,
308
- midAxisType: ruleTypes.SOLID,
309
-
310
- leftBarLabelWidth: 30,
311
- rightBarLabelWidth: 30,
312
-
313
- leftBarColor: 'skyblue',
314
- rightBarColor: 'orange',
315
- leftBarBorderColor: 'blue',
316
- rightBarBorderColor: 'red',
317
- leftBarBorderWidth: 0,
318
- rightBarBorderWidth: 0,
319
- leftBarBorderRadius: 0,
320
- rightBarBorderRadius: 0,
321
- allCornersRounded: false,
322
- showSurplus: false,
323
- showSurplusLeft: false,
324
- showSurplusRight: false,
325
- leftSurplusColor: '#334790',
326
- leftSurplusBorderColor: 'blue',
327
- rightSurplusColor: '#AC343C',
328
- rightSurplusBorderColor: 'red',
329
- leftSurplusBorderWidth: 0,
330
- rightSurplusBorderWidth: 0,
331
- prefix: '',
332
- suffix: '',
333
- }