gifted-charts-core 0.0.11 → 0.0.13

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": "gifted-charts-core",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Mathematical and logical utilities used by react-gifted-charts and react-native-gifted-charts",
5
5
  "main": "index.ts",
6
6
  "files": [
@@ -276,12 +276,20 @@ export const useLineChart = (props: extendedLineChartPropsType) => {
276
276
  const endIndex5 = props.endIndex5 ?? data5.length - 1;
277
277
 
278
278
  const lineSegments = !interpolateMissingValues
279
- ? getLineSegmentsForMissingValues(data)
279
+ ? getLineSegmentsForMissingValues(props.data)
280
280
  : props.lineSegments;
281
- const lineSegments2 = props.lineSegments2;
282
- const lineSegments3 = props.lineSegments3;
283
- const lineSegments4 = props.lineSegments4;
284
- const lineSegments5 = props.lineSegments5;
281
+ const lineSegments2 = !interpolateMissingValues
282
+ ? getLineSegmentsForMissingValues(props.data2)
283
+ : props.lineSegments2;
284
+ const lineSegments3 = !interpolateMissingValues
285
+ ? getLineSegmentsForMissingValues(props.data3)
286
+ : props.lineSegments3;
287
+ const lineSegments4 = !interpolateMissingValues
288
+ ? getLineSegmentsForMissingValues(props.data4)
289
+ : props.lineSegments4;
290
+ const lineSegments5 = !interpolateMissingValues
291
+ ? getLineSegmentsForMissingValues(props.data5)
292
+ : props.lineSegments5;
285
293
 
286
294
  const highlightedRange = props.highlightedRange;
287
295
 
@@ -4,6 +4,7 @@ import {
4
4
  BarAndLineChartsWrapperTypes,
5
5
  horizSectionPropTypes,
6
6
  } from "../../utils/types";
7
+ import { I18nManager } from "react-native";
7
8
 
8
9
  export const useBarAndLineChartsWrapper = (
9
10
  props: BarAndLineChartsWrapperTypes
@@ -317,18 +318,25 @@ export const useBarAndLineChartsWrapper = (
317
318
  const [canMomentum, setCanMomentum] = useState(false);
318
319
 
319
320
  const isCloseToEnd = ({ layoutMeasurement, contentOffset, contentSize }) => {
320
- return (
321
- layoutMeasurement.width + contentOffset.x >=
322
- contentSize.width - initialSpacing - endReachedOffset
323
- );
321
+ return I18nManager.isRTL
322
+ ? contentOffset.x <= initialSpacing
323
+ : layoutMeasurement.width + contentOffset.x >=
324
+ contentSize.width - initialSpacing - endReachedOffset;
324
325
  };
325
326
 
326
327
  // const isCloseToStart = ({ layoutMeasurement, contentOffset }) => {
327
328
  // return layoutMeasurement.width + contentOffset.x <= initialSpacing;
328
329
  // };
329
330
 
330
- const isCloseToStart = ({ contentOffset }) => {
331
- return contentOffset.x <= initialSpacing;
331
+ const isCloseToStart = ({
332
+ layoutMeasurement,
333
+ contentOffset,
334
+ contentSize,
335
+ }) => {
336
+ return I18nManager.isRTL
337
+ ? layoutMeasurement.width + contentOffset.x >=
338
+ contentSize.width - initialSpacing - endReachedOffset
339
+ : contentOffset.x <= initialSpacing;
332
340
  };
333
341
 
334
342
  useEffect(() => {
@@ -1339,14 +1339,15 @@ export const getInterpolatedData = (
1339
1339
  };
1340
1340
 
1341
1341
  export const getLineSegmentsForMissingValues = (
1342
- data: lineDataItem[]
1343
- ): LineSegment[] => {
1342
+ data?: lineDataItem[]
1343
+ ): LineSegment[] | undefined => {
1344
+ if (!data?.length) return undefined;
1344
1345
  let i,
1345
1346
  n = data.length;
1346
1347
  const numericValuesLength = data.filter(
1347
1348
  (item) => typeof item.value === "number"
1348
1349
  ).length;
1349
- if (!numericValuesLength) return [];
1350
+ if (!numericValuesLength) return undefined;
1350
1351
  const segments: LineSegment[] = [];
1351
1352
  for (i = 0; i < n; i++) {
1352
1353
  if (typeof data[i].value !== "number") {