react-native-gifted-charts 1.4.68 → 1.4.70
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/dist/BarChart/RenderStackBars.js +2 -2
- package/dist/BarChart/index.js +7 -1
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/index.js +9 -5
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.d.ts +1 -1
- package/dist/Components/BarAndLineChartsWrapper/renderLineInBarChart/renderDataPoints.js +80 -46
- package/dist/Components/Rotatable.d.ts +9 -0
- package/dist/Components/Rotatable.js +132 -0
- package/dist/LineChart/index.js +39 -6
- package/dist/PieChart/index.d.ts +1 -1
- package/dist/PieChart/index.js +34 -26
- package/dist/PieChart/main.js +11 -9
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +2 -2
|
@@ -22,7 +22,7 @@ var RenderStackBars = function (props) {
|
|
|
22
22
|
var _e = useRenderStackBars(__assign(__assign({}, props), { secondaryStepHeight: secondaryStepHeight, secondaryStepValue: secondaryStepValue, secondaryNegativeStepHeight: secondaryNegativeStepHeight, secondaryNegativeStepValue: secondaryNegativeStepValue })), containsNegativeValue = _e.containsNegativeValue, noAnimation = _e.noAnimation, localBarInnerComponent = _e.localBarInnerComponent, borderRadius = _e.borderRadius, borderTopLeftRadius = _e.borderTopLeftRadius, borderTopRightRadius = _e.borderTopRightRadius, borderBottomLeftRadius = _e.borderBottomLeftRadius, borderBottomRightRadius = _e.borderBottomRightRadius, disablePress = _e.disablePress, totalHeight = _e.totalHeight, height = _e.height, setHeight = _e.setHeight, getBarHeight = _e.getBarHeight, getPosition = _e.getPosition, lowestBarPosition = _e.lowestBarPosition, getStackBorderRadii = _e.getStackBorderRadii, tooltipProps = _e.tooltipProps;
|
|
23
23
|
var renderLabel = function (label, labelTextStyle) {
|
|
24
24
|
return (_jsx(TouchableOpacity, { disabled: disablePress || (stackHighlightEnabled && !highlightEnabled), activeOpacity: activeOpacity, onPress: function () {
|
|
25
|
-
setSelectedIndex(index);
|
|
25
|
+
setSelectedIndex([index]);
|
|
26
26
|
if (item.onPress) {
|
|
27
27
|
item.onPress();
|
|
28
28
|
}
|
|
@@ -84,7 +84,7 @@ var RenderStackBars = function (props) {
|
|
|
84
84
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
85
85
|
var remainingBarMarginBottom = barMarginBottom;
|
|
86
86
|
return (_jsxs(_Fragment, { children: [_jsxs(TouchableOpacity, { disabled: disablePress || (stackHighlightEnabled && !highlightEnabled), activeOpacity: activeOpacity, onPress: function () {
|
|
87
|
-
setSelectedIndex(index);
|
|
87
|
+
setSelectedIndex([index]);
|
|
88
88
|
if (item.onPress) {
|
|
89
89
|
item.onPress();
|
|
90
90
|
}
|
package/dist/BarChart/index.js
CHANGED
|
@@ -47,7 +47,7 @@ export var BarChart = function (props) {
|
|
|
47
47
|
bounces: props.bounces,
|
|
48
48
|
overScrollMode: (_b = props.overScrollMode) !== null && _b !== void 0 ? _b : 'auto',
|
|
49
49
|
};
|
|
50
|
-
var _d = useBarChart(__assign(__assign({}, props), { heightValue: heightValue, widthValue: widthValue, opacityValue: opacityValue, parentWidth: (_c = props.parentWidth) !== null && _c !== void 0 ? _c : screenWidth })), lineConfig = _d.lineConfig, hidePointer1 = _d.hidePointer1, pointerItem = _d.pointerItem, pointerY = _d.pointerY, pointerConfig = _d.pointerConfig, pointerColor = _d.pointerColor, pointerX = _d.pointerX, pointerComponent = _d.pointerComponent, pointerHeight = _d.pointerHeight, pointerRadius = _d.pointerRadius, pointerWidth = _d.pointerWidth, autoAdjustPointerLabelPosition = _d.autoAdjustPointerLabelPosition, pointerLabelWidth = _d.pointerLabelWidth, activatePointersOnLongPress = _d.activatePointersOnLongPress, yAxisLabelWidth = _d.yAxisLabelWidth, shiftPointerLabelX = _d.shiftPointerLabelX, pointerLabelHeight = _d.pointerLabelHeight, pointerStripUptoDataPoint = _d.pointerStripUptoDataPoint, pointerStripHeight = _d.pointerStripHeight, shiftPointerLabelY = _d.shiftPointerLabelY, showPointerStrip = _d.showPointerStrip, pointerStripWidth = _d.pointerStripWidth, containerHeight = _d.containerHeight, xAxisThickness = _d.xAxisThickness, pointerStripColor = _d.pointerStripColor, pointerEvents = _d.pointerEvents, setResponderStartTime = _d.setResponderStartTime, setPointerY = _d.setPointerY, setPointerItem = _d.setPointerItem, initialSpacing = _d.initialSpacing, spacing = _d.spacing, data = _d.data, barWidth = _d.barWidth, setPointerX = _d.setPointerX, pointerIndex = _d.pointerIndex, setPointerIndex = _d.setPointerIndex, maxValue = _d.maxValue, responderStartTime = _d.responderStartTime, setResponderActive = _d.setResponderActive, activatePointersDelay = _d.activatePointersDelay, persistPointer = _d.persistPointer, pointerVanishDelay = _d.pointerVanishDelay, containerHeightIncludingBelowXAxis = _d.containerHeightIncludingBelowXAxis, extendedContainerHeight = _d.extendedContainerHeight, totalWidth = _d.totalWidth, stripBehindBars = _d.stripBehindBars, noOfSectionsBelowXAxis = _d.noOfSectionsBelowXAxis, stepHeight = _d.stepHeight, xAxisLabelsVerticalShift = _d.xAxisLabelsVerticalShift, labelsExtraHeight = _d.labelsExtraHeight, stripOverPointer = _d.stripOverPointer, pointerLabelComponent = _d.pointerLabelComponent, selectedIndex = _d.selectedIndex, setSelectedIndex = _d.setSelectedIndex, selectedStackIndex = _d.selectedStackIndex, setSelectedStackIndex = _d.setSelectedStackIndex, isAnimated = _d.isAnimated, animationDuration = _d.animationDuration, side = _d.side, labelWidth = _d.labelWidth, isThreeD = _d.isThreeD, animatedHeight = _d.animatedHeight, appearingOpacity = _d.appearingOpacity, autoShiftLabels = _d.autoShiftLabels, getPropsCommonForBarAndStack = _d.getPropsCommonForBarAndStack, barAndLineChartsWrapperProps = _d.barAndLineChartsWrapperProps, autoShiftLabelsForNegativeStacks = _d.autoShiftLabelsForNegativeStacks, showLine = _d.showLine, points2 = _d.points2;
|
|
50
|
+
var _d = useBarChart(__assign(__assign({}, props), { heightValue: heightValue, widthValue: widthValue, opacityValue: opacityValue, parentWidth: (_c = props.parentWidth) !== null && _c !== void 0 ? _c : screenWidth })), lineConfig = _d.lineConfig, lineConfig2 = _d.lineConfig2, hidePointer1 = _d.hidePointer1, pointerItem = _d.pointerItem, pointerY = _d.pointerY, pointerConfig = _d.pointerConfig, pointerColor = _d.pointerColor, pointerX = _d.pointerX, pointerComponent = _d.pointerComponent, pointerHeight = _d.pointerHeight, pointerRadius = _d.pointerRadius, pointerWidth = _d.pointerWidth, autoAdjustPointerLabelPosition = _d.autoAdjustPointerLabelPosition, pointerLabelWidth = _d.pointerLabelWidth, activatePointersOnLongPress = _d.activatePointersOnLongPress, yAxisLabelWidth = _d.yAxisLabelWidth, shiftPointerLabelX = _d.shiftPointerLabelX, pointerLabelHeight = _d.pointerLabelHeight, pointerStripUptoDataPoint = _d.pointerStripUptoDataPoint, pointerStripHeight = _d.pointerStripHeight, shiftPointerLabelY = _d.shiftPointerLabelY, showPointerStrip = _d.showPointerStrip, pointerStripWidth = _d.pointerStripWidth, containerHeight = _d.containerHeight, xAxisThickness = _d.xAxisThickness, pointerStripColor = _d.pointerStripColor, pointerEvents = _d.pointerEvents, setResponderStartTime = _d.setResponderStartTime, setPointerY = _d.setPointerY, setPointerItem = _d.setPointerItem, initialSpacing = _d.initialSpacing, spacing = _d.spacing, data = _d.data, barWidth = _d.barWidth, setPointerX = _d.setPointerX, pointerIndex = _d.pointerIndex, setPointerIndex = _d.setPointerIndex, maxValue = _d.maxValue, responderStartTime = _d.responderStartTime, setResponderActive = _d.setResponderActive, activatePointersDelay = _d.activatePointersDelay, persistPointer = _d.persistPointer, pointerVanishDelay = _d.pointerVanishDelay, containerHeightIncludingBelowXAxis = _d.containerHeightIncludingBelowXAxis, extendedContainerHeight = _d.extendedContainerHeight, totalWidth = _d.totalWidth, stripBehindBars = _d.stripBehindBars, noOfSectionsBelowXAxis = _d.noOfSectionsBelowXAxis, stepHeight = _d.stepHeight, xAxisLabelsVerticalShift = _d.xAxisLabelsVerticalShift, labelsExtraHeight = _d.labelsExtraHeight, stripOverPointer = _d.stripOverPointer, pointerLabelComponent = _d.pointerLabelComponent, selectedIndex = _d.selectedIndex, setSelectedIndex = _d.setSelectedIndex, selectedStackIndex = _d.selectedStackIndex, setSelectedStackIndex = _d.setSelectedStackIndex, isAnimated = _d.isAnimated, animationDuration = _d.animationDuration, side = _d.side, labelWidth = _d.labelWidth, isThreeD = _d.isThreeD, animatedHeight = _d.animatedHeight, appearingOpacity = _d.appearingOpacity, autoShiftLabels = _d.autoShiftLabels, getPropsCommonForBarAndStack = _d.getPropsCommonForBarAndStack, barAndLineChartsWrapperProps = _d.barAndLineChartsWrapperProps, autoShiftLabelsForNegativeStacks = _d.autoShiftLabelsForNegativeStacks, showLine = _d.showLine, points2 = _d.points2;
|
|
51
51
|
var _e = useBarAndLineChartsWrapper(__assign(__assign({}, barAndLineChartsWrapperProps), { isRTL: I18nManager.isRTL })), lineInBarChartProps = _e.lineInBarChartProps, lineInBarChartProps2 = _e.lineInBarChartProps2;
|
|
52
52
|
var stackData = barAndLineChartsWrapperProps.stackData;
|
|
53
53
|
var labelsAppear = useCallback(function () {
|
|
@@ -228,6 +228,12 @@ export var BarChart = function (props) {
|
|
|
228
228
|
setSelectedStackIndex(-1);
|
|
229
229
|
// props.setHighlightedStackIndex?.(-1)
|
|
230
230
|
}
|
|
231
|
+
if (lineConfig.focusEnabled) {
|
|
232
|
+
lineConfig.setFocusedDataPointIndex(-1);
|
|
233
|
+
}
|
|
234
|
+
if (lineConfig2.focusEnabled) {
|
|
235
|
+
lineConfig2.setFocusedDataPointIndex(-1);
|
|
236
|
+
}
|
|
231
237
|
(_b = props.onBackgroundPress) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
232
238
|
}, children: [renderChart(),
|
|
233
239
|
// Only For Bar Charts-
|
|
@@ -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:
|
|
56
|
+
return (_jsx(Animated.View, { pointerEvents: isIos ? 'none' : 'box-none', style: {
|
|
53
57
|
position: 'absolute',
|
|
54
|
-
height:
|
|
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:
|
|
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) =>
|
|
2
|
+
export declare const renderDataPoints: (props: DataPointProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,51 +1,85 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment } from 'react';
|
|
3
3
|
import { styles } from '../../../BarChart/styles';
|
|
4
|
-
import { View } from 'react-native';
|
|
4
|
+
import { TouchableOpacity, View } from 'react-native';
|
|
5
5
|
import { getXForLineInBar, getYForLineInBar } from 'gifted-charts-core';
|
|
6
|
-
import { Rect, Text as CanvasText, Circle } from 'react-native-svg';
|
|
6
|
+
import { Rect, Text as CanvasText, Circle, ForeignObject, } from 'react-native-svg';
|
|
7
|
+
import { isWebApp } from '../../../utils';
|
|
7
8
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
9
|
+
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;
|
|
10
|
+
var focusEnabled = lineConfig.focusEnabled, dataPointLabelComponent = lineConfig.dataPointLabelComponent, showDataPointLabelOnFocus = lineConfig.showDataPointLabelOnFocus, focusedDataPointIndex = lineConfig.focusedDataPointIndex, setFocusedDataPointIndex = lineConfig.setFocusedDataPointIndex;
|
|
11
|
+
return (_jsxs(_Fragment, { children: [data.map(function (item, index) {
|
|
12
|
+
var _a, _b, _c;
|
|
13
|
+
if (index < lineConfig.startIndex ||
|
|
14
|
+
index > lineConfig.endIndex ||
|
|
15
|
+
item.hideDataPoint) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
var currentBarWidth = item.barWidth || barWidth || 30;
|
|
19
|
+
var customDataPoint = item.customDataPoint || lineConfig.customDataPoint;
|
|
20
|
+
var dataPointColor = lineConfig.focusEnabled && index === focusedDataPointIndex
|
|
21
|
+
? lineConfig.focusedDataPointColor
|
|
22
|
+
: lineConfig.dataPointsColor;
|
|
23
|
+
var dataPointRadius = lineConfig.focusEnabled && index === focusedDataPointIndex
|
|
24
|
+
? lineConfig.focusedDataPointRadius
|
|
25
|
+
: lineConfig.dataPointsRadius;
|
|
26
|
+
var value = (_a = item.value) !== null && _a !== void 0 ? _a : item.stacks.reduce(function (total, item) { return total + item.value; }, 0);
|
|
27
|
+
var x = getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing);
|
|
28
|
+
var y = getYForLineInBar(value, lineConfig.shiftY, containerHeight, maxValue, yAxisOffset);
|
|
29
|
+
if (customDataPoint) {
|
|
30
|
+
return (_jsx(TouchableOpacity, { style: [
|
|
31
|
+
styles.customDataPointContainer,
|
|
32
|
+
{
|
|
33
|
+
opacity: opacity,
|
|
34
|
+
height: lineConfig.dataPointsHeight,
|
|
35
|
+
width: lineConfig.dataPointsWidth,
|
|
36
|
+
top: containerHeight -
|
|
37
|
+
(value * containerHeight) / maxValue -
|
|
38
|
+
((_c = (_b = item.shiftY) !== null && _b !== void 0 ? _b : lineConfig.shiftY) !== null && _c !== void 0 ? _c : 0),
|
|
39
|
+
left: getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing),
|
|
40
|
+
},
|
|
41
|
+
], onPress: function () {
|
|
42
|
+
if (focusEnabled)
|
|
43
|
+
setFocusedDataPointIndex(index);
|
|
44
|
+
}, children: customDataPoint(item, index) }, index + '.' + value + 'custom'));
|
|
45
|
+
}
|
|
46
|
+
if (lineConfig.dataPointsShape === 'rectangular') {
|
|
47
|
+
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 () {
|
|
48
|
+
if (focusEnabled)
|
|
49
|
+
setFocusedDataPointIndex(index);
|
|
50
|
+
} }), 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 -
|
|
51
|
+
lineConfig.dataPointsHeight / 2 +
|
|
52
|
+
(item.textShiftY || lineConfig.textShiftY || 0), children: item.dataPointText }))] }, index + '.' + value + 'rect'));
|
|
53
|
+
}
|
|
54
|
+
return (_jsxs(Fragment, { children: [_jsx(Circle, { cx: x, cy: y, r: dataPointRadius, fill: dataPointColor, opacity: opacity, onPress: function () {
|
|
55
|
+
if (focusEnabled)
|
|
56
|
+
setFocusedDataPointIndex(index);
|
|
57
|
+
} }), 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 -
|
|
58
|
+
lineConfig.dataPointsHeight / 2 +
|
|
59
|
+
(item.textShiftY || lineConfig.textShiftY || 0), children: item.dataPointText }))] }, index + '.' + value + 'circ'));
|
|
60
|
+
}), dataPointLabelComponent
|
|
61
|
+
? data.map(function (item, index) {
|
|
62
|
+
var _a;
|
|
63
|
+
if (index < lineConfig.startIndex ||
|
|
64
|
+
index > lineConfig.endIndex ||
|
|
65
|
+
item.hideDataPoint) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
var currentBarWidth = item.barWidth || barWidth || 30;
|
|
69
|
+
var value = (_a = item.value) !== null && _a !== void 0 ? _a : item.stacks.reduce(function (total, item) { return total + item.value; }, 0);
|
|
70
|
+
var x = getXForLineInBar(index, firstBarWidth, currentBarWidth, yAxisLabelWidth, lineConfig, spacing);
|
|
71
|
+
var y = getYForLineInBar(value, lineConfig.shiftY, containerHeight, maxValue, yAxisOffset);
|
|
72
|
+
if (isWebApp)
|
|
73
|
+
return (_jsx(ForeignObject, { height: svgHeight, width: totalWidth, x: x - 12, y: y - 24, children: showDataPointLabelOnFocus
|
|
74
|
+
? focusedDataPointIndex === index
|
|
75
|
+
? dataPointLabelComponent === null || dataPointLabelComponent === void 0 ? void 0 : dataPointLabelComponent(item, index)
|
|
76
|
+
: null
|
|
77
|
+
: dataPointLabelComponent === null || dataPointLabelComponent === void 0 ? void 0 : dataPointLabelComponent(item, index) }, index + '.' + value + 'label'));
|
|
78
|
+
return (_jsx(View, { style: { top: y - 24, left: x - 12, position: 'absolute' }, children: showDataPointLabelOnFocus
|
|
79
|
+
? focusedDataPointIndex === index
|
|
80
|
+
? dataPointLabelComponent === null || dataPointLabelComponent === void 0 ? void 0 : dataPointLabelComponent(item, index)
|
|
81
|
+
: null
|
|
82
|
+
: dataPointLabelComponent === null || dataPointLabelComponent === void 0 ? void 0 : dataPointLabelComponent(item, index) }, index + '.' + value + 'label'));
|
|
83
|
+
})
|
|
84
|
+
: null] }));
|
|
51
85
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type RotatablePieProps = {
|
|
3
|
+
initialAngle: number;
|
|
4
|
+
size: number;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
onAngleChange?: (angle: number) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare function RotatablePie({ initialAngle, size, children, onAngleChange, }: RotatablePieProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
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
|
+
};
|
|
12
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
+
if (!m) return o;
|
|
15
|
+
var i = m.call(o), r, ar = [], e;
|
|
16
|
+
try {
|
|
17
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
+
}
|
|
19
|
+
catch (error) { e = { error: error }; }
|
|
20
|
+
finally {
|
|
21
|
+
try {
|
|
22
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
+
}
|
|
24
|
+
finally { if (e) throw e.error; }
|
|
25
|
+
}
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
29
|
+
import { useRef, useState, useEffect } from 'react';
|
|
30
|
+
import { View, PanResponder, Animated, StyleSheet, } from 'react-native';
|
|
31
|
+
// ----------------------------------------
|
|
32
|
+
// Ultra-smooth animation helper
|
|
33
|
+
// Throttles to ~60 FPS AND applies low-pass filtering
|
|
34
|
+
// ----------------------------------------
|
|
35
|
+
function createSmoothUpdater(animatedValue, smoothing, fps) {
|
|
36
|
+
if (smoothing === void 0) { smoothing = 0.15; }
|
|
37
|
+
if (fps === void 0) { fps = 60; }
|
|
38
|
+
var frameDelay = 1000 / fps;
|
|
39
|
+
var lastTime = 0;
|
|
40
|
+
var filtered = 0; // low-pass output
|
|
41
|
+
var timeout = null;
|
|
42
|
+
return function (target) {
|
|
43
|
+
var now = Date.now();
|
|
44
|
+
var diff = now - lastTime;
|
|
45
|
+
var update = function () {
|
|
46
|
+
// low-pass filter (natural smoothing)
|
|
47
|
+
filtered = filtered * (1 - smoothing) + target * smoothing;
|
|
48
|
+
animatedValue.setValue(filtered);
|
|
49
|
+
};
|
|
50
|
+
if (diff >= frameDelay) {
|
|
51
|
+
lastTime = now;
|
|
52
|
+
update();
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
clearTimeout(timeout);
|
|
56
|
+
timeout = setTimeout(function () {
|
|
57
|
+
lastTime = Date.now();
|
|
58
|
+
update();
|
|
59
|
+
}, frameDelay - diff);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export function RotatablePie(_a) {
|
|
64
|
+
var initialAngle = _a.initialAngle, size = _a.size, children = _a.children, onAngleChange = _a.onAngleChange;
|
|
65
|
+
var angle = useRef(new Animated.Value(initialAngle)).current;
|
|
66
|
+
var _b = __read(useState({ x: size / 2, y: size / 2 }), 2), center = _b[0], setCenter = _b[1];
|
|
67
|
+
var gestureStartAngle = useRef(0);
|
|
68
|
+
var startAngle = useRef(initialAngle);
|
|
69
|
+
// Create smooth updater ONCE
|
|
70
|
+
var smoothSetAngle = useRef(createSmoothUpdater(angle, 0.15, 60)).current;
|
|
71
|
+
useEffect(function () {
|
|
72
|
+
angle.setValue(initialAngle);
|
|
73
|
+
startAngle.current = initialAngle;
|
|
74
|
+
}, [initialAngle, angle]);
|
|
75
|
+
useEffect(function () {
|
|
76
|
+
var id = angle.addListener(function (_a) {
|
|
77
|
+
var value = _a.value;
|
|
78
|
+
return onAngleChange === null || onAngleChange === void 0 ? void 0 : onAngleChange(value);
|
|
79
|
+
});
|
|
80
|
+
return function () { return angle.removeListener(id); };
|
|
81
|
+
}, [angle, onAngleChange]);
|
|
82
|
+
var onLayout = function (e) {
|
|
83
|
+
var _a = e.nativeEvent.layout, width = _a.width, height = _a.height;
|
|
84
|
+
setCenter({ x: width / 2, y: height / 2 });
|
|
85
|
+
};
|
|
86
|
+
var getTouchAngleDeg = function (x, y) {
|
|
87
|
+
var dx = x - center.x;
|
|
88
|
+
var dy = y - center.y;
|
|
89
|
+
var rad = Math.atan2(dy, dx);
|
|
90
|
+
return (rad * 180) / Math.PI;
|
|
91
|
+
};
|
|
92
|
+
var panResponder = useRef(PanResponder.create({
|
|
93
|
+
onStartShouldSetPanResponder: function () { return true; },
|
|
94
|
+
onMoveShouldSetPanResponder: function () { return true; },
|
|
95
|
+
onPanResponderGrant: function (evt) {
|
|
96
|
+
var _a = evt.nativeEvent, locationX = _a.locationX, locationY = _a.locationY;
|
|
97
|
+
gestureStartAngle.current = getTouchAngleDeg(locationX, locationY);
|
|
98
|
+
angle.stopAnimation(function (current) {
|
|
99
|
+
startAngle.current = current;
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
onPanResponderMove: function (evt) {
|
|
103
|
+
var _a = evt.nativeEvent, locationX = _a.locationX, locationY = _a.locationY;
|
|
104
|
+
var currentAngle = getTouchAngleDeg(locationX, locationY);
|
|
105
|
+
var delta = currentAngle - gestureStartAngle.current;
|
|
106
|
+
if (delta > 180)
|
|
107
|
+
delta -= 360;
|
|
108
|
+
if (delta < -180)
|
|
109
|
+
delta += 360;
|
|
110
|
+
var next = startAngle.current + delta;
|
|
111
|
+
// 🔥 SUPER SMOOTH UPDATE
|
|
112
|
+
smoothSetAngle(next);
|
|
113
|
+
},
|
|
114
|
+
})).current;
|
|
115
|
+
var rotateInterpolation = angle.interpolate({
|
|
116
|
+
inputRange: [-360, 360],
|
|
117
|
+
outputRange: ['-360deg', '360deg'],
|
|
118
|
+
});
|
|
119
|
+
return (_jsx(View, __assign({ onLayout: onLayout, style: [styles.container, { width: size, height: size }] }, panResponder.panHandlers, { children: _jsx(Animated.View, { style: {
|
|
120
|
+
width: size,
|
|
121
|
+
height: size,
|
|
122
|
+
justifyContent: 'center',
|
|
123
|
+
alignItems: 'center',
|
|
124
|
+
transform: [{ rotate: rotateInterpolation }],
|
|
125
|
+
}, children: children }) })));
|
|
126
|
+
}
|
|
127
|
+
var styles = StyleSheet.create({
|
|
128
|
+
container: {
|
|
129
|
+
alignItems: 'center',
|
|
130
|
+
justifyContent: 'center',
|
|
131
|
+
},
|
|
132
|
+
});
|
package/dist/LineChart/index.js
CHANGED
|
@@ -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) })) :
|
|
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) })) :
|
|
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 +
|
|
@@ -840,6 +869,8 @@ export var LineChart = function (props) {
|
|
|
840
869
|
}
|
|
841
870
|
};
|
|
842
871
|
var renderLine = function (containerHeightIncludingBelowXAxis, zIndex, points, currentLineThickness, color, fillPoints, startFillColor, endFillColor, startOpacity, endOpacity, strokeDashArray, strokeLinecap, showArrow, arrowPoints, arrowStrokeWidth, arrowStrokeColor, arrowFillColor, hideDataPoints, paramData, propsData, dataPointsShape, dataPointsWidth, dataPointsHeight, dataPointsColor, dataPointsRadius, textColor, textFontSize, startIndex, endIndex, isSecondary, showValuesAsDataPointsText, spacingArray, key) {
|
|
872
|
+
if (!points)
|
|
873
|
+
return null;
|
|
843
874
|
return (_jsx(View, { onPointerEnter: function () { var _a; return (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onPointerEnter) === null || _a === void 0 ? void 0 : _a.call(pointerConfig); }, onPointerLeave: function () { var _a; return (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onPointerLeave) === null || _a === void 0 ? void 0 : _a.call(pointerConfig); }, onTouchStart: function () { var _a; return (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onTouchStart) === null || _a === void 0 ? void 0 : _a.call(pointerConfig); }, onTouchEnd: function () { var _a; return (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onTouchEnd) === null || _a === void 0 ? void 0 : _a.call(pointerConfig); }, onMoveShouldSetResponder: function (evt) { return (pointerConfig ? true : false); }, onStartShouldSetResponder: function (evt) {
|
|
844
875
|
return pointerConfig && activatePointersInstantlyOnTouch ? true : false;
|
|
845
876
|
}, onResponderGrant: function (evt) {
|
|
@@ -905,6 +936,8 @@ export var LineChart = function (props) {
|
|
|
905
936
|
], children: lineSvgComponent(points, currentLineThickness, color, fillPoints, startFillColor, endFillColor, startOpacity, endOpacity, strokeDashArray, strokeLinecap, showArrow, arrowPoints, arrowStrokeWidth, arrowStrokeColor, arrowFillColor, key, hideDataPoints, paramData, propsData, dataPointsShape, dataPointsWidth, dataPointsHeight, dataPointsColor, dataPointsRadius, textColor, textFontSize, startIndex, endIndex, isSecondary, showValuesAsDataPointsText, spacingArray) }, key !== null && key !== void 0 ? key : 0));
|
|
906
937
|
};
|
|
907
938
|
var renderAnimatedLine = function (containerHeightIncludingBelowXAxis, zIndex, points, animatedWidth, currentLineThickness, color, fillPoints, startFillColor, endFillColor, startOpacity, endOpacity, strokeDashArray, strokeLinecap, showArrow, arrowPoints, arrowStrokeWidth, arrowStrokeColor, arrowFillColor, hideDataPoints, paramsData, propsData, dataPointsShape, dataPointsWidth, dataPointsHeight, dataPointsColor, dataPointsRadius, textColor, textFontSize, startIndex, endIndex, isSecondary, showValuesAsDataPointsText, spacingArray, key) {
|
|
939
|
+
if (!points)
|
|
940
|
+
return null;
|
|
908
941
|
return (_jsx(Animated.View, { onPointerEnter: function () { var _a; return (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onPointerEnter) === null || _a === void 0 ? void 0 : _a.call(pointerConfig); }, onPointerLeave: function () { var _a; return (_a = pointerConfig === null || pointerConfig === void 0 ? void 0 : pointerConfig.onPointerLeave) === null || _a === void 0 ? void 0 : _a.call(pointerConfig); }, onMoveShouldSetResponder: function (evt) { return (pointerConfig ? true : false); }, onStartShouldSetResponder: function (evt) {
|
|
909
942
|
return pointerConfig && activatePointersInstantlyOnTouch ? true : false;
|
|
910
943
|
}, onResponderGrant: function (evt) {
|
package/dist/PieChart/index.d.ts
CHANGED
|
@@ -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;
|
package/dist/PieChart/index.js
CHANGED
|
@@ -31,8 +31,11 @@ import { PieChartMain } from './main';
|
|
|
31
31
|
import { pieColors, usePieChart } from 'gifted-charts-core';
|
|
32
32
|
import { isWebApp } from '../utils';
|
|
33
33
|
import { useState } from 'react';
|
|
34
|
+
import { RotatablePie } from '../Components/Rotatable';
|
|
34
35
|
export var PieChart = function (props) {
|
|
35
|
-
|
|
36
|
+
if (!props.data)
|
|
37
|
+
return null;
|
|
38
|
+
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, rotatable = _a.rotatable;
|
|
36
39
|
var _b = __read(useState(0), 2), touchX = _b[0], setTouchX = _b[1];
|
|
37
40
|
var _c = __read(useState(0), 2), touchY = _c[0], setTouchY = _c[1];
|
|
38
41
|
var renderInnerCircle = function (innerRadius, innerCircleBorderWidth) {
|
|
@@ -117,29 +120,34 @@ export var PieChart = function (props) {
|
|
|
117
120
|
fontStyle: fontStyle,
|
|
118
121
|
}, children: getTooltipText(tooltipSelectedIndex) }) })) }));
|
|
119
122
|
};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
123
|
+
var PieChartBody = function () {
|
|
124
|
+
return (_jsxs(View, { style: {
|
|
125
|
+
height: (radius + extraRadius + paddingVertical / 2) *
|
|
126
|
+
(props.semiCircle ? 1 : 2),
|
|
127
|
+
width: (radius + extraRadius + paddingHorizontal / 2) * 2,
|
|
128
|
+
overflow: 'hidden',
|
|
129
|
+
}, children: [_jsx(View, { style: { position: 'absolute' }, children: _jsx(PieChartMain, __assign({}, props, { setTouchX: setTouchX, setTouchY: setTouchY, tooltipSelectedIndex: tooltipSelectedIndex, setTooltipSelectedIndex: setTooltipSelectedIndex, selectedIndex: selectedIndex, setSelectedIndex: setSelectedIndex, paddingHorizontal: paddingHorizontal, paddingVertical: paddingVertical, extraRadius: extraRadius })) }), renderInnerCircle(innerRadius, innerCircleBorderWidth), props.data.length > 1 &&
|
|
130
|
+
props.data[selectedIndex] && // don't forget to add this one so there are no errors when the data is empty / updating
|
|
131
|
+
(props.focusOnPress || props.sectionAutoFocus) &&
|
|
132
|
+
selectedIndex !== -1 && (_jsx(View, { pointerEvents: "box-none", style: {
|
|
133
|
+
position: 'absolute',
|
|
134
|
+
top: -extraRadius,
|
|
135
|
+
left: -extraRadius,
|
|
136
|
+
zIndex: isWebApp ? -1 : 0, // was not getting displayed in web (using Expo)
|
|
137
|
+
}, children: _jsx(PieChartMain, __assign({}, props, { setTouchX: setTouchX, setTouchY: setTouchY, tooltipSelectedIndex: tooltipSelectedIndex, setTooltipSelectedIndex: setTooltipSelectedIndex, data: [
|
|
138
|
+
__assign(__assign({}, props.data[selectedIndex]), { color: props.showGradient
|
|
139
|
+
? "url(#grad".concat(selectedIndex, ")")
|
|
140
|
+
: props.data[selectedIndex].color ||
|
|
141
|
+
pieColors[selectedIndex % 9] }),
|
|
142
|
+
{
|
|
143
|
+
value: total - props.data[selectedIndex].value,
|
|
144
|
+
peripheral: true,
|
|
145
|
+
strokeWidth: 0,
|
|
146
|
+
},
|
|
147
|
+
], radius: radius + extraRadius, initialAngle: startAngle, innerRadius: props.innerRadius || radius / 2.5, isBiggerPie: true, selectedIndex: selectedIndex, setSelectedIndex: setSelectedIndex, paddingHorizontal: paddingHorizontal, paddingVertical: paddingVertical, extraRadius: extraRadius })) })), renderInnerCircle(innerRadius - inwardExtraLengthForFocused, inwardExtraLengthForFocused ? 0 : innerCircleBorderWidth), showTooltip && tooltipSelectedIndex !== -1 ? renderTooltip() : null] }));
|
|
148
|
+
};
|
|
149
|
+
if (rotatable && !semiCircle) {
|
|
150
|
+
return (_jsx(RotatablePie, { children: [_jsx(PieChartBody, {}, "PieChartBody")], initialAngle: startAngle, size: radius * 2 }));
|
|
151
|
+
}
|
|
152
|
+
return _jsx(PieChartBody, {});
|
|
145
153
|
};
|
package/dist/PieChart/main.js
CHANGED
|
@@ -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
|
|
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
|
|
30
|
-
var
|
|
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,21 +89,22 @@ 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
|
-
}) }),
|
|
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
|
-
var _a
|
|
94
|
+
: ((_a = data[0]) === null || _a === void 0 ? void 0 : _a.color) || pieColors[0 % 9] }) })) : (data.map(function (item, index) {
|
|
95
|
+
var _a;
|
|
96
|
+
var _b = coordinates[index], sx = _b.sx, sy = _b.sy, ax = _b.ax, ay = _b.ay;
|
|
95
97
|
if (isBiggerPie && index)
|
|
96
98
|
return null;
|
|
97
99
|
return (_jsx(Path, { d: "M ".concat(cx + (item.shiftX || 0), " ").concat(cy + (item.shiftY || 0), " L ").concat(sx, " ").concat(sy, " A ").concat(radius, " ").concat(radius, " 0 ").concat(semiCircle ? 0 : data[index].value > total / 2 ? 1 : 0, " 1 ").concat(ax, " ").concat(ay, " L ").concat(cx + (item.shiftX || 0), " ").concat(cy + (item.shiftY || 0)), stroke: item.strokeColor || strokeColor, strokeWidth: props.focusOnPress && props.selectedIndex === index
|
|
98
100
|
? 0
|
|
99
101
|
: item.strokeWidth === 0
|
|
100
102
|
? 0
|
|
101
|
-
: item.strokeWidth || strokeWidth, fill:
|
|
103
|
+
: item.strokeWidth || strokeWidth, fill: item.peripheral
|
|
102
104
|
? 'none'
|
|
103
105
|
: showGradient
|
|
104
106
|
? "url(#grad".concat(index, ")")
|
|
105
|
-
: item.color || pieColors[index % 9] }, index + 'a'));
|
|
107
|
+
: item.color || pieColors[isBiggerPie ? (_a = props.selectedIndex) !== null && _a !== void 0 ? _a : 0 % 9 : index % 9] }, index + 'a'));
|
|
106
108
|
})), (showText || showInnerComponent || showExternalLabels) &&
|
|
107
109
|
data.map(function (item, index) {
|
|
108
110
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
@@ -161,7 +163,7 @@ export var PieChartMain = function (props) {
|
|
|
161
163
|
item.textSize ||
|
|
162
164
|
textSize, fill: item.textBackgroundColor || textBackgroundColor })) : null, showText && (_jsx(SvgText, { fill: item.textColor ||
|
|
163
165
|
textColor ||
|
|
164
|
-
|
|
166
|
+
'black', fontSize: item.textSize || textSize, fontFamily: item.font || font, fontWeight: item.fontWeight || fontWeight, fontStyle: item.fontStyle || fontStyle || 'normal', x: x +
|
|
165
167
|
(item.shiftTextX || 0) -
|
|
166
168
|
(item.textSize || textSize) / 1.8, y: y + (item.shiftTextY || 0), children: item.text || (showValuesAsLabels ? item.value + '' : '') })), localPieInnerComponent ? (_jsx(G, { x: x - pieInnerComponentHeight / 2, y: y - pieInnerComponentWidth / 2, children: (_j = localPieInnerComponent === null || localPieInnerComponent === void 0 ? void 0 : localPieInnerComponent(item, index)) !== null && _j !== void 0 ? _j : null })) : null] }, index));
|
|
167
169
|
})] }), isThreeD && shadow && !semiCircle ? (_jsx(View, { style: {
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gifted-charts",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.70",
|
|
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.
|
|
29
|
+
"gifted-charts-core": "0.1.72"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@babel/cli": "^7.24.8",
|