gifted-charts-core 0.0.21 → 0.0.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.
@@ -1,6 +1,14 @@
1
- import { screenWidth } from "../../utils/constants";
1
+ import { screenWidth } from '../../utils/constants'
2
+ import { type StripAndLabelProps } from './types'
2
3
 
3
- export const getTopAndLeftForStripAndLabel = (props) => {
4
+ interface IgetTopAndLeftForStripAndLabel {
5
+ top: number
6
+ left: number
7
+ }
8
+
9
+ export const getTopAndLeftForStripAndLabel = (
10
+ props: StripAndLabelProps
11
+ ): IgetTopAndLeftForStripAndLabel => {
4
12
  const {
5
13
  autoAdjustPointerLabelPosition,
6
14
  pointerX,
@@ -16,45 +24,45 @@ export const getTopAndLeftForStripAndLabel = (props) => {
16
24
  pointerStripHeight,
17
25
  shiftPointerLabelY,
18
26
  scrollX,
19
- } = props;
20
- let left = 0,
21
- top = 0;
27
+ width
28
+ } = props
29
+ let left = 0
30
+ let top = 0
22
31
  if (autoAdjustPointerLabelPosition) {
23
32
  if (pointerX < pointerLabelWidth / 2) {
24
- left = 7;
33
+ left = 7
25
34
  } else if (
26
35
  activatePointersOnLongPress &&
27
36
  pointerX - scrollX < pointerLabelWidth / 2 - 10
28
37
  ) {
29
- left = 7;
38
+ left = 7
30
39
  } else {
31
40
  if (
32
41
  !activatePointersOnLongPress &&
33
42
  pointerX >
34
- (props.width || screenWidth - yAxisLabelWidth - 15) -
35
- pointerLabelWidth / 2
43
+ (width || screenWidth - yAxisLabelWidth - 15) - pointerLabelWidth / 2
36
44
  ) {
37
- left = -pointerLabelWidth - 4;
45
+ left = -pointerLabelWidth - 4
38
46
  } else if (
39
47
  activatePointersOnLongPress &&
40
48
  pointerX - scrollX >
41
- ((props.width ?? 0) + 10 || screenWidth - yAxisLabelWidth - 15) -
49
+ ((width ?? 0) + 10 || screenWidth - yAxisLabelWidth - 15) -
42
50
  pointerLabelWidth / 2
43
51
  ) {
44
- left = -pointerLabelWidth - 4;
52
+ left = -pointerLabelWidth - 4
45
53
  } else {
46
- left = -pointerLabelWidth / 2 + 5;
54
+ left = -pointerLabelWidth / 2 + 5
47
55
  }
48
56
  }
49
57
  } else {
50
- left = (pointerRadius || pointerWidth / 2) - 10 + shiftPointerLabelX;
58
+ left = (pointerRadius || pointerWidth / 2) - 10 + shiftPointerLabelX
51
59
  }
52
60
 
53
61
  if (autoAdjustPointerLabelPosition) {
54
62
  if (pointerLabelHeight - pointerYLocal > 10) {
55
- top = 10;
63
+ top = 10
56
64
  } else {
57
- top = -pointerLabelHeight;
65
+ top = -pointerLabelHeight
58
66
  }
59
67
  } else {
60
68
  top =
@@ -62,11 +70,11 @@ export const getTopAndLeftForStripAndLabel = (props) => {
62
70
  ? pointerRadius || pointerStripHeight / 2
63
71
  : -pointerYLocal + 8) -
64
72
  pointerLabelWidth / 2 +
65
- shiftPointerLabelY;
73
+ shiftPointerLabelY
66
74
  }
67
75
 
68
76
  return {
69
77
  top,
70
- left,
71
- };
72
- };
78
+ left
79
+ }
80
+ }
@@ -0,0 +1,31 @@
1
+ import { type ColorValue, type PointerEvent } from 'react-native'
2
+ import { type Pointer } from '../../utils/types'
3
+ import { type barDataItem, type stackDataItem } from '../../BarChart/types'
4
+
5
+ export interface StripAndLabelProps {
6
+ autoAdjustPointerLabelPosition: boolean
7
+ pointerX: number
8
+ pointerLabelWidth: number
9
+ activatePointersOnLongPress: boolean
10
+ yAxisLabelWidth: number
11
+ pointerRadius: number
12
+ pointerWidth: number
13
+ shiftPointerLabelX: number
14
+ pointerLabelHeight: number
15
+ pointerYLocal: number
16
+ pointerStripUptoDataPoint: boolean
17
+ pointerStripHeight: number
18
+ shiftPointerLabelY: number
19
+ pointerItemLocal: barDataItem | stackDataItem
20
+ showPointerStrip: boolean
21
+ pointerStripWidth: number
22
+ containerHeight: number
23
+ xAxisThickness: number
24
+ pointerStripColor: ColorValue
25
+ pointerConfig: Pointer
26
+ pointerLabelComponent: Function
27
+ secondaryPointerItem: barDataItem | stackDataItem
28
+ scrollX: number
29
+ pointerEvents: PointerEvent
30
+ width: number
31
+ }
@@ -1,7 +1,7 @@
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";
1
+ import { type defaultLineConfigType } from '../BarChart/types'
2
+ import { CurveType, EdgePosition, type RuleTypes } from './types'
3
+ import { Dimensions } from 'react-native'
4
+ import { type FontStyle } from 'react-native-svg'
5
5
 
6
6
  // Global
7
7
 
@@ -11,13 +11,13 @@ export enum chartTypes {
11
11
  LINE_BI_COLOR,
12
12
  }
13
13
 
14
- export const screenWidth = Dimensions.get("window").width;
14
+ export const screenWidth = Dimensions.get('window').width
15
15
 
16
- const defaultCurvature = 0.2;
17
- const defaultCurveType = CurveType.CUBIC;
18
- const defaultAnimationDuration = 800;
19
- const defaultScrollEventThrottle = 0;
20
- const defaultEndReachedOffset = 80;
16
+ export const defaultCurvature = 0.2
17
+ const defaultCurveType = CurveType.CUBIC
18
+ const defaultAnimationDuration = 800
19
+ const defaultScrollEventThrottle = 0
20
+ const defaultEndReachedOffset = 80
21
21
 
22
22
  // Bar and Line chart Specific
23
23
 
@@ -32,38 +32,38 @@ export enum loc {
32
32
  DOWN,
33
33
  }
34
34
 
35
- export const SEGMENT_START = "segmentStart";
36
- export const SEGMENT_END = "segmentEnd";
37
- export const RANGE_ENTER = "RangeEnter";
38
- export const RANGE_EXIT = "RangeExit";
39
- export const STOP = "stop";
35
+ export const SEGMENT_START = 'segmentStart'
36
+ export const SEGMENT_END = 'segmentEnd'
37
+ export const RANGE_ENTER = 'RangeEnter'
38
+ export const RANGE_EXIT = 'RangeExit'
39
+ export const STOP = 'stop'
40
40
 
41
41
  export const ruleTypes: RuleTypes = {
42
- SOLID: "solid",
43
- DASHED: "dashed",
44
- DOTTED: "dotted",
45
- };
42
+ SOLID: 'solid',
43
+ DASHED: 'dashed',
44
+ DOTTED: 'dotted'
45
+ }
46
46
 
47
47
  export const AxesAndRulesDefaults = {
48
48
  yAxisSide: yAxisSides.LEFT,
49
- yAxisColor: "black",
49
+ yAxisColor: 'black',
50
50
  yAxisExtraHeight: 0,
51
51
  yAxisThickness: 1,
52
52
  trimYAxisAtTop: false,
53
53
  overflowTop: 0,
54
- xAxisColor: "black",
54
+ xAxisColor: 'black',
55
55
  xAxisThickness: 1,
56
56
  xAxisType: ruleTypes.SOLID,
57
57
  xAxisTextNumberOfLines: 1,
58
58
  xAxisLabelsVerticalShift: 0,
59
59
  dashWidth: 4,
60
60
  dashGap: 8,
61
- backgroundColor: "transparent",
61
+ backgroundColor: 'transparent',
62
62
 
63
63
  hideRules: false,
64
64
  rulesType: ruleTypes.DASHED,
65
65
  rulesThickness: 1,
66
- rulesColor: "lightgray",
66
+ rulesColor: 'lightgray',
67
67
  rulesConfigArray: [],
68
68
 
69
69
  rotateLabel: false,
@@ -71,12 +71,12 @@ export const AxesAndRulesDefaults = {
71
71
  showYAxisIndices: false,
72
72
  yAxisIndicesHeight: 2,
73
73
  yAxisIndicesWidth: 4,
74
- yAxisIndicesColor: "black",
74
+ yAxisIndicesColor: 'black',
75
75
 
76
76
  showXAxisIndices: false,
77
77
  xAxisIndicesHeight: 2,
78
78
  xAxisIndicesWidth: 4,
79
- xAxisIndicesColor: "black",
79
+ xAxisIndicesColor: 'black',
80
80
 
81
81
  hideOrigin: false,
82
82
  hideYAxisText: false,
@@ -84,8 +84,8 @@ export const AxesAndRulesDefaults = {
84
84
 
85
85
  showVerticalLines: false,
86
86
  verticalLinesThickness: 1,
87
- verticalLinesColor: "lightgray",
88
- verticalLinesStrokeDashArray: "",
87
+ verticalLinesColor: 'lightgray',
88
+ verticalLinesStrokeDashArray: '',
89
89
  verticalLinesShift: 0,
90
90
  verticalLinesZIndex: -1,
91
91
  verticalLinesSpacing: 0,
@@ -103,17 +103,17 @@ export const AxesAndRulesDefaults = {
103
103
 
104
104
  showFractionalValues: false,
105
105
  roundToDigits: 1,
106
- referenceLinesOverChartContent: true,
107
- };
106
+ referenceLinesOverChartContent: true
107
+ }
108
108
 
109
109
  export const defaultArrowConfig = {
110
110
  length: 10,
111
111
  width: 10,
112
112
  strokeWidth: 1,
113
- strokeColor: "black",
114
- fillColor: "none",
115
- showArrowBase: true,
116
- };
113
+ strokeColor: 'black',
114
+ fillColor: 'none',
115
+ showArrowBase: true
116
+ }
117
117
 
118
118
  // Bar chart specific
119
119
 
@@ -121,9 +121,9 @@ export const BarDefaults = {
121
121
  barWidth: 30,
122
122
  spacing: 20,
123
123
  capThickness: 6,
124
- capColor: "gray",
124
+ capColor: 'gray',
125
125
  capRadius: 0,
126
- barBorderColor: "gray",
126
+ barBorderColor: 'gray',
127
127
 
128
128
  horizontal: false,
129
129
  rtl: false,
@@ -141,22 +141,22 @@ export const BarDefaults = {
141
141
  showScrollIndicator: false,
142
142
  scrollEventThrottle: defaultScrollEventThrottle,
143
143
 
144
- side: "",
144
+ side: '',
145
145
  isAnimated: false,
146
146
  animationDuration: 800,
147
147
  opacity: 1,
148
148
  isThreeD: false,
149
- frontColor: "black",
150
- threeDBarGradientColor: "white",
151
- threeDBarFrontColor: "#C0CA3A",
152
- threeDBarSideColor: "#887A24",
153
- threeDBarTopColor: "#D9E676",
149
+ frontColor: 'black',
150
+ threeDBarGradientColor: 'white',
151
+ threeDBarFrontColor: '#C0CA3A',
152
+ threeDBarSideColor: '#887A24',
153
+ threeDBarTopColor: '#D9E676',
154
154
  endReachedOffset: defaultEndReachedOffset,
155
155
  focusedBarFrontColor: 'lightgreen',
156
156
  focusedThreeDBarFrontColor: '#B0B929',
157
157
  focusedBarSideColor: '#776913',
158
- focusedBarTopColor: '#C8D565',
159
- };
158
+ focusedBarTopColor: '#C8D565'
159
+ }
160
160
 
161
161
  export const defaultLineConfig: defaultLineConfigType = {
162
162
  initialSpacing: BarDefaults.spacing, // gets updated to spacing before being used
@@ -166,14 +166,14 @@ export const defaultLineConfig: defaultLineConfigType = {
166
166
  isAnimated: false,
167
167
  animationDuration: defaultAnimationDuration,
168
168
  thickness: 1,
169
- color: "black",
169
+ color: 'black',
170
170
  hideDataPoints: false,
171
- dataPointsShape: "circular",
171
+ dataPointsShape: 'circular',
172
172
  dataPointsWidth: 4,
173
173
  dataPointsHeight: 4,
174
- dataPointsColor: "black",
174
+ dataPointsColor: 'black',
175
175
  dataPointsRadius: 3,
176
- textColor: "gray",
176
+ textColor: 'gray',
177
177
  textFontSize: 10,
178
178
  textShiftX: 0,
179
179
  textShiftY: 0,
@@ -184,13 +184,13 @@ export const defaultLineConfig: defaultLineConfigType = {
184
184
  endIndex: 0, // gets updated to lineData.length - 1
185
185
  showArrow: false,
186
186
  arrowConfig: defaultArrowConfig,
187
- isSecondary: false,
188
- };
187
+ isSecondary: false
188
+ }
189
189
 
190
190
  // Line chart specific
191
191
 
192
192
  export const LineDefaults = {
193
- color: "black",
193
+ color: 'black',
194
194
  curvature: defaultCurvature,
195
195
  curveType: defaultCurveType,
196
196
  thickness: 2,
@@ -211,19 +211,19 @@ export const LineDefaults = {
211
211
  dataPointsHeight: 4,
212
212
  dataPointsWidth: 4,
213
213
  dataPointsRadius: 3,
214
- dataPointsColor: "black",
215
- dataPointsColor2: "blue",
216
- dataPointsColor3: "red",
217
- dataPointsShape: "circular",
214
+ dataPointsColor: 'black',
215
+ dataPointsColor2: 'blue',
216
+ dataPointsColor3: 'red',
217
+ dataPointsShape: 'circular',
218
218
 
219
219
  textFontSize: 10,
220
- textColor: "gray",
220
+ textColor: 'gray',
221
221
 
222
- startFillColor: "gray",
223
- endFillColor: "white",
222
+ startFillColor: 'gray',
223
+ endFillColor: 'white',
224
224
  lineGradient: false,
225
- lineGradientStartColor: "lightgreen",
226
- lineGradientEndColor: "orange",
225
+ lineGradientStartColor: 'lightgreen',
226
+ lineGradientEndColor: 'orange',
227
227
  startOpacity: 1,
228
228
  endOpacity: 1,
229
229
 
@@ -235,19 +235,19 @@ export const LineDefaults = {
235
235
  unFocusOnPressOut: true,
236
236
  delayBeforeUnFocus: 300,
237
237
  edgePosition: EdgePosition.AFTER_DATA_POINT,
238
- endReachedOffset: defaultEndReachedOffset,
239
- };
238
+ endReachedOffset: defaultEndReachedOffset
239
+ }
240
240
 
241
241
  export const defaultPointerConfig = {
242
242
  height: 0,
243
243
  width: 0,
244
244
  radius: 5,
245
- pointerColor: "red",
245
+ pointerColor: 'red',
246
246
  pointerComponent: null,
247
247
  showPointerStrip: true,
248
248
  pointerStripHeight: AxesAndRulesDefaults.containerHeight, // gets updated to actual containerHeight
249
249
  pointerStripWidth: 1,
250
- pointerStripColor: "black",
250
+ pointerStripColor: 'black',
251
251
  pointerStripUptoDataPoint: false,
252
252
  pointerLabelComponent: null,
253
253
  stripOverPointer: false,
@@ -270,22 +270,22 @@ export const defaultPointerConfig = {
270
270
  hideSecondaryPointer: false,
271
271
  barTouchable: false,
272
272
  stripBehindBars: true,
273
- resetPointerOnDataChange: true,
273
+ resetPointerOnDataChange: true
274
274
  // pointerEvents: PointerEvent
275
- };
275
+ }
276
276
 
277
277
  // Pie chart specific
278
278
 
279
279
  export const pieColors = [
280
- "cyan",
281
- "green",
282
- "orange",
283
- "purple",
284
- "#bbff00",
285
- "red",
286
- "blue",
287
- "pink",
288
- ];
280
+ 'cyan',
281
+ 'green',
282
+ 'orange',
283
+ 'purple',
284
+ '#bbff00',
285
+ 'red',
286
+ 'blue',
287
+ 'pink'
288
+ ]
289
289
 
290
290
  export const populationDefaults = {
291
291
  height: 200,
@@ -297,21 +297,21 @@ export const populationDefaults = {
297
297
  showXAxisIndices: true,
298
298
  xAxisIndicesWidth: 2,
299
299
  xAxisIndicesHeight: 4,
300
- xAxisIndicesColor: "black",
300
+ xAxisIndicesColor: 'black',
301
301
  showXAxisLabelTexts: true,
302
302
  xAxisRoundToDigits: 0,
303
303
 
304
304
  showVerticalLines: true,
305
- verticalLinesColor: "lightgray",
305
+ verticalLinesColor: 'lightgray',
306
306
  verticalLinesThickness: 1,
307
307
  verticalLinesType: ruleTypes.DASHED,
308
308
  verticalLinesStrokeDashArray: [4, 8],
309
309
 
310
310
  defaultFontSize: 12,
311
- defaultFontColor: "black",
312
- defaultFontStyle: <FontStyle>"normal",
311
+ defaultFontColor: 'black',
312
+ defaultFontStyle: 'normal' as FontStyle,
313
313
  defaultFontWeight: 1,
314
- defaultFontFamily: "",
314
+ defaultFontFamily: '',
315
315
 
316
316
  yAxisLabelTextMarginRight: 4,
317
317
  showValuesAsBarLabels: false,
@@ -322,10 +322,10 @@ export const populationDefaults = {
322
322
  leftBarLabelWidth: 30,
323
323
  rightBarLabelWidth: 30,
324
324
 
325
- leftBarColor: "skyblue",
326
- rightBarColor: "orange",
327
- leftBarBorderColor: "blue",
328
- rightBarBorderColor: "red",
325
+ leftBarColor: 'skyblue',
326
+ rightBarColor: 'orange',
327
+ leftBarBorderColor: 'blue',
328
+ rightBarBorderColor: 'red',
329
329
  leftBarBorderWidth: 0,
330
330
  rightBarBorderWidth: 0,
331
331
  leftBarBorderRadius: 0,
@@ -334,12 +334,12 @@ export const populationDefaults = {
334
334
  showSurplus: false,
335
335
  showSurplusLeft: false,
336
336
  showSurplusRight: false,
337
- leftSurplusColor: "#334790",
338
- leftSurplusBorderColor: "blue",
339
- rightSurplusColor: "#AC343C",
340
- rightSurplusBorderColor: "red",
337
+ leftSurplusColor: '#334790',
338
+ leftSurplusBorderColor: 'blue',
339
+ rightSurplusColor: '#AC343C',
340
+ rightSurplusBorderColor: 'red',
341
341
  leftSurplusBorderWidth: 0,
342
342
  rightSurplusBorderWidth: 0,
343
- prefix: "",
344
- suffix: "",
345
- };
343
+ prefix: '',
344
+ suffix: ''
345
+ }