react-native-gifted-charts 1.3.6 → 1.3.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gifted-charts",
3
- "version": "1.3.6",
3
+ "version": "1.3.7",
4
4
  "description": "The most complete library for Bar, Line, Area, Pie, Donut and Stacked Bar charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
5
5
  "main": "src/index.tsx",
6
6
  "files": [
@@ -161,6 +161,8 @@ export const BarChart = (props: BarChartPropsType) => {
161
161
  const labelWidth = props.labelWidth ?? AxesAndRulesDefaults.labelWidth;
162
162
  const scrollToEnd = props.scrollToEnd ?? BarDefaults.scrollToEnd;
163
163
  const scrollAnimation = props.scrollAnimation ?? BarDefaults.scrollAnimation;
164
+ const scrollEventThrottle =
165
+ props.scrollEventThrottle ?? BarDefaults.scrollEventThrottle;
164
166
  const labelsExtraHeight =
165
167
  props.labelsExtraHeight ?? AxesAndRulesDefaults.labelsExtraHeight;
166
168
 
@@ -529,6 +531,7 @@ export const BarChart = (props: BarChartPropsType) => {
529
531
  scrollToEnd,
530
532
  scrollToIndex: props.scrollToIndex,
531
533
  scrollAnimation,
534
+ scrollEventThrottle,
532
535
  indicatorColor: props.indicatorColor,
533
536
  setSelectedIndex,
534
537
  spacing,
@@ -134,6 +134,7 @@ export type BarChartPropsType = {
134
134
  scrollToEnd?: boolean;
135
135
  scrollToIndex?: number;
136
136
  scrollAnimation?: boolean;
137
+ scrollEventThrottle?: number;
137
138
  labelsExtraHeight?: number;
138
139
  barBackgroundPattern?: Function;
139
140
  patternId?: String;
@@ -76,6 +76,8 @@ const BarAndLineChartsWrapper = (props: BarAndLineChartsWrapperTypes) => {
76
76
  pointerIndex,
77
77
  pointerX,
78
78
  pointerY,
79
+
80
+ scrollEventThrottle,
79
81
  } = props;
80
82
 
81
83
  let yAxisAtTop = rtl ? !props.yAxisAtTop : props.yAxisAtTop;
@@ -240,6 +242,7 @@ const BarAndLineChartsWrapper = (props: BarAndLineChartsWrapperTypes) => {
240
242
  totalWidth,
241
243
  barWidth,
242
244
  labelsExtraHeight,
245
+ scrollEventThrottle,
243
246
  };
244
247
  const extendedContainerHeight = containerHeight + 10;
245
248
  const containerHeightIncludingBelowXAxis =
@@ -322,6 +325,9 @@ const BarAndLineChartsWrapper = (props: BarAndLineChartsWrapperTypes) => {
322
325
  ? renderHorizSections(horizSectionProps)
323
326
  : null}
324
327
  <ScrollView
328
+ scrollEventThrottle={
329
+ props.scrollEventThrottle ? props.scrollEventThrottle : 16
330
+ }
325
331
  horizontal
326
332
  ref={scrollRef}
327
333
  style={[
@@ -340,7 +346,7 @@ const BarAndLineChartsWrapper = (props: BarAndLineChartsWrapperTypes) => {
340
346
  60 +
341
347
  (chartType === chartTypes.LINE_BI_COLOR ? 0 : xAxisThickness),
342
348
  },
343
- !!props.width && {width: props.width - 11},
349
+ !!props.width && {width: props.width},
344
350
  horizontal && {
345
351
  width:
346
352
  (props.width ?? totalWidth) + (props.width ? endSpacing : -20),
@@ -410,9 +416,9 @@ const BarAndLineChartsWrapper = (props: BarAndLineChartsWrapperTypes) => {
410
416
  </ScrollView>
411
417
  {
412
418
  // Only For Line Charts-
413
- pointerConfig &&
414
- getPointerProps &&
415
- getPointerProps({pointerIndex, pointerX, pointerY})
419
+ pointerConfig && getPointerProps
420
+ ? getPointerProps({pointerIndex, pointerX, pointerY})
421
+ : null
416
422
  }
417
423
  </View>
418
424
  );
@@ -125,7 +125,8 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
125
125
  );
126
126
  secondaryYAxisConfig.maxValue =
127
127
  secondaryYAxisConfig.maxValue ?? (maxItem || maxValue);
128
- secondaryYAxisConfig.mostNegativeValue = secondaryYAxisConfig.mostNegativeValue ?? minItem;
128
+ secondaryYAxisConfig.mostNegativeValue =
129
+ secondaryYAxisConfig.mostNegativeValue ?? minItem;
129
130
  secondaryYAxisConfig.stepValue =
130
131
  secondaryYAxisConfig.stepValue ??
131
132
  secondaryYAxisConfig.maxValue /
@@ -391,6 +392,7 @@ export const renderHorizSections = (props: horizSectionPropTypes) => {
391
392
  {
392
393
  borderColor: yAxisColor,
393
394
  backgroundColor: backgroundColor,
395
+ width: (props.width || totalWidth - spacing) + endSpacing,
394
396
  },
395
397
  yAxisSide === yAxisSides.RIGHT
396
398
  ? {borderRightWidth: yAxisThickness}
@@ -180,6 +180,7 @@ type propTypes = {
180
180
  scrollToEnd?: boolean;
181
181
  scrollToIndex?: number;
182
182
  scrollAnimation?: boolean;
183
+ scrollEventThrottle?: number;
183
184
  noOfSectionsBelowXAxis?: number;
184
185
  labelsExtraHeight?: number;
185
186
  adjustToWidth?: boolean;
@@ -197,8 +198,8 @@ type referenceConfigType = {
197
198
  };
198
199
  type itemType = {
199
200
  value: number;
200
- label: String;
201
- labelComponent: Function;
201
+ label?: String;
202
+ labelComponent?: Function;
202
203
  labelTextStyle?: any;
203
204
  dataPointText?: string;
204
205
  textShiftX?: number;
@@ -274,6 +275,8 @@ export const LineChartBicolor = (props: propTypes) => {
274
275
 
275
276
  const scrollToEnd = props.scrollToEnd ?? LineDefaults.scrollToEnd;
276
277
  const scrollAnimation = props.scrollAnimation ?? LineDefaults.scrollAnimation;
278
+ const scrollEventThrottle =
279
+ props.scrollEventThrottle ?? LineDefaults.scrollEventThrottle;
277
280
 
278
281
  const opacValue = useMemo(() => new Animated.Value(0), []);
279
282
  const widthValue = useMemo(() => new Animated.Value(0), []);
@@ -700,7 +703,7 @@ export const LineChartBicolor = (props: propTypes) => {
700
703
  index: number,
701
704
  label: String,
702
705
  labelTextStyle: any,
703
- labelComponent: Function,
706
+ labelComponent?: Function,
704
707
  ) => {
705
708
  return (
706
709
  <View
@@ -735,7 +738,7 @@ export const LineChartBicolor = (props: propTypes) => {
735
738
  index: number,
736
739
  label: String,
737
740
  labelTextStyle: any,
738
- labelComponent: Function,
741
+ labelComponent?: Function,
739
742
  ) => {
740
743
  return (
741
744
  <Animated.View
@@ -1335,6 +1338,7 @@ export const LineChartBicolor = (props: propTypes) => {
1335
1338
  scrollToEnd,
1336
1339
  scrollToIndex: props.scrollToIndex,
1337
1340
  scrollAnimation,
1341
+ scrollEventThrottle,
1338
1342
  indicatorColor: props.indicatorColor,
1339
1343
  setSelectedIndex,
1340
1344
  spacing,
@@ -6,7 +6,15 @@ import React, {
6
6
  useState,
7
7
  useRef,
8
8
  } from 'react';
9
- import {View, Animated, Easing, Text, Dimensions, Platform, ColorValue} from 'react-native';
9
+ import {
10
+ View,
11
+ Animated,
12
+ Easing,
13
+ Text,
14
+ Dimensions,
15
+ Platform,
16
+ ColorValue,
17
+ } from 'react-native';
10
18
  import {styles} from './styles';
11
19
  import Svg, {
12
20
  Path,
@@ -32,6 +40,7 @@ import {
32
40
  chartTypes,
33
41
  defaultArrowConfig,
34
42
  defaultPointerConfig,
43
+ screenWidth,
35
44
  } from '../utils/constants';
36
45
  import BarAndLineChartsWrapper from '../Components/BarAndLineChartsWrapper';
37
46
  import {LineChartPropsType, itemType} from './types';
@@ -78,6 +87,11 @@ export const LineChart = (props: LineChartPropsType) => {
78
87
  pointerShiftX: 0,
79
88
  pointerShiftY: 0,
80
89
  });
90
+ const [secondaryPointerY, setSecondaryPointerY] = useState(0);
91
+ const [secondaryPointerItem, setSecondaryPointerItem] = useState({
92
+ pointerShiftX: 0,
93
+ pointerShiftY: 0,
94
+ });
81
95
  const [responderStartTime, setResponderStartTime] = useState(0);
82
96
  const [responderActive, setResponderActive] = useState(false);
83
97
  const [points, setPoints] = useState('');
@@ -167,6 +181,8 @@ export const LineChart = (props: LineChartPropsType) => {
167
181
 
168
182
  const scrollToEnd = props.scrollToEnd || LineDefaults.scrollToEnd;
169
183
  const scrollAnimation = props.scrollAnimation ?? LineDefaults.scrollAnimation;
184
+ const scrollEventThrottle =
185
+ props.scrollEventThrottle ?? LineDefaults.scrollEventThrottle;
170
186
 
171
187
  const opacValue = useMemo(() => new Animated.Value(0), []);
172
188
  const widthValue = useMemo(() => new Animated.Value(0), []);
@@ -225,10 +241,16 @@ export const LineChart = (props: LineChartPropsType) => {
225
241
 
226
242
  const thickness = props.thickness || LineDefaults.thickness;
227
243
 
244
+ const yAxisLabelWidth =
245
+ props.yAxisLabelWidth ??
246
+ (props.hideYAxisText
247
+ ? AxesAndRulesDefaults.yAxisEmptyLabelWidth
248
+ : AxesAndRulesDefaults.yAxisLabelWidth);
249
+
228
250
  const spacing =
229
251
  props.spacing ??
230
252
  (adjustToWidth
231
- ? ((props.width ?? AxesAndRulesDefaults.width) - initialSpacing) /
253
+ ? ((props.width ?? screenWidth - yAxisLabelWidth) - initialSpacing) /
232
254
  (data.length - 1)
233
255
  : LineDefaults.spacing);
234
256
 
@@ -1323,11 +1345,6 @@ export const LineChart = (props: LineChartPropsType) => {
1323
1345
  const horizontalRulesStyle = props.horizontalRulesStyle;
1324
1346
  const showFractionalValues =
1325
1347
  props.showFractionalValues ?? AxesAndRulesDefaults.showFractionalValues;
1326
- const yAxisLabelWidth =
1327
- props.yAxisLabelWidth ??
1328
- (props.hideYAxisText
1329
- ? AxesAndRulesDefaults.yAxisEmptyLabelWidth
1330
- : AxesAndRulesDefaults.yAxisLabelWidth);
1331
1348
 
1332
1349
  const horizontal = false;
1333
1350
  const yAxisAtTop = false;
@@ -1336,83 +1353,69 @@ export const LineChart = (props: LineChartPropsType) => {
1336
1353
 
1337
1354
  const pointerConfig = props.pointerConfig || null;
1338
1355
  const getPointerProps = props.getPointerProps || null;
1339
- const pointerHeight = pointerConfig?.height
1340
- ? pointerConfig.height
1341
- : defaultPointerConfig.height;
1342
- const pointerWidth = pointerConfig?.width
1343
- ? pointerConfig.width
1344
- : defaultPointerConfig.width;
1345
- const pointerRadius = pointerConfig?.radius
1346
- ? pointerConfig.radius
1347
- : defaultPointerConfig.radius;
1348
- const pointerColor = pointerConfig?.pointerColor
1349
- ? pointerConfig.pointerColor
1350
- : defaultPointerConfig.pointerColor;
1351
- const pointerComponent = pointerConfig?.pointerComponent
1352
- ? pointerConfig.pointerComponent
1353
- : defaultPointerConfig.pointerComponent;
1356
+ const pointerHeight = pointerConfig?.height ?? defaultPointerConfig.height;
1357
+ const pointerWidth = pointerConfig?.width ?? defaultPointerConfig.width;
1358
+ const pointerRadius = pointerConfig?.radius ?? defaultPointerConfig.radius;
1359
+ const pointerColor =
1360
+ pointerConfig?.pointerColor ?? defaultPointerConfig.pointerColor;
1361
+ const pointerComponent =
1362
+ pointerConfig?.pointerComponent ?? defaultPointerConfig.pointerComponent;
1354
1363
 
1355
1364
  const showPointerStrip =
1356
1365
  pointerConfig?.showPointerStrip === false
1357
1366
  ? false
1358
1367
  : defaultPointerConfig.showPointerStrip;
1359
- const pointerStripHeight = pointerConfig?.pointerStripHeight
1360
- ? pointerConfig.pointerStripHeight
1361
- : defaultPointerConfig.pointerStripHeight;
1362
- const pointerStripWidth = pointerConfig?.pointerStripWidth
1363
- ? pointerConfig.pointerStripWidth
1364
- : defaultPointerConfig.pointerStripWidth;
1365
- const pointerStripColor = pointerConfig?.pointerStripColor
1366
- ? pointerConfig.pointerStripColor
1367
- : defaultPointerConfig.pointerStripColor;
1368
- const pointerStripUptoDataPoint = pointerConfig?.pointerStripUptoDataPoint
1369
- ? pointerConfig.pointerStripUptoDataPoint
1370
- : defaultPointerConfig.pointerStripUptoDataPoint;
1371
- const pointerLabelComponent = pointerConfig?.pointerLabelComponent
1372
- ? pointerConfig.pointerLabelComponent
1373
- : defaultPointerConfig.pointerLabelComponent;
1374
- const stripOverPointer = pointerConfig?.stripOverPointer
1375
- ? pointerConfig.stripOverPointer
1376
- : defaultPointerConfig.stripOverPointer;
1377
- const shiftPointerLabelX = pointerConfig?.shiftPointerLabelX
1378
- ? pointerConfig.shiftPointerLabelX
1379
- : defaultPointerConfig.shiftPointerLabelX;
1380
- const shiftPointerLabelY = pointerConfig?.shiftPointerLabelY
1381
- ? pointerConfig.shiftPointerLabelY
1382
- : defaultPointerConfig.shiftPointerLabelY;
1383
- const pointerLabelWidth = pointerConfig?.pointerLabelWidth
1384
- ? pointerConfig.pointerLabelWidth
1385
- : defaultPointerConfig.pointerLabelWidth;
1386
- const pointerLabelHeight = pointerConfig?.pointerLabelHeight
1387
- ? pointerConfig.pointerLabelHeight
1388
- : defaultPointerConfig.pointerLabelHeight;
1368
+ const pointerStripHeight =
1369
+ pointerConfig?.pointerStripHeight ??
1370
+ defaultPointerConfig.pointerStripHeight;
1371
+ const pointerStripWidth =
1372
+ pointerConfig?.pointerStripWidth ?? defaultPointerConfig.pointerStripWidth;
1373
+ const pointerStripColor =
1374
+ pointerConfig?.pointerStripColor ?? defaultPointerConfig.pointerStripColor;
1375
+ const pointerStripUptoDataPoint =
1376
+ pointerConfig?.pointerStripUptoDataPoint ??
1377
+ defaultPointerConfig.pointerStripUptoDataPoint;
1378
+ const pointerLabelComponent =
1379
+ pointerConfig?.pointerLabelComponent ??
1380
+ defaultPointerConfig.pointerLabelComponent;
1381
+ const stripOverPointer =
1382
+ pointerConfig?.stripOverPointer ?? defaultPointerConfig.stripOverPointer;
1383
+ const shiftPointerLabelX =
1384
+ pointerConfig?.shiftPointerLabelX ??
1385
+ defaultPointerConfig.shiftPointerLabelX;
1386
+ const shiftPointerLabelY =
1387
+ pointerConfig?.shiftPointerLabelY ??
1388
+ defaultPointerConfig.shiftPointerLabelY;
1389
+ const pointerLabelWidth =
1390
+ pointerConfig?.pointerLabelWidth ?? defaultPointerConfig.pointerLabelWidth;
1391
+ const pointerLabelHeight =
1392
+ pointerConfig?.pointerLabelHeight ??
1393
+ defaultPointerConfig.pointerLabelHeight;
1389
1394
  const autoAdjustPointerLabelPosition =
1390
1395
  pointerConfig?.autoAdjustPointerLabelPosition ??
1391
1396
  defaultPointerConfig.autoAdjustPointerLabelPosition;
1392
- const pointerVanishDelay = pointerConfig?.pointerVanishDelay
1393
- ? pointerConfig.pointerVanishDelay
1394
- : defaultPointerConfig.pointerVanishDelay;
1395
- const activatePointersOnLongPress = pointerConfig?.activatePointersOnLongPress
1396
- ? pointerConfig.activatePointersOnLongPress
1397
- : defaultPointerConfig.activatePointersOnLongPress;
1398
- const activatePointersDelay = pointerConfig?.activatePointersDelay
1399
- ? pointerConfig.activatePointersDelay
1400
- : defaultPointerConfig.activatePointersDelay;
1401
- const hidePointer1 = pointerConfig?.hidePointer1
1402
- ? pointerConfig.hidePointer1
1403
- : defaultPointerConfig.hidePointer1;
1404
- const hidePointer2 = pointerConfig?.hidePointer2
1405
- ? pointerConfig.hidePointer2
1406
- : defaultPointerConfig.hidePointer2;
1407
- const hidePointer3 = pointerConfig?.hidePointer3
1408
- ? pointerConfig.hidePointer3
1409
- : defaultPointerConfig.hidePointer3;
1410
- const hidePointer4 = pointerConfig?.hidePointer4
1411
- ? pointerConfig.hidePointer4
1412
- : defaultPointerConfig.hidePointer4;
1413
- const hidePointer5 = pointerConfig?.hidePointer5
1414
- ? pointerConfig.hidePointer5
1415
- : defaultPointerConfig.hidePointer5;
1397
+ const pointerVanishDelay =
1398
+ pointerConfig?.pointerVanishDelay ??
1399
+ defaultPointerConfig.pointerVanishDelay;
1400
+ const activatePointersOnLongPress =
1401
+ pointerConfig?.activatePointersOnLongPress ??
1402
+ defaultPointerConfig.activatePointersOnLongPress;
1403
+ const activatePointersDelay =
1404
+ pointerConfig?.activatePointersDelay ??
1405
+ defaultPointerConfig.activatePointersDelay;
1406
+ const hidePointer1 =
1407
+ pointerConfig?.hidePointer1 ?? defaultPointerConfig.hidePointer1;
1408
+ const hidePointer2 =
1409
+ pointerConfig?.hidePointer2 ?? defaultPointerConfig.hidePointer2;
1410
+ const hidePointer3 =
1411
+ pointerConfig?.hidePointer3 ?? defaultPointerConfig.hidePointer3;
1412
+ const hidePointer4 =
1413
+ pointerConfig?.hidePointer4 ?? defaultPointerConfig.hidePointer4;
1414
+ const hidePointer5 =
1415
+ pointerConfig?.hidePointer5 ?? defaultPointerConfig.hidePointer5;
1416
+ const hideSecondaryPointer =
1417
+ pointerConfig?.hideSecondaryPointer ??
1418
+ defaultPointerConfig.hideSecondaryPointer;
1416
1419
  const disableScroll =
1417
1420
  props.disableScroll ||
1418
1421
  (pointerConfig
@@ -1827,7 +1830,9 @@ export const LineChart = (props: LineChartPropsType) => {
1827
1830
  ? (item.value * containerHeight) / maxValue - xAxisThickness
1828
1831
  : extendedContainerHeight - xAxisThickness
1829
1832
  }
1830
- fill={item.verticalLineColor || props.verticalLinesColor || 'lightgray'}
1833
+ fill={
1834
+ item.verticalLineColor || props.verticalLinesColor || 'lightgray'
1835
+ }
1831
1836
  />
1832
1837
  );
1833
1838
  }
@@ -1841,6 +1846,9 @@ export const LineChart = (props: LineChartPropsType) => {
1841
1846
  if (lineNumber === 3 && hidePointer3) return;
1842
1847
  if (lineNumber === 4 && hidePointer4) return;
1843
1848
  if (lineNumber === 5 && hidePointer5) return;
1849
+ // 6 is for secondaryData
1850
+ if (lineNumber === 6 && hideSecondaryPointer) return;
1851
+
1844
1852
  let pointerItemLocal, pointerYLocal, pointerColorLocal;
1845
1853
  switch (lineNumber) {
1846
1854
  case 1:
@@ -1868,6 +1876,12 @@ export const LineChart = (props: LineChartPropsType) => {
1868
1876
  pointerYLocal = pointerY5;
1869
1877
  pointerColorLocal = pointerConfig?.pointer5Color || pointerColor;
1870
1878
  break;
1879
+ case 6:
1880
+ pointerItemLocal = secondaryPointerItem;
1881
+ pointerYLocal = secondaryPointerY;
1882
+ pointerColorLocal =
1883
+ pointerConfig?.secondaryPointerColor || pointerColor;
1884
+ break;
1871
1885
  }
1872
1886
 
1873
1887
  return (
@@ -1915,6 +1929,9 @@ export const LineChart = (props: LineChartPropsType) => {
1915
1929
  arr.push(pointerY5);
1916
1930
  pointerItemLocal.push(pointerItem5);
1917
1931
  }
1932
+ if (secondaryPointerY !== 0) {
1933
+ pointerItemLocal.push(secondaryPointerItem);
1934
+ }
1918
1935
  pointerYLocal = Math.min(...arr);
1919
1936
 
1920
1937
  let left = 0,
@@ -2025,7 +2042,7 @@ export const LineChart = (props: LineChartPropsType) => {
2025
2042
  width: pointerLabelWidth,
2026
2043
  },
2027
2044
  ]}>
2028
- {pointerLabelComponent(pointerItemLocal)}
2045
+ {pointerLabelComponent(pointerItemLocal, secondaryPointerItem)}
2029
2046
  </View>
2030
2047
  )}
2031
2048
  </View>
@@ -2320,6 +2337,18 @@ export const LineChart = (props: LineChartPropsType) => {
2320
2337
  setPointerItem5(item);
2321
2338
  }
2322
2339
  }
2340
+ if (secondaryData?.length) {
2341
+ item = secondaryData[factor];
2342
+ if (item) {
2343
+ y =
2344
+ containerHeight -
2345
+ (item.value * containerHeight) / maxValue -
2346
+ (pointerRadius || pointerHeight / 2) +
2347
+ 10;
2348
+ setSecondaryPointerY(y);
2349
+ setSecondaryPointerItem(item);
2350
+ }
2351
+ }
2323
2352
  }}
2324
2353
  onResponderMove={evt => {
2325
2354
  if (!pointerConfig) return;
@@ -2405,6 +2434,18 @@ export const LineChart = (props: LineChartPropsType) => {
2405
2434
  setPointerItem5(item);
2406
2435
  }
2407
2436
  }
2437
+ if (secondaryData?.length) {
2438
+ item = secondaryData[factor];
2439
+ if (item) {
2440
+ y =
2441
+ containerHeight -
2442
+ (item.value * containerHeight) / maxValue -
2443
+ (pointerRadius || pointerHeight / 2) +
2444
+ 10;
2445
+ setSecondaryPointerY(y);
2446
+ setSecondaryPointerItem(item);
2447
+ }
2448
+ }
2408
2449
  }}
2409
2450
  // onResponderReject={evt => {
2410
2451
  // console.log('evt...reject.......',evt);
@@ -2560,6 +2601,18 @@ export const LineChart = (props: LineChartPropsType) => {
2560
2601
  setPointerItem5(item);
2561
2602
  }
2562
2603
  }
2604
+ if (secondaryData?.length) {
2605
+ item = secondaryData[factor];
2606
+ if (item) {
2607
+ y =
2608
+ containerHeight -
2609
+ (item.value * containerHeight) / maxValue -
2610
+ (pointerRadius || pointerHeight / 2) +
2611
+ 10;
2612
+ setSecondaryPointerY(y);
2613
+ setSecondaryPointerItem(item);
2614
+ }
2615
+ }
2563
2616
  }}
2564
2617
  onResponderMove={evt => {
2565
2618
  if (!pointerConfig) return;
@@ -2645,6 +2698,18 @@ export const LineChart = (props: LineChartPropsType) => {
2645
2698
  setPointerItem5(item);
2646
2699
  }
2647
2700
  }
2701
+ if (secondaryData?.length) {
2702
+ item = secondaryData[factor];
2703
+ if (item) {
2704
+ y =
2705
+ containerHeight -
2706
+ (item.value * containerHeight) / maxValue -
2707
+ (pointerRadius || pointerHeight / 2) +
2708
+ 10;
2709
+ setSecondaryPointerY(y);
2710
+ setSecondaryPointerItem(item);
2711
+ }
2712
+ }
2648
2713
  }}
2649
2714
  // onResponderReject={evt => {
2650
2715
  // console.log('evt...reject.......',evt);
@@ -2667,8 +2732,13 @@ export const LineChart = (props: LineChartPropsType) => {
2667
2732
  // }}
2668
2733
  style={{
2669
2734
  position: 'absolute',
2670
- height: containerHeightIncludingBelowXAxis,
2671
- bottom: 60, //stepHeight * -0.5 + xAxisThickness,
2735
+ height:
2736
+ containerHeightIncludingBelowXAxis +
2737
+ (props.overflowBottom ?? dataPointsRadius1),
2738
+ bottom:
2739
+ 60 +
2740
+ labelsExtraHeight -
2741
+ (props.overflowBottom ?? dataPointsRadius1),
2672
2742
  width: animatedWidth,
2673
2743
  zIndex: zIndex,
2674
2744
  // backgroundColor: 'wheat',
@@ -2939,8 +3009,7 @@ export const LineChart = (props: LineChartPropsType) => {
2939
3009
  style={{
2940
3010
  position: 'absolute',
2941
3011
  height:
2942
- extendedContainerHeight +
2943
- noOfSectionsBelowXAxis * stepHeight,
3012
+ extendedContainerHeight + noOfSectionsBelowXAxis * stepHeight,
2944
3013
  bottom: 60 + labelsExtraHeight,
2945
3014
  width: totalWidth,
2946
3015
  zIndex: 20,
@@ -2951,6 +3020,7 @@ export const LineChart = (props: LineChartPropsType) => {
2951
3020
  {points3 ? renderPointer(3) : null}
2952
3021
  {points4 ? renderPointer(4) : null}
2953
3022
  {points5 ? renderPointer(5) : null}
3023
+ {secondaryPoints ? renderPointer(6) : null}
2954
3024
  {stripOverPointer && renderStripAndLabel()}
2955
3025
  </View>
2956
3026
  ) : null}
@@ -3010,6 +3080,7 @@ export const LineChart = (props: LineChartPropsType) => {
3010
3080
  scrollToEnd,
3011
3081
  scrollToIndex: props.scrollToIndex,
3012
3082
  scrollAnimation,
3083
+ scrollEventThrottle,
3013
3084
  indicatorColor: props.indicatorColor,
3014
3085
  setSelectedIndex,
3015
3086
  spacing,
@@ -19,11 +19,11 @@ export const styles = StyleSheet.create({
19
19
  },
20
20
  leftPart: {
21
21
  justifyContent: 'center',
22
- width: '100%',
22
+ // width: '100%',
23
23
  },
24
24
  lastLeftPart: {
25
25
  justifyContent: 'flex-end',
26
- width: '100%',
26
+ // width: '100%',
27
27
  },
28
28
  line: {
29
29
  width: '100%',
@@ -258,6 +258,7 @@ export type LineChartPropsType = {
258
258
  scrollToEnd?: boolean;
259
259
  scrollToIndex?: number;
260
260
  scrollAnimation?: boolean;
261
+ scrollEventThrottle?: number;
261
262
  noOfSectionsBelowXAxis?: number;
262
263
  labelsExtraHeight?: number;
263
264
  adjustToWidth?: boolean;
@@ -352,6 +353,7 @@ type Pointer = {
352
353
  pointer3Color?: ColorValue;
353
354
  pointer4Color?: ColorValue;
354
355
  pointer5Color?: ColorValue;
356
+ secondaryPointerColor?: ColorValue;
355
357
  pointerComponent?: Function;
356
358
  showPointerStrip?: boolean;
357
359
  pointerStripWidth?: number;
@@ -373,5 +375,6 @@ type Pointer = {
373
375
  hidePointer3?: boolean;
374
376
  hidePointer4?: boolean;
375
377
  hidePointer5?: boolean;
378
+ hideSecondaryPointer?: boolean;
376
379
  strokeDashArray?: Array<number>;
377
380
  };
@@ -1,5 +1,6 @@
1
1
  import {defaultLineConfigType} from '../BarChart/types';
2
- import {CurveType} from './types';
2
+ import {CurveType, RuleTypes} from './types';
3
+ import {Dimensions} from 'react-native';
3
4
 
4
5
  // Global
5
6
 
@@ -9,9 +10,12 @@ export enum chartTypes {
9
10
  LINE_BI_COLOR,
10
11
  }
11
12
 
13
+ export const screenWidth = Dimensions.get('window').width;
14
+
12
15
  const defaultCurvature = 0.2;
13
16
  const defaultCurveType = CurveType.CUBIC;
14
17
  const defaultAnimationDuration = 800;
18
+ const defaultScrollEventThrottle = 0;
15
19
 
16
20
  // Bar and Line chart Specific
17
21
 
@@ -20,7 +24,7 @@ export enum yAxisSides {
20
24
  RIGHT,
21
25
  }
22
26
 
23
- export const ruleTypes = {
27
+ export const ruleTypes: RuleTypes = {
24
28
  SOLID: 'solid',
25
29
  DASHED: 'dashed',
26
30
  DOTTED: 'dotted',
@@ -114,6 +118,7 @@ export const BarDefaults = {
114
118
  scrollToEnd: false,
115
119
  scrollAnimation: true,
116
120
  showScrollIndicator: false,
121
+ scrollEventThrottle: defaultScrollEventThrottle,
117
122
 
118
123
  side: '',
119
124
  isAnimated: false,
@@ -168,6 +173,7 @@ export const LineDefaults = {
168
173
  scrollToEnd: false,
169
174
  scrollAnimation: true,
170
175
  showScrollIndicator: false,
176
+ scrollEventThrottle: defaultScrollEventThrottle,
171
177
  showValuesAsDataPointsText: false,
172
178
 
173
179
  dataPointsHeight: 4,
@@ -221,6 +227,7 @@ export const defaultPointerConfig = {
221
227
  hidePointer3: false,
222
228
  hidePointer4: false,
223
229
  hidePointer5: false,
230
+ hideSecondaryPointer: false,
224
231
  };
225
232
 
226
233
  // Pie chart specific
@@ -1,7 +1,13 @@
1
1
  import {ColorValue} from 'react-native';
2
2
  import {chartTypes, yAxisSides} from './constants';
3
3
 
4
- export type RuleType = 'solid' | 'dashed' | 'dotted';
4
+ export type RuleType = 'solid' | 'dashed' | 'dotted' | string;
5
+
6
+ export type RuleTypes = {
7
+ SOLID: RuleType;
8
+ DASHED: RuleType;
9
+ DOTTED: RuleType;
10
+ };
5
11
 
6
12
  export enum CurveType {
7
13
  CUBIC,
@@ -205,4 +211,6 @@ export type BarAndLineChartsWrapperTypes = {
205
211
  pointerIndex: number;
206
212
  pointerX: number;
207
213
  pointerY: number;
214
+
215
+ scrollEventThrottle: number;
208
216
  };