react-native-gifted-charts 1.4.67 → 1.4.69

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.
@@ -4,6 +4,7 @@ import Svg, { Path } from 'react-native-svg';
4
4
  import { renderSpecificVerticalLines } from './renderSpecificVerticalLines';
5
5
  import { renderDataPoints } from './renderDataPoints';
6
6
  import { renderSpecificDataPoints } from './renderSpecificDataPoints';
7
+ import { isIos } from '../../../utils';
7
8
  var RenderLineInBarChart = function (props) {
8
9
  var _a, _b;
9
10
  var yAxisLabelWidth = props.yAxisLabelWidth, initialSpacing = props.initialSpacing, spacing = props.spacing, containerHeight = props.containerHeight, lineConfig = props.lineConfig, maxValue = props.maxValue, animatedWidth = props.animatedWidth, lineBehindBars = props.lineBehindBars, points = props.points, arrowPoints = props.arrowPoints, data = props.data, totalWidth = props.totalWidth, barWidth = props.barWidth, labelsExtraHeight = props.labelsExtraHeight, xAxisLabelsVerticalShift = props.xAxisLabelsVerticalShift, selectedIndex = props.selectedIndex, containerHeightIncludingBelowXAxis = props.containerHeightIncludingBelowXAxis, yAxisOffset = props.yAxisOffset, highlightEnabled = props.highlightEnabled, lowlightOpacity = props.lowlightOpacity;
@@ -13,6 +14,7 @@ var RenderLineInBarChart = function (props) {
13
14
  ? 1
14
15
  : lowlightOpacity
15
16
  : 1;
17
+ var svgHeight = containerHeightIncludingBelowXAxis + labelsExtraHeight;
16
18
  var dataPointsProps = {
17
19
  data: data,
18
20
  lineConfig: lineConfig,
@@ -25,6 +27,8 @@ var RenderLineInBarChart = function (props) {
25
27
  selectedIndex: selectedIndex[0],
26
28
  yAxisOffset: yAxisOffset,
27
29
  opacity: opacity,
30
+ svgHeight: svgHeight,
31
+ totalWidth: totalWidth,
28
32
  };
29
33
  var specificVerticalLinesProps = {
30
34
  data: data,
@@ -49,21 +53,21 @@ var RenderLineInBarChart = function (props) {
49
53
  };
50
54
  var renderAnimatedLine = function () {
51
55
  var _a, _b, _c;
52
- return (_jsx(Animated.View, { pointerEvents: "none", style: {
56
+ return (_jsx(Animated.View, { pointerEvents: isIos ? 'none' : 'box-none', style: {
53
57
  position: 'absolute',
54
- height: containerHeightIncludingBelowXAxis + labelsExtraHeight,
58
+ height: svgHeight,
55
59
  left: 6 - yAxisLabelWidth,
56
60
  bottom: 50 + xAxisLabelsVerticalShift, //stepHeight * -0.5 + xAxisThickness,
57
61
  width: animatedWidth,
58
62
  zIndex: lineBehindBars ? -1 : 100000,
59
63
  // backgroundColor: 'wheat',
60
- }, children: _jsxs(Svg, { children: [_jsx(Path, { d: points, fill: "none", opacity: opacity, stroke: lineConfig.color, strokeWidth: lineConfig.thickness, strokeDasharray: lineConfig.strokeDashArray }), renderSpecificVerticalLines(specificVerticalLinesProps), !lineConfig.hideDataPoints
64
+ }, children: _jsxs(Svg, { pointerEvents: isIos ? 'none' : 'box-none', children: [_jsx(Path, { d: points, fill: "none", opacity: opacity, stroke: lineConfig.color, strokeWidth: lineConfig.thickness, strokeDasharray: lineConfig.strokeDashArray }), renderSpecificVerticalLines(specificVerticalLinesProps), !lineConfig.hideDataPoints
61
65
  ? renderDataPoints(dataPointsProps)
62
66
  : renderSpecificDataPoints(specificDataPointsProps), lineConfig.showArrow && (_jsx(Path, { d: arrowPoints, fill: (_a = lineConfig.arrowConfig) === null || _a === void 0 ? void 0 : _a.fillColor, stroke: (_b = lineConfig.arrowConfig) === null || _b === void 0 ? void 0 : _b.strokeColor, strokeWidth: (_c = lineConfig.arrowConfig) === null || _c === void 0 ? void 0 : _c.strokeWidth }))] }) }));
63
67
  };
64
68
  var renderLine = function () {
65
69
  var _a, _b, _c;
66
- return (_jsx(View, { pointerEvents: "none", style: {
70
+ return (_jsx(View, { pointerEvents: isIos ? 'none' : 'box-none', style: {
67
71
  position: 'absolute',
68
72
  height: containerHeightIncludingBelowXAxis + labelsExtraHeight,
69
73
  left: 6 - yAxisLabelWidth,
@@ -71,7 +75,7 @@ var RenderLineInBarChart = function (props) {
71
75
  width: totalWidth,
72
76
  zIndex: lineBehindBars ? -1 : 100000,
73
77
  // backgroundColor: 'rgba(200,150,150,0.1)'
74
- }, children: _jsxs(Svg, { children: [_jsx(Path, { d: points, fill: "none", opacity: opacity, stroke: lineConfig.color, strokeWidth: lineConfig.thickness, strokeDasharray: lineConfig.strokeDashArray }), renderSpecificVerticalLines(specificVerticalLinesProps), !lineConfig.hideDataPoints
78
+ }, children: _jsxs(Svg, { pointerEvents: isIos ? 'none' : 'box-none', children: [_jsx(Path, { d: points, fill: "none", opacity: opacity, stroke: lineConfig.color, strokeWidth: lineConfig.thickness, strokeDasharray: lineConfig.strokeDashArray }), renderSpecificVerticalLines(specificVerticalLinesProps), !lineConfig.hideDataPoints
75
79
  ? renderDataPoints(dataPointsProps)
76
80
  : renderSpecificDataPoints(specificDataPointsProps), lineConfig.showArrow && (_jsx(Path, { d: arrowPoints, fill: (_a = lineConfig.arrowConfig) === null || _a === void 0 ? void 0 : _a.fillColor, stroke: (_b = lineConfig.arrowConfig) === null || _b === void 0 ? void 0 : _b.strokeColor, strokeWidth: (_c = lineConfig.arrowConfig) === null || _c === void 0 ? void 0 : _c.strokeWidth }))] }) }));
77
81
  };
@@ -1,2 +1,2 @@
1
1
  import { DataPointProps } from 'gifted-charts-core';
2
- export declare const renderDataPoints: (props: DataPointProps) => (import("react/jsx-runtime").JSX.Element | null)[];
2
+ export declare const renderDataPoints: (props: DataPointProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,51 +1,102 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Fragment } from 'react';
1
+ var __read = (this && this.__read) || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o), r, ar = [], e;
5
+ try {
6
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
+ }
8
+ catch (error) { e = { error: error }; }
9
+ finally {
10
+ try {
11
+ if (r && !r.done && (m = i["return"])) m.call(i);
12
+ }
13
+ finally { if (e) throw e.error; }
14
+ }
15
+ return ar;
16
+ };
17
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
18
+ import { Fragment, useState } from 'react';
3
19
  import { styles } from '../../../BarChart/styles';
4
- import { View } from 'react-native';
20
+ import { TouchableOpacity, View } from 'react-native';
5
21
  import { getXForLineInBar, getYForLineInBar } from 'gifted-charts-core';
6
- import { Rect, Text as CanvasText, Circle } from 'react-native-svg';
22
+ import { Rect, Text as CanvasText, Circle, ForeignObject, } from 'react-native-svg';
23
+ import { isWebApp } from '../../../utils';
7
24
  export var renderDataPoints = function (props) {
8
- var data = props.data, lineConfig = props.lineConfig, barWidth = props.barWidth, containerHeight = props.containerHeight, maxValue = props.maxValue, firstBarWidth = props.firstBarWidth, yAxisLabelWidth = props.yAxisLabelWidth, spacing = props.spacing, selectedIndex = props.selectedIndex, yAxisOffset = props.yAxisOffset, opacity = props.opacity;
9
- return data.map(function (item, index) {
10
- var _a, _b, _c, _d, _e;
11
- if (index < lineConfig.startIndex ||
12
- index > lineConfig.endIndex ||
13
- item.hideDataPoint) {
14
- return null;
15
- }
16
- var currentBarWidth = item.barWidth || barWidth || 30;
17
- var customDataPoint = item.customDataPoint || lineConfig.customDataPoint;
18
- var dataPointColor = lineConfig.focusEnabled &&
19
- index === ((_a = lineConfig.focusedDataPointIndex) !== null && _a !== void 0 ? _a : selectedIndex)
20
- ? lineConfig.focusedDataPointColor
21
- : lineConfig.dataPointsColor;
22
- var dataPointRadius = lineConfig.focusEnabled &&
23
- index === ((_b = lineConfig.focusedDataPointIndex) !== null && _b !== void 0 ? _b : selectedIndex)
24
- ? lineConfig.focusedDataPointRadius
25
- : lineConfig.dataPointsRadius;
26
- var value = (_c = item.value) !== null && _c !== void 0 ? _c : item.stacks.reduce(function (total, item) { return total + item.value; }, 0);
27
- if (customDataPoint) {
28
- return (_jsx(View, { style: [
29
- styles.customDataPointContainer,
30
- {
31
- opacity: opacity,
32
- height: lineConfig.dataPointsHeight,
33
- width: lineConfig.dataPointsWidth,
34
- top: containerHeight -
35
- (value * containerHeight) / maxValue -
36
- ((_e = (_d = item.shiftY) !== null && _d !== void 0 ? _d : lineConfig.shiftY) !== null && _e !== void 0 ? _e : 0),
37
- left: getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing),
38
- },
39
- ], children: customDataPoint(item, index) }));
40
- }
41
- if (lineConfig.dataPointsShape === 'rectangular') {
42
- return (_jsxs(Fragment, { children: [_jsx(Rect, { x: getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing), y: getYForLineInBar(value, lineConfig.shiftY, containerHeight, maxValue, yAxisOffset) -
43
- lineConfig.dataPointsHeight / 2, width: lineConfig.dataPointsWidth, height: lineConfig.dataPointsHeight, fill: dataPointColor, opacity: opacity }), item.dataPointText && (_jsx(CanvasText, { fill: item.textColor || lineConfig.textColor, opacity: opacity, fontSize: item.textFontSize || lineConfig.textFontSize, x: getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing) + (item.textShiftX || lineConfig.textShiftX || 0), y: getYForLineInBar(value, lineConfig.shiftY, containerHeight, maxValue, yAxisOffset) -
44
- lineConfig.dataPointsHeight / 2 +
45
- (item.textShiftY || lineConfig.textShiftY || 0), children: item.dataPointText }))] }, index));
46
- }
47
- return (_jsxs(Fragment, { children: [_jsx(Circle, { cx: getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing), cy: getYForLineInBar(value, lineConfig.shiftY, containerHeight, maxValue, yAxisOffset), r: dataPointRadius, fill: dataPointColor, opacity: opacity }), item.dataPointText && (_jsx(CanvasText, { fill: item.textColor || lineConfig.textColor, opacity: opacity, fontSize: item.textFontSize || lineConfig.textFontSize, x: getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing) + (item.textShiftX || lineConfig.textShiftX || 0), y: getYForLineInBar(value, lineConfig.shiftY, containerHeight, maxValue, yAxisOffset) -
48
- lineConfig.dataPointsHeight / 2 +
49
- (item.textShiftY || lineConfig.textShiftY || 0), children: item.dataPointText }))] }, index));
50
- });
25
+ var data = props.data, lineConfig = props.lineConfig, barWidth = props.barWidth, containerHeight = props.containerHeight, maxValue = props.maxValue, firstBarWidth = props.firstBarWidth, yAxisLabelWidth = props.yAxisLabelWidth, spacing = props.spacing, selectedIndex = props.selectedIndex, yAxisOffset = props.yAxisOffset, opacity = props.opacity, svgHeight = props.svgHeight, totalWidth = props.totalWidth;
26
+ var focusEnabled = lineConfig.focusEnabled, dataPointLabelComponent = lineConfig.dataPointLabelComponent, showDataPointLabelOnFocus = lineConfig.showDataPointLabelOnFocus, focusedDataPointIndex = lineConfig.focusedDataPointIndex;
27
+ var _a = __read(useState(focusedDataPointIndex !== null && focusedDataPointIndex !== void 0 ? focusedDataPointIndex : -1), 2), selectedDataPointIndex = _a[0], setSelectedDataPointIndex = _a[1];
28
+ return (_jsxs(_Fragment, { children: [data.map(function (item, index) {
29
+ var _a, _b, _c;
30
+ if (index < lineConfig.startIndex ||
31
+ index > lineConfig.endIndex ||
32
+ item.hideDataPoint) {
33
+ return null;
34
+ }
35
+ var currentBarWidth = item.barWidth || barWidth || 30;
36
+ var customDataPoint = item.customDataPoint || lineConfig.customDataPoint;
37
+ var dataPointColor = lineConfig.focusEnabled && index === selectedDataPointIndex
38
+ ? lineConfig.focusedDataPointColor
39
+ : lineConfig.dataPointsColor;
40
+ var dataPointRadius = lineConfig.focusEnabled && index === selectedDataPointIndex
41
+ ? lineConfig.focusedDataPointRadius
42
+ : lineConfig.dataPointsRadius;
43
+ var value = (_a = item.value) !== null && _a !== void 0 ? _a : item.stacks.reduce(function (total, item) { return total + item.value; }, 0);
44
+ var x = getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing);
45
+ var y = getYForLineInBar(value, lineConfig.shiftY, containerHeight, maxValue, yAxisOffset);
46
+ if (customDataPoint) {
47
+ return (_jsx(TouchableOpacity, { style: [
48
+ styles.customDataPointContainer,
49
+ {
50
+ opacity: opacity,
51
+ height: lineConfig.dataPointsHeight,
52
+ width: lineConfig.dataPointsWidth,
53
+ top: containerHeight -
54
+ (value * containerHeight) / maxValue -
55
+ ((_c = (_b = item.shiftY) !== null && _b !== void 0 ? _b : lineConfig.shiftY) !== null && _c !== void 0 ? _c : 0),
56
+ left: getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing),
57
+ },
58
+ ], onPress: function () {
59
+ if (focusEnabled)
60
+ setSelectedDataPointIndex(index);
61
+ }, children: customDataPoint(item, index) }, index + '.' + value + 'custom'));
62
+ }
63
+ if (lineConfig.dataPointsShape === 'rectangular') {
64
+ return (_jsxs(Fragment, { children: [_jsx(Rect, { x: x, y: y - lineConfig.dataPointsHeight / 2, width: lineConfig.dataPointsWidth, height: lineConfig.dataPointsHeight, fill: dataPointColor, opacity: opacity, onPress: function () {
65
+ if (focusEnabled)
66
+ setSelectedDataPointIndex(index);
67
+ } }), item.dataPointText && (_jsx(CanvasText, { fill: item.textColor || lineConfig.textColor, opacity: opacity, fontSize: item.textFontSize || lineConfig.textFontSize, x: x + (item.textShiftX || lineConfig.textShiftX || 0), y: y -
68
+ lineConfig.dataPointsHeight / 2 +
69
+ (item.textShiftY || lineConfig.textShiftY || 0), children: item.dataPointText }))] }, index + '.' + value + 'rect'));
70
+ }
71
+ return (_jsxs(Fragment, { children: [_jsx(Circle, { cx: x, cy: y, r: dataPointRadius, fill: dataPointColor, opacity: opacity, onPress: function () {
72
+ if (focusEnabled)
73
+ setSelectedDataPointIndex(index);
74
+ } }), item.dataPointText && (_jsx(CanvasText, { fill: item.textColor || lineConfig.textColor, opacity: opacity, fontSize: item.textFontSize || lineConfig.textFontSize, x: x + (item.textShiftX || lineConfig.textShiftX || 0), y: y -
75
+ lineConfig.dataPointsHeight / 2 +
76
+ (item.textShiftY || lineConfig.textShiftY || 0), children: item.dataPointText }))] }, index + '.' + value + 'circ'));
77
+ }), dataPointLabelComponent
78
+ ? data.map(function (item, index) {
79
+ var _a;
80
+ if (index < lineConfig.startIndex ||
81
+ index > lineConfig.endIndex ||
82
+ item.hideDataPoint) {
83
+ return null;
84
+ }
85
+ var currentBarWidth = item.barWidth || barWidth || 30;
86
+ var value = (_a = item.value) !== null && _a !== void 0 ? _a : item.stacks.reduce(function (total, item) { return total + item.value; }, 0);
87
+ var x = getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing);
88
+ var y = getYForLineInBar(value, lineConfig.shiftY, containerHeight, maxValue, yAxisOffset);
89
+ if (isWebApp)
90
+ return (_jsx(ForeignObject, { height: svgHeight, width: totalWidth, x: x - 12, y: y - 24, children: showDataPointLabelOnFocus
91
+ ? selectedDataPointIndex === index
92
+ ? dataPointLabelComponent === null || dataPointLabelComponent === void 0 ? void 0 : dataPointLabelComponent(item, index)
93
+ : null
94
+ : dataPointLabelComponent === null || dataPointLabelComponent === void 0 ? void 0 : dataPointLabelComponent(item, index) }, index + '.' + value + 'label'));
95
+ return (_jsx(View, { style: { top: y - 24, left: x - 12, position: 'absolute' }, children: showDataPointLabelOnFocus
96
+ ? selectedDataPointIndex === index
97
+ ? dataPointLabelComponent === null || dataPointLabelComponent === void 0 ? void 0 : dataPointLabelComponent(item, index)
98
+ : null
99
+ : dataPointLabelComponent === null || dataPointLabelComponent === void 0 ? void 0 : dataPointLabelComponent(item, index) }, index + '.' + value + 'label'));
100
+ })
101
+ : null] }));
51
102
  };
@@ -1,9 +1,22 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { createElement as _createElement } from "react";
2
14
  import { View } from 'react-native';
3
15
  import { chartTypes } from 'gifted-charts-core';
4
16
  import { Line, Svg } from 'react-native-svg';
5
17
  var RenderVerticalLines = function (props) {
6
- var verticalLinesAr = props.verticalLinesAr, verticalLinesSpacing = props.verticalLinesSpacing, spacing = props.spacing, initialSpacing = props.initialSpacing, verticalLinesZIndex = props.verticalLinesZIndex, verticalLinesHeight = props.verticalLinesHeight, verticalLinesThickness = props.verticalLinesThickness, verticalLinesColor = props.verticalLinesColor, verticalLinesStrokeDashArray = props.verticalLinesStrokeDashArray, verticalLinesShift = props.verticalLinesShift, verticalLinesUptoDataPoint = props.verticalLinesUptoDataPoint, verticalLinesStrokeLinecap = props.verticalLinesStrokeLinecap, xAxisThickness = props.xAxisThickness, labelsExtraHeight = props.labelsExtraHeight, containerHeight = props.containerHeight, data = props.data, stackData = props.stackData, barWidth = props.barWidth, maxValue = props.maxValue, chartType = props.chartType, containerHeightIncludingBelowXAxis = props.containerHeightIncludingBelowXAxis, totalWidth = props.totalWidth, xAxisLabelsVerticalShift = props.xAxisLabelsVerticalShift;
18
+ var showVerticalLines = props.showVerticalLines, // this is the value passed by user (note that it's not the effective value that is computed by traversing through the data array and finding any item for which showVerticalLines is true)
19
+ verticalLinesAr = props.verticalLinesAr, verticalLinesSpacing = props.verticalLinesSpacing, spacing = props.spacing, initialSpacing = props.initialSpacing, verticalLinesZIndex = props.verticalLinesZIndex, verticalLinesHeight = props.verticalLinesHeight, verticalLinesThickness = props.verticalLinesThickness, verticalLinesColor = props.verticalLinesColor, verticalLinesStrokeDashArray = props.verticalLinesStrokeDashArray, verticalLinesShift = props.verticalLinesShift, verticalLinesUptoDataPoint = props.verticalLinesUptoDataPoint, verticalLinesStrokeLinecap = props.verticalLinesStrokeLinecap, xAxisThickness = props.xAxisThickness, labelsExtraHeight = props.labelsExtraHeight, containerHeight = props.containerHeight, data = props.data, stackData = props.stackData, barWidth = props.barWidth, maxValue = props.maxValue, chartType = props.chartType, containerHeightIncludingBelowXAxis = props.containerHeightIncludingBelowXAxis, totalWidth = props.totalWidth, xAxisLabelsVerticalShift = props.xAxisLabelsVerticalShift;
7
20
  var getHeightOfVerticalLine = function (index) {
8
21
  if (verticalLinesUptoDataPoint) {
9
22
  if (index < data.length) {
@@ -32,6 +45,7 @@ var RenderVerticalLines = function (props) {
32
45
  width: totalWidth,
33
46
  zIndex: verticalLinesZIndex || -1,
34
47
  }, children: _jsx(Svg, { height: containerHeightIncludingBelowXAxis, width: totalWidth, children: verticalLinesAr.map(function (item, index) {
48
+ var _a, _b, _c, _d, _e, _f;
35
49
  var totalSpacing = initialSpacing;
36
50
  if (verticalLinesSpacing) {
37
51
  totalSpacing = verticalLinesSpacing * (index + 1);
@@ -80,16 +94,40 @@ var RenderVerticalLines = function (props) {
80
94
  totalSpacing += actualSpacing;
81
95
  }
82
96
  }
83
- var x = verticalLinesShift +
97
+ if (!showVerticalLines && !item.showVerticalLine) {
98
+ return null;
99
+ }
100
+ var verticalLinesShiftLocal = chartType === chartTypes.BAR
101
+ ? ((_a = item.verticalLineShift) !== null && _a !== void 0 ? _a : verticalLinesShift)
102
+ : verticalLinesShift;
103
+ var x = verticalLinesShiftLocal +
84
104
  1 +
85
- (chartType === chartTypes.BAR
105
+ (chartType === chartTypes.BAR // This logic exists because we have renderSpecificVerticalLines in Line Charts which I would love to deprecate at the earliest, because that functionality gets handled here elegantly
86
106
  ? totalSpacing - 1
87
107
  : verticalLinesSpacing
88
108
  ? verticalLinesSpacing * (index + 1)
89
109
  : index * spacing + (initialSpacing - 2));
90
- return (_jsx(Line, { x1: x, y1: extendedContainerHeight -
110
+ var lineProps = chartType === chartTypes.BAR // This logic exists because we have renderSpecificVerticalLines in Line Charts which I would love to deprecate at the earliest, because that functionality gets handled here elegantly
111
+ ? {
112
+ y2: containerHeightIncludingBelowXAxis -
113
+ heightAdjustmentDueToStrokeLinecap,
114
+ stroke: ((_b = item.verticalLineColor) !== null && _b !== void 0 ? _b : verticalLinesColor) ||
115
+ 'lightgray',
116
+ strokeWidth: ((_c = item.verticalLineThickness) !== null && _c !== void 0 ? _c : verticalLinesThickness) || 2,
117
+ strokeDasharray: (_e = (_d = item.verticalLineStrokeDashArray) !== null && _d !== void 0 ? _d : verticalLinesStrokeDashArray) !== null && _e !== void 0 ? _e : '',
118
+ strokeLinecap: (_f = item.verticalLineStrokeLinecap) !== null && _f !== void 0 ? _f : verticalLinesStrokeLinecap,
119
+ }
120
+ : {
121
+ y2: containerHeightIncludingBelowXAxis -
122
+ heightAdjustmentDueToStrokeLinecap,
123
+ stroke: verticalLinesColor || 'lightgray',
124
+ strokeWidth: verticalLinesThickness || 2,
125
+ strokeDasharray: verticalLinesStrokeDashArray !== null && verticalLinesStrokeDashArray !== void 0 ? verticalLinesStrokeDashArray : '',
126
+ strokeLinecap: verticalLinesStrokeLinecap,
127
+ };
128
+ return (_createElement(Line, __assign({}, lineProps, { key: index, x1: x, y1: extendedContainerHeight -
91
129
  getHeightOfVerticalLine(index) +
92
- heightAdjustmentDueToStrokeLinecap, x2: x, y2: containerHeightIncludingBelowXAxis - heightAdjustmentDueToStrokeLinecap, stroke: verticalLinesColor || 'lightgray', strokeWidth: verticalLinesThickness || 2, strokeDasharray: verticalLinesStrokeDashArray !== null && verticalLinesStrokeDashArray !== void 0 ? verticalLinesStrokeDashArray : '', strokeLinecap: verticalLinesStrokeLinecap }, index));
130
+ heightAdjustmentDueToStrokeLinecap, x2: x })));
93
131
  }) }) }));
94
132
  };
95
133
  export default RenderVerticalLines;
@@ -38,7 +38,7 @@ import { createElement as _createElement } from "react";
38
38
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
39
39
  import { Fragment, useCallback, useEffect, useMemo, useRef } from 'react';
40
40
  import { View, Animated, Easing, Text, Dimensions, I18nManager, } from 'react-native';
41
- import { screenWidth, usePrevious } from '../utils';
41
+ import { isWebApp, screenWidth, usePrevious } from '../utils';
42
42
  import Svg, { Path, LinearGradient, Stop, Circle, Rect, Text as CanvasText, Line, ClipPath, Use, ForeignObject, Defs, Mask, } from 'react-native-svg';
43
43
  import { getSegmentedPathObjects, getRegionPathObjects, RANGE_ENTER, RANGE_EXIT, SEGMENT_END, SEGMENT_START, STOP, svgPath, useLineChart, adjustToOffset, LineDefaults, pointsWithPaddedRepititions, } from 'gifted-charts-core';
44
44
  import BarAndLineChartsWrapper from '../Components/BarAndLineChartsWrapper';
@@ -260,7 +260,7 @@ export var LineChart = function (props) {
260
260
  var renderDataPoints = function (hideDataPoints, dataForRender, originalDataFromProps, dataPtsShape, dataPtsWidth, dataPtsHeight, dataPtsColor, dataPtsRadius, textColor, textFontSize, startIndex, endIndex, isSecondary, showValuesAsDataPointsText, spacingArray, key) {
261
261
  var getYOrSecondaryY = isSecondary ? getSecondaryY : getY;
262
262
  return dataForRender.map(function (item, index) {
263
- var _a, _b, _c, _d, _e;
263
+ var _a, _b, _c, _d, _e, _f;
264
264
  if (index < startIndex || index > endIndex)
265
265
  return null;
266
266
  if (item.hideDataPoint) {
@@ -328,9 +328,18 @@ export var LineChart = function (props) {
328
328
  return (_jsxs(Fragment, { children: [focusEnabled ? (_jsx(_Fragment, { children: key === lastLineNumber - 1 ? (_jsx(Rect, { x: initialSpacing + (spacing * index - spacing / 2), y: 8, width: spacing, height: containerHeight - 0, fill: 'none', onPressIn: function (evt) {
329
329
  var locationY = evt.nativeEvent.locationY; // Note that we have another property named pageY which can be useful
330
330
  handleFocus(index, item, locationY, onStripPress);
331
- }, onPressOut: handleUnFocus })) : null })) : null, hideDataPoints ? null : (_jsxs(_Fragment, { children: [customDataPoint ? (_jsx(ForeignObject, { height: svgHeight, width: totalWidth, x: initialSpacing -
331
+ }, onPressOut: handleUnFocus })) : null })) : null, hideDataPoints ? null : (_jsxs(_Fragment, { children: [customDataPoint ? (isWebApp ? (_jsx(ForeignObject, { height: svgHeight, width: totalWidth, x: initialSpacing -
332
332
  dataPointsWidth / 2 +
333
- ((_e = spacingArray[index - 1]) !== null && _e !== void 0 ? _e : 0), y: getYOrSecondaryY(item.value) - dataPointsHeight / 2, children: customDataPoint(item, index) })) : null, dataPointsShape === 'rectangular' ? (_jsx(Fragment, { children: customDataPoint ? null : (_jsx(Rect, { x: getX(spacingArray, index) - dataPointsWidth / 2, y: getYOrSecondaryY(item.value) - dataPointsHeight / 2, width: dataPointsWidth, height: dataPointsHeight, fill: showDataPointOnFocus
333
+ ((_e = spacingArray[index - 1]) !== null && _e !== void 0 ? _e : 0), y: getYOrSecondaryY(item.value) - dataPointsHeight / 2, children: customDataPoint(item, index) })) : (_jsx(Animated.View, { style: {
334
+ position: 'absolute',
335
+ // height: svgHeight,
336
+ // width: totalWidth,
337
+ left: initialSpacing -
338
+ dataPointsWidth / 2 +
339
+ ((_f = spacingArray[index - 1]) !== null && _f !== void 0 ? _f : 0),
340
+ top: getYOrSecondaryY(item.value) - dataPointsHeight / 2,
341
+ opacity: isAnimated ? appearingOpacity : 1,
342
+ }, children: customDataPoint(item, index) }))) : null, dataPointsShape === 'rectangular' ? (_jsx(Fragment, { children: customDataPoint ? null : (_jsx(Rect, { x: getX(spacingArray, index) - dataPointsWidth / 2, y: getYOrSecondaryY(item.value) - dataPointsHeight / 2, width: dataPointsWidth, height: dataPointsHeight, fill: showDataPointOnFocus
334
343
  ? index === selectedIndex
335
344
  ? dataPointsColor
336
345
  : 'none'
@@ -362,7 +371,7 @@ export var LineChart = function (props) {
362
371
  if (!item.onPress && !props.onPress && focusEnabled) {
363
372
  handleUnFocus();
364
373
  }
365
- } })) }, index)), dataPointLabelComponent ? (!showTextOnFocus || index === selectedIndex ? (_jsx(ForeignObject, { height: svgHeight, width: dataPointLabelWidth, x: initialSpacing +
374
+ } })) }, index)), dataPointLabelComponent ? (!showTextOnFocus || index === selectedIndex ? (isWebApp ? (_jsx(ForeignObject, { height: svgHeight, width: dataPointLabelWidth, x: initialSpacing +
366
375
  (item.dataPointLabelShiftX ||
367
376
  props.dataPointLabelShiftX ||
368
377
  0) -
@@ -376,7 +385,27 @@ export var LineChart = function (props) {
376
385
  (focusTogether || key == selectedLineNumber)
377
386
  ? dataPointLabelComponent(item, index) // not pushed in latest release
378
387
  : null
379
- : dataPointLabelComponent(item, index) })) : null) : text || item.dataPointText ? (!showTextOnFocus || index === selectedIndex ? (_jsx(CanvasText, { fill: item.textColor || textColor, fontSize: item.textFontSize || textFontSize, x: getX(spacingArray, index) -
388
+ : dataPointLabelComponent(item, index) })) : (_jsx(View, { style: {
389
+ position: 'absolute',
390
+ height: svgHeight,
391
+ width: dataPointLabelWidth,
392
+ left: initialSpacing +
393
+ (item.dataPointLabelShiftX ||
394
+ props.dataPointLabelShiftX ||
395
+ 0) -
396
+ dataPointLabelWidth / 2 +
397
+ spacing * index,
398
+ top: containerHeight +
399
+ (item.dataPointLabelShiftY ||
400
+ props.dataPointLabelShiftY ||
401
+ 0) -
402
+ (item.value * containerHeight) / maxValue,
403
+ }, children: showDataPointLabelOnFocus
404
+ ? index === selectedIndex &&
405
+ (focusTogether || key == selectedLineNumber)
406
+ ? dataPointLabelComponent(item, index) // not pushed in latest release
407
+ : null
408
+ : dataPointLabelComponent(item, index) }))) : null) : text || item.dataPointText ? (!showTextOnFocus || index === selectedIndex ? (_jsx(CanvasText, { fill: item.textColor || textColor, fontSize: item.textFontSize || textFontSize, x: getX(spacingArray, index) -
380
409
  dataPointsWidth +
381
410
  (item.textShiftX || props.textShiftX || 0), y: getYOrSecondaryY(item.value) -
382
411
  dataPointsHeight / 2 +
@@ -1,2 +1,2 @@
1
1
  import { PieChartPropsType } from 'gifted-charts-core';
2
- export declare const PieChart: (props: PieChartPropsType) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const PieChart: (props: PieChartPropsType) => import("react/jsx-runtime").JSX.Element | null;
@@ -32,6 +32,8 @@ import { pieColors, usePieChart } from 'gifted-charts-core';
32
32
  import { isWebApp } from '../utils';
33
33
  import { useState } from 'react';
34
34
  export var PieChart = function (props) {
35
+ if (!props.data)
36
+ return null;
35
37
  var _a = usePieChart(props), radius = _a.radius, extraRadius = _a.extraRadius, selectedIndex = _a.selectedIndex, setSelectedIndex = _a.setSelectedIndex, startAngle = _a.startAngle, total = _a.total, donut = _a.donut, isThreeD = _a.isThreeD, semiCircle = _a.semiCircle, inwardExtraLengthForFocused = _a.inwardExtraLengthForFocused, canvasWidth = _a.canvasWidth, canvasHeight = _a.canvasHeight, innerRadius = _a.innerRadius, innerCircleColor = _a.innerCircleColor, innerCircleBorderWidth = _a.innerCircleBorderWidth, innerCircleBorderColor = _a.innerCircleBorderColor, shiftInnerCenterX = _a.shiftInnerCenterX, shiftInnerCenterY = _a.shiftInnerCenterY, tiltAngle = _a.tiltAngle, isDataShifted = _a.isDataShifted, paddingHorizontal = _a.paddingHorizontal, paddingVertical = _a.paddingVertical, data = _a.data, showTooltip = _a.showTooltip, tooltipHorizontalShift = _a.tooltipHorizontalShift, tooltipVerticalShift = _a.tooltipVerticalShift, tooltipComponent = _a.tooltipComponent, getTooltipText = _a.getTooltipText, tooltipBackgroundColor = _a.tooltipBackgroundColor, tooltipBorderRadius = _a.tooltipBorderRadius, tooltipWidth = _a.tooltipWidth, tooltipTextNoOfLines = _a.tooltipTextNoOfLines, textColor = _a.textColor, textSize = _a.textSize, font = _a.font, fontWeight = _a.fontWeight, fontStyle = _a.fontStyle, tooltipSelectedIndex = _a.tooltipSelectedIndex, setTooltipSelectedIndex = _a.setTooltipSelectedIndex;
36
38
  var _b = __read(useState(0), 2), touchX = _b[0], setTouchX = _b[1];
37
39
  var _c = __read(useState(0), 2), touchY = _c[0], setTouchY = _c[1];
@@ -117,7 +119,6 @@ export var PieChart = function (props) {
117
119
  fontStyle: fontStyle,
118
120
  }, children: getTooltipText(tooltipSelectedIndex) }) })) }));
119
121
  };
120
- // if (!total) return null;
121
122
  return (_jsxs(View, { style: {
122
123
  height: (radius + extraRadius + paddingVertical / 2) *
123
124
  (props.semiCircle ? 1 : 2),
@@ -21,13 +21,14 @@ import Svg, { Path, Circle, Text as SvgText, Defs, RadialGradient, Stop, G, Line
21
21
  import { getPieChartMainProps, pieColors, } from 'gifted-charts-core';
22
22
  import { isWebApp, rnVersion } from '../utils';
23
23
  export var PieChartMain = function (props) {
24
- var _a = getPieChartMainProps(props), isThreeD = _a.isThreeD, isBiggerPie = _a.isBiggerPie, data = _a.data, showInnerComponent = _a.showInnerComponent, radius = _a.radius, canvasWidth = _a.canvasWidth, canvasHeight = _a.canvasHeight, shadowWidth = _a.shadowWidth, backgroundColor = _a.backgroundColor, shadowColor = _a.shadowColor, semiCircle = _a.semiCircle, pi = _a.pi, initialAngle = _a.initialAngle, shadow = _a.shadow, donut = _a.donut, strokeWidth = _a.strokeWidth, strokeColor = _a.strokeColor, innerRadius = _a.innerRadius, showText = _a.showText, textColor = _a.textColor, textSize = _a.textSize, tiltAngle = _a.tiltAngle, labelsPosition = _a.labelsPosition, showTextBackground = _a.showTextBackground, textBackgroundColor = _a.textBackgroundColor, showValuesAsLabels = _a.showValuesAsLabels, showGradient = _a.showGradient, gradientCenterColor = _a.gradientCenterColor, minShiftX = _a.minShiftX, minShiftY = _a.minShiftY, total = _a.total, horizAdjustment = _a.horizAdjustment, vertAdjustment = _a.vertAdjustment, cx = _a.cx, cy = _a.cy, mData = _a.mData, paddingHorizontal = _a.paddingHorizontal, paddingVertical = _a.paddingVertical, extraRadius = _a.extraRadius, showExternalLabels = _a.showExternalLabels, getExternaLabelProperties = _a.getExternaLabelProperties, coordinates = _a.coordinates, onPressed = _a.onPressed, font = _a.font, fontWeight = _a.fontWeight, fontStyle = _a.fontStyle, edgesPressable = _a.edgesPressable;
24
+ var _a;
25
+ var _b = getPieChartMainProps(props), isThreeD = _b.isThreeD, isBiggerPie = _b.isBiggerPie, data = _b.data, showInnerComponent = _b.showInnerComponent, radius = _b.radius, canvasWidth = _b.canvasWidth, canvasHeight = _b.canvasHeight, shadowWidth = _b.shadowWidth, backgroundColor = _b.backgroundColor, shadowColor = _b.shadowColor, semiCircle = _b.semiCircle, pi = _b.pi, initialAngle = _b.initialAngle, shadow = _b.shadow, donut = _b.donut, strokeWidth = _b.strokeWidth, strokeColor = _b.strokeColor, innerRadius = _b.innerRadius, showText = _b.showText, textColor = _b.textColor, textSize = _b.textSize, tiltAngle = _b.tiltAngle, labelsPosition = _b.labelsPosition, showTextBackground = _b.showTextBackground, textBackgroundColor = _b.textBackgroundColor, showValuesAsLabels = _b.showValuesAsLabels, showGradient = _b.showGradient, gradientCenterColor = _b.gradientCenterColor, minShiftX = _b.minShiftX, minShiftY = _b.minShiftY, total = _b.total, horizAdjustment = _b.horizAdjustment, vertAdjustment = _b.vertAdjustment, cx = _b.cx, cy = _b.cy, mData = _b.mData, paddingHorizontal = _b.paddingHorizontal, paddingVertical = _b.paddingVertical, extraRadius = _b.extraRadius, showExternalLabels = _b.showExternalLabels, getExternaLabelProperties = _b.getExternaLabelProperties, coordinates = _b.coordinates, onPressed = _b.onPressed, font = _b.font, fontWeight = _b.fontWeight, fontStyle = _b.fontStyle, edgesPressable = _b.edgesPressable;
25
26
  var setTouchX = props.setTouchX, setTouchY = props.setTouchY;
26
27
  var prevSide = 'right';
27
28
  var prevLabelComponentX = 0;
28
29
  var wasFirstItemOnPole = false;
29
- var _b = __read(useState(0), 2), top = _b[0], setTop = _b[1];
30
- var _c = __read(useState(0), 2), left = _c[0], setLeft = _c[1];
30
+ var _c = __read(useState(0), 2), top = _c[0], setTop = _c[1];
31
+ var _d = __read(useState(0), 2), left = _d[0], setLeft = _d[1];
31
32
  var onPressHandler = function (e) {
32
33
  var x = 0, y = 0;
33
34
  if (isWebApp) {
@@ -88,9 +89,9 @@ export var PieChartMain = function (props) {
88
89
  vertAdjustment +
89
90
  (vertAdjustment ? strokeWidth : 0)), height: (radius + extraRadius) * 2 + strokeWidth + paddingVertical, width: (radius + extraRadius) * 2 + strokeWidth + paddingHorizontal, children: [_jsx(Defs, { children: data.map(function (item, index) {
90
91
  return (_jsxs(RadialGradient, { id: 'grad' + index, cx: "50%", cy: "50%", rx: "50%", ry: "50%", fx: "50%", fy: "50%", gradientUnits: "userSpaceOnUse", children: [_jsx(Stop, { offset: "0%", stopColor: item.gradientCenterColor || gradientCenterColor, stopOpacity: "1" }), _jsx(Stop, { offset: "100%", stopColor: item.color || pieColors[index % 9], stopOpacity: "1" })] }, index + ''));
91
- }) }), (data.length === 1 || !total) ? (_jsx(_Fragment, { children: _jsx(Circle, { cx: cx, cy: cy, r: radius, fill: showGradient
92
+ }) }), data.length === 1 || !total ? (_jsx(_Fragment, { children: _jsx(Circle, { cx: cx, cy: cy, r: radius, fill: showGradient
92
93
  ? "url(#grad".concat(0, ")")
93
- : data[0].color || pieColors[0 % 9] }) })) : (data.map(function (item, index) {
94
+ : ((_a = data[0]) === null || _a === void 0 ? void 0 : _a.color) || pieColors[0 % 9] }) })) : (data.map(function (item, index) {
94
95
  var _a = coordinates[index], sx = _a.sx, sy = _a.sy, ax = _a.ax, ay = _a.ay;
95
96
  if (isBiggerPie && index)
96
97
  return null;
@@ -2,3 +2,4 @@ export declare const rnVersion: number;
2
2
  export declare const screenWidth: number;
3
3
  export declare function usePrevious(value: string): string;
4
4
  export declare const isWebApp: boolean;
5
+ export declare const isIos: boolean;
@@ -19,3 +19,4 @@ export function usePrevious(value) {
19
19
  return ref.current; //in the end, return the current ref value.
20
20
  }
21
21
  export var isWebApp = Platform.OS === 'web';
22
+ export var isIos = Platform.OS === 'ios';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gifted-charts",
3
- "version": "1.4.67",
3
+ "version": "1.4.69",
4
4
  "description": "The most complete library for Bar, Line, Area, Pie, Donut, Stacked Bar, Population Pyramid and Radar charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -26,7 +26,7 @@
26
26
  "registry": "https://registry.npmjs.org/"
27
27
  },
28
28
  "dependencies": {
29
- "gifted-charts-core": "0.1.69"
29
+ "gifted-charts-core": "0.1.71"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@babel/cli": "^7.24.8",