@harveylx/react-native-gifted-charts 1.4.72 → 1.4.74

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/README.md CHANGED
@@ -20,7 +20,7 @@
20
20
  <img src="/demos/redditLogo.png" height="auto" width="32" height="32" />
21
21
  </a>
22
22
  </p>
23
- 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.
23
+ The most loved 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.
24
24
 
25
25
  ### Yet another chart library? Why?
26
26
 
@@ -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
  }
@@ -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-
@@ -27,10 +27,10 @@ var isCloseToLeft = function (_a, endReachedOffset) {
27
27
  contentSize.width - endReachedOffset);
28
28
  };
29
29
  var BarAndLineChartsWrapper = function (props) {
30
- var _a, _b, _c, _d, _e;
31
- var chartType = props.chartType, containerHeight = props.containerHeight, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, stepHeight = props.stepHeight, labelsExtraHeight = props.labelsExtraHeight, yAxisLabelWidth = props.yAxisLabelWidth, horizontal = props.horizontal, scrollRef = props.scrollRef, initialSpacing = props.initialSpacing, data = props.data, barWidth = props.barWidth, xAxisThickness = props.xAxisThickness, totalWidth = props.totalWidth, disableScroll = props.disableScroll, showScrollIndicator = props.showScrollIndicator, scrollToEnd = props.scrollToEnd, scrollToIndex = props.scrollToIndex, scrollAnimation = props.scrollAnimation, indicatorColor = props.indicatorColor, spacing = props.spacing, renderChartContent = props.renderChartContent, remainingScrollViewProps = props.remainingScrollViewProps, endSpacing = props.endSpacing, hideAxesAndRules = props.hideAxesAndRules, showXAxisIndices = props.showXAxisIndices, xAxisIndicesHeight = props.xAxisIndicesHeight, xAxisIndicesWidth = props.xAxisIndicesWidth, xAxisIndicesColor = props.xAxisIndicesColor, pointerConfig = props.pointerConfig, getPointerProps = props.getPointerProps, pointerIndex = props.pointerIndex, pointerX = props.pointerX, pointerY = props.pointerY, onEndReached = props.onEndReached, onStartReached = props.onStartReached, endReachedOffset = props.endReachedOffset, onMomentumScrollEnd = props.onMomentumScrollEnd, onScrollEndDrag = props.onScrollEndDrag, nestedScrollEnabled = props.nestedScrollEnabled, _f = props.extraWidthDueToDataPoint, extraWidthDueToDataPoint = _f === void 0 ? 0 : _f, // extraWidthDueToDataPoint will be receved from props onlhy in case of LineCharts, for other charts it will be undefined and will default to 0
32
- showBackgroundSlices = props.showBackgroundSlices;
33
- var _g = useBarAndLineChartsWrapper(__assign(__assign({}, props), { isRTL: I18nManager.isRTL })), containerHeightIncludingBelowXAxis = _g.containerHeightIncludingBelowXAxis, xAxisLabelsVerticalShift = _g.xAxisLabelsVerticalShift, trimYAxisAtTop = _g.trimYAxisAtTop, yAxisExtraHeight = _g.yAxisExtraHeight, overflowTop = _g.overflowTop, xAxisLabelsHeight = _g.xAxisLabelsHeight, xAxisTextNumberOfLines = _g.xAxisTextNumberOfLines, actualContainerWidth = _g.actualContainerWidth, transformForHorizontal = _g.transformForHorizontal, horizSectionProps = _g.horizSectionProps, referenceLinesOverChartContent = _g.referenceLinesOverChartContent, setCanMomentum = _g.setCanMomentum, isCloseToStart = _g.isCloseToStart, isCloseToEnd = _g.isCloseToEnd, canMomentum = _g.canMomentum, yAxisAtTop = _g.yAxisAtTop, yAxisThickness = _g.yAxisThickness, yAxisSide = _g.yAxisSide, showVerticalLines = _g.showVerticalLines, verticalLinesProps = _g.verticalLinesProps;
30
+ var _a, _b, _c, _d, _e, _f;
31
+ var chartType = props.chartType, containerHeight = props.containerHeight, noOfSectionsBelowXAxis = props.noOfSectionsBelowXAxis, stepHeight = props.stepHeight, labelsExtraHeight = props.labelsExtraHeight, yAxisLabelWidth = props.yAxisLabelWidth, horizontal = props.horizontal, scrollRef = props.scrollRef, initialSpacing = props.initialSpacing, data = props.data, barWidth = props.barWidth, xAxisThickness = props.xAxisThickness, totalWidth = props.totalWidth, disableScroll = props.disableScroll, showScrollIndicator = props.showScrollIndicator, scrollToEnd = props.scrollToEnd, scrollToIndex = props.scrollToIndex, scrollAnimation = props.scrollAnimation, indicatorColor = props.indicatorColor, spacing = props.spacing, renderChartContent = props.renderChartContent, remainingScrollViewProps = props.remainingScrollViewProps, endSpacing = props.endSpacing, hideAxesAndRules = props.hideAxesAndRules, showXAxisIndices = props.showXAxisIndices, xAxisIndicesHeight = props.xAxisIndicesHeight, xAxisIndicesWidth = props.xAxisIndicesWidth, xAxisIndicesColor = props.xAxisIndicesColor, pointerConfig = props.pointerConfig, getPointerProps = props.getPointerProps, pointerIndex = props.pointerIndex, pointerX = props.pointerX, pointerY = props.pointerY, onEndReached = props.onEndReached, onStartReached = props.onStartReached, endReachedOffset = props.endReachedOffset, onMomentumScrollEnd = props.onMomentumScrollEnd, onScrollEndDrag = props.onScrollEndDrag, nestedScrollEnabled = props.nestedScrollEnabled, _g = props.extraWidthDueToDataPoint, extraWidthDueToDataPoint = _g === void 0 ? 0 : _g, // extraWidthDueToDataPoint will be receved from props onlhy in case of LineCharts, for other charts it will be undefined and will default to 0
32
+ backgroundSlices = props.backgroundSlices;
33
+ var _h = useBarAndLineChartsWrapper(__assign(__assign({}, props), { isRTL: I18nManager.isRTL })), containerHeightIncludingBelowXAxis = _h.containerHeightIncludingBelowXAxis, xAxisLabelsVerticalShift = _h.xAxisLabelsVerticalShift, trimYAxisAtTop = _h.trimYAxisAtTop, yAxisExtraHeight = _h.yAxisExtraHeight, overflowTop = _h.overflowTop, xAxisLabelsHeight = _h.xAxisLabelsHeight, xAxisTextNumberOfLines = _h.xAxisTextNumberOfLines, actualContainerWidth = _h.actualContainerWidth, transformForHorizontal = _h.transformForHorizontal, horizSectionProps = _h.horizSectionProps, referenceLinesOverChartContent = _h.referenceLinesOverChartContent, setCanMomentum = _h.setCanMomentum, isCloseToStart = _h.isCloseToStart, isCloseToEnd = _h.isCloseToEnd, canMomentum = _h.canMomentum, yAxisAtTop = _h.yAxisAtTop, yAxisThickness = _h.yAxisThickness, yAxisSide = _h.yAxisSide, showVerticalLines = _h.showVerticalLines, verticalLinesProps = _h.verticalLinesProps;
34
34
  useEffect(function () {
35
35
  if (pointerConfig && getPointerProps) {
36
36
  getPointerProps({ pointerIndex: pointerIndex, pointerX: pointerX, pointerY: pointerY });
@@ -128,7 +128,7 @@ var BarAndLineChartsWrapper = function (props) {
128
128
  animated: scrollAnimation,
129
129
  });
130
130
  }
131
- } }, remainingScrollViewProps, { children: _jsxs(Fragment, { children: [showBackgroundSlices && chartType === chartTypes.LINE ? (_jsx(View, { style: {
131
+ } }, remainingScrollViewProps, { children: _jsxs(Fragment, { children: [(backgroundSlices === null || backgroundSlices === void 0 ? void 0 : backgroundSlices.length) && chartType === chartTypes.LINE ? (_jsx(View, { style: {
132
132
  position: 'absolute',
133
133
  bottom: 61 + xAxisLabelsVerticalShift,
134
134
  left: initialSpacing,
@@ -136,7 +136,8 @@ var BarAndLineChartsWrapper = function (props) {
136
136
  width: totalWidth,
137
137
  zIndex: -1,
138
138
  }, children: renderBackgroundSlices({
139
- data: data || [],
139
+ backgroundSlices: backgroundSlices,
140
+ dataLength: (_f = data === null || data === void 0 ? void 0 : data.length) !== null && _f !== void 0 ? _f : 0,
140
141
  endSpacing: endSpacing,
141
142
  totalWidth: totalWidth,
142
143
  }) })) : null, showVerticalLines ? (_jsx(RenderVerticalLines, __assign({}, verticalLinesProps))) : null,
@@ -1,7 +1,9 @@
1
+ import { BackgroundSlice } from '@harveylx/gifted-charts-core';
1
2
  interface RenderBackgroundSlicesProps {
2
- data: any[];
3
+ backgroundSlices: BackgroundSlice[];
4
+ dataLength: number;
3
5
  endSpacing?: number;
4
6
  totalWidth: number;
5
7
  }
6
- export declare const renderBackgroundSlices: (props: RenderBackgroundSlicesProps) => (import("react/jsx-runtime").JSX.Element | null)[] | null;
8
+ export declare const renderBackgroundSlices: (props: RenderBackgroundSlicesProps) => import("react/jsx-runtime").JSX.Element[] | null;
7
9
  export {};
@@ -1,30 +1,24 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { View } from 'react-native';
2
+ import { View, PixelRatio } from 'react-native';
3
3
  export var renderBackgroundSlices = function (props) {
4
- var data = props.data, totalWidth = props.totalWidth, _a = props.endSpacing, endSpacing = _a === void 0 ? 0 : _a;
5
- if (!data || data.length === 0) {
4
+ var backgroundSlices = props.backgroundSlices, dataLength = props.dataLength, totalWidth = props.totalWidth, _a = props.endSpacing, endSpacing = _a === void 0 ? 0 : _a;
5
+ if (!backgroundSlices.length || dataLength === 0) {
6
6
  return null;
7
7
  }
8
- // Calculate total chart width
9
8
  var totalChartWidth = totalWidth - endSpacing;
10
- // Each slice gets equal width based on TOTAL data length (not filtered)
11
- var sliceWidth = totalChartWidth / data.length;
12
- // Map over ALL data items, preserving original index positions
13
- return data.map(function (item, index) {
14
- // Skip rendering if no background slice color specified
15
- if (!item.backgroundSliceColor) {
16
- return null;
17
- }
18
- // Use original data index for position
9
+ var unitWidth = totalChartWidth / dataLength;
10
+ return backgroundSlices.map(function (slice, i) {
11
+ var left = PixelRatio.roundToNearestPixel(unitWidth * slice.from);
12
+ var right = PixelRatio.roundToNearestPixel(unitWidth * slice.to);
19
13
  return (_jsx(View, { style: {
20
14
  position: 'absolute',
21
- left: sliceWidth * index,
15
+ left: left,
22
16
  top: 0,
23
17
  bottom: 0,
24
- width: sliceWidth,
25
- backgroundColor: item.backgroundSliceColor,
18
+ width: right - left,
19
+ backgroundColor: slice.color,
26
20
  zIndex: -100,
27
- opacity: 0.35,
28
- } }, "bg-slice-".concat(item.id, "-").concat(index)));
21
+ opacity: 1,
22
+ } }, "bg-slice-".concat(i)));
29
23
  });
30
24
  };
@@ -4,7 +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
+ import { isIos, isWebApp } from '../../../utils';
8
8
  var RenderLineInBarChart = function (props) {
9
9
  var _a, _b;
10
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;
@@ -15,6 +15,7 @@ var RenderLineInBarChart = function (props) {
15
15
  : lowlightOpacity
16
16
  : 1;
17
17
  var svgHeight = containerHeightIncludingBelowXAxis + labelsExtraHeight;
18
+ var svgHeightProp = isWebApp ? svgHeight : undefined;
18
19
  var dataPointsProps = {
19
20
  data: data,
20
21
  lineConfig: lineConfig,
@@ -61,7 +62,7 @@ var RenderLineInBarChart = function (props) {
61
62
  width: animatedWidth,
62
63
  zIndex: lineBehindBars ? -1 : 100000,
63
64
  // backgroundColor: 'wheat',
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
65
+ }, children: _jsxs(Svg, { pointerEvents: isIos ? 'none' : 'box-none', height: svgHeightProp, width: isWebApp ? animatedWidth : undefined, children: [_jsx(Path, { d: points, fill: "none", opacity: opacity, stroke: lineConfig.color, strokeWidth: lineConfig.thickness, strokeDasharray: lineConfig.strokeDashArray }), renderSpecificVerticalLines(specificVerticalLinesProps), !lineConfig.hideDataPoints
65
66
  ? renderDataPoints(dataPointsProps)
66
67
  : 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 }))] }) }));
67
68
  };
@@ -75,7 +76,7 @@ var RenderLineInBarChart = function (props) {
75
76
  width: totalWidth,
76
77
  zIndex: lineBehindBars ? -1 : 100000,
77
78
  // backgroundColor: 'rgba(200,150,150,0.1)'
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
79
+ }, children: _jsxs(Svg, { pointerEvents: isIos ? 'none' : 'box-none', height: svgHeightProp, width: isWebApp ? totalWidth : undefined, children: [_jsx(Path, { d: points, fill: "none", opacity: opacity, stroke: lineConfig.color, strokeWidth: lineConfig.thickness, strokeDasharray: lineConfig.strokeDashArray }), renderSpecificVerticalLines(specificVerticalLinesProps), !lineConfig.hideDataPoints
79
80
  ? renderDataPoints(dataPointsProps)
80
81
  : 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 }))] }) }));
81
82
  };
@@ -1,21 +1,5 @@
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
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
18
- import { Fragment, useState } from 'react';
2
+ import { Fragment } from 'react';
19
3
  import { styles } from '../../../BarChart/styles';
20
4
  import { TouchableOpacity, View } from 'react-native';
21
5
  import { getXForLineInBar, getYForLineInBar } from '@harveylx/gifted-charts-core';
@@ -23,8 +7,7 @@ import { Rect, Text as CanvasText, Circle, ForeignObject, } from 'react-native-s
23
7
  import { isWebApp } from '../../../utils';
24
8
  export var renderDataPoints = function (props) {
25
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;
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];
10
+ var focusEnabled = lineConfig.focusEnabled, dataPointLabelComponent = lineConfig.dataPointLabelComponent, showDataPointLabelOnFocus = lineConfig.showDataPointLabelOnFocus, focusedDataPointIndex = lineConfig.focusedDataPointIndex, setFocusedDataPointIndex = lineConfig.setFocusedDataPointIndex;
28
11
  return (_jsxs(_Fragment, { children: [data.map(function (item, index) {
29
12
  var _a, _b, _c;
30
13
  if (index < lineConfig.startIndex ||
@@ -34,10 +17,10 @@ export var renderDataPoints = function (props) {
34
17
  }
35
18
  var currentBarWidth = item.barWidth || barWidth || 30;
36
19
  var customDataPoint = item.customDataPoint || lineConfig.customDataPoint;
37
- var dataPointColor = lineConfig.focusEnabled && index === selectedDataPointIndex
20
+ var dataPointColor = lineConfig.focusEnabled && index === focusedDataPointIndex
38
21
  ? lineConfig.focusedDataPointColor
39
22
  : lineConfig.dataPointsColor;
40
- var dataPointRadius = lineConfig.focusEnabled && index === selectedDataPointIndex
23
+ var dataPointRadius = lineConfig.focusEnabled && index === focusedDataPointIndex
41
24
  ? lineConfig.focusedDataPointRadius
42
25
  : lineConfig.dataPointsRadius;
43
26
  var value = (_a = item.value) !== null && _a !== void 0 ? _a : item.stacks.reduce(function (total, item) { return total + item.value; }, 0);
@@ -57,20 +40,20 @@ export var renderDataPoints = function (props) {
57
40
  },
58
41
  ], onPress: function () {
59
42
  if (focusEnabled)
60
- setSelectedDataPointIndex(index);
43
+ setFocusedDataPointIndex(index);
61
44
  }, children: customDataPoint(item, index) }, index + '.' + value + 'custom'));
62
45
  }
63
46
  if (lineConfig.dataPointsShape === 'rectangular') {
64
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 () {
65
48
  if (focusEnabled)
66
- setSelectedDataPointIndex(index);
49
+ setFocusedDataPointIndex(index);
67
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 -
68
51
  lineConfig.dataPointsHeight / 2 +
69
52
  (item.textShiftY || lineConfig.textShiftY || 0), children: item.dataPointText }))] }, index + '.' + value + 'rect'));
70
53
  }
71
54
  return (_jsxs(Fragment, { children: [_jsx(Circle, { cx: x, cy: y, r: dataPointRadius, fill: dataPointColor, opacity: opacity, onPress: function () {
72
55
  if (focusEnabled)
73
- setSelectedDataPointIndex(index);
56
+ setFocusedDataPointIndex(index);
74
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 -
75
58
  lineConfig.dataPointsHeight / 2 +
76
59
  (item.textShiftY || lineConfig.textShiftY || 0), children: item.dataPointText }))] }, index + '.' + value + 'circ'));
@@ -88,12 +71,12 @@ export var renderDataPoints = function (props) {
88
71
  var y = getYForLineInBar(value, lineConfig.shiftY, containerHeight, maxValue, yAxisOffset);
89
72
  if (isWebApp)
90
73
  return (_jsx(ForeignObject, { height: svgHeight, width: totalWidth, x: x - 12, y: y - 24, children: showDataPointLabelOnFocus
91
- ? selectedDataPointIndex === index
74
+ ? focusedDataPointIndex === index
92
75
  ? dataPointLabelComponent === null || dataPointLabelComponent === void 0 ? void 0 : dataPointLabelComponent(item, index)
93
76
  : null
94
77
  : dataPointLabelComponent === null || dataPointLabelComponent === void 0 ? void 0 : dataPointLabelComponent(item, index) }, index + '.' + value + 'label'));
95
78
  return (_jsx(View, { style: { top: y - 24, left: x - 12, position: 'absolute' }, children: showDataPointLabelOnFocus
96
- ? selectedDataPointIndex === index
79
+ ? focusedDataPointIndex === index
97
80
  ? dataPointLabelComponent === null || dataPointLabelComponent === void 0 ? void 0 : dataPointLabelComponent(item, index)
98
81
  : null
99
82
  : dataPointLabelComponent === null || dataPointLabelComponent === void 0 ? void 0 : dataPointLabelComponent(item, index) }, index + '.' + value + 'label'));
@@ -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
+ });
@@ -869,6 +869,8 @@ export var LineChart = function (props) {
869
869
  }
870
870
  };
871
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;
872
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) {
873
875
  return pointerConfig && activatePointersInstantlyOnTouch ? true : false;
874
876
  }, onResponderGrant: function (evt) {
@@ -934,6 +936,8 @@ export var LineChart = function (props) {
934
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));
935
937
  };
936
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;
937
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) {
938
942
  return pointerConfig && activatePointersInstantlyOnTouch ? true : false;
939
943
  }, onResponderGrant: function (evt) {
@@ -1133,5 +1137,5 @@ export var LineChart = function (props) {
1133
1137
  pointerConfig.dynamicLegendContainerStyle,
1134
1138
  ], children: pointerConfig.dynamicLegendComponent(pointerItemLocal, pointerIndex) })) : null] }));
1135
1139
  };
1136
- return (_jsx(BarAndLineChartsWrapper, __assign({}, barAndLineChartsWrapperProps, { dataSet: dataSet, scrollRef: scrollRef, animatedWidth: widthValue, renderChartContent: renderChartContent, remainingScrollViewProps: remainingScrollViewProps, nestedScrollEnabled: props.nestedScrollEnabled, showBackgroundSlices: props.showBackgroundSlices })));
1140
+ return (_jsx(BarAndLineChartsWrapper, __assign({}, barAndLineChartsWrapperProps, { dataSet: dataSet, scrollRef: scrollRef, animatedWidth: widthValue, renderChartContent: renderChartContent, remainingScrollViewProps: remainingScrollViewProps, nestedScrollEnabled: props.nestedScrollEnabled, backgroundSlices: props.backgroundSlices })));
1137
1141
  };
@@ -31,10 +31,11 @@ import { PieChartMain } from './main';
31
31
  import { pieColors, usePieChart } from '@harveylx/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)
36
37
  return null;
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;
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;
38
39
  var _b = __read(useState(0), 2), touchX = _b[0], setTouchX = _b[1];
39
40
  var _c = __read(useState(0), 2), touchY = _c[0], setTouchY = _c[1];
40
41
  var renderInnerCircle = function (innerRadius, innerCircleBorderWidth) {
@@ -119,28 +120,34 @@ export var PieChart = function (props) {
119
120
  fontStyle: fontStyle,
120
121
  }, children: getTooltipText(tooltipSelectedIndex) }) })) }));
121
122
  };
122
- return (_jsxs(View, { style: {
123
- height: (radius + extraRadius + paddingVertical / 2) *
124
- (props.semiCircle ? 1 : 2),
125
- width: (radius + extraRadius + paddingHorizontal / 2) * 2,
126
- overflow: 'hidden',
127
- }, children: [_jsx(View, { style: { position: 'absolute' }, children: _jsx(PieChartMain, __assign({}, props, { setTouchX: setTouchX, setTouchY: setTouchY, tooltipSelectedIndex: tooltipSelectedIndex, setTooltipSelectedIndex: setTooltipSelectedIndex, setSelectedIndex: setSelectedIndex, paddingHorizontal: paddingHorizontal, paddingVertical: paddingVertical, extraRadius: extraRadius })) }), renderInnerCircle(innerRadius, innerCircleBorderWidth), props.data.length > 1 &&
128
- props.data[selectedIndex] && // don't forget to add this one so there are no errors when the data is empty / updating
129
- (props.focusOnPress || props.sectionAutoFocus) &&
130
- selectedIndex !== -1 && (_jsx(View, { pointerEvents: "box-none", style: {
131
- position: 'absolute',
132
- top: -extraRadius,
133
- left: -extraRadius,
134
- zIndex: isWebApp ? -1 : 0, // was not getting displayed in web (using Expo)
135
- }, children: _jsx(PieChartMain, __assign({}, props, { setTouchX: setTouchX, setTouchY: setTouchY, tooltipSelectedIndex: tooltipSelectedIndex, setTooltipSelectedIndex: setTooltipSelectedIndex, data: [
136
- __assign(__assign({}, props.data[selectedIndex]), { color: props.showGradient
137
- ? "url(#grad".concat(selectedIndex, ")")
138
- : props.data[selectedIndex].color ||
139
- pieColors[selectedIndex % 9] }),
140
- {
141
- value: total - props.data[selectedIndex].value,
142
- peripheral: true,
143
- strokeWidth: 0,
144
- },
145
- ], radius: radius + extraRadius, initialAngle: startAngle, innerRadius: props.innerRadius || radius / 2.5, isBiggerPie: true, setSelectedIndex: setSelectedIndex, paddingHorizontal: paddingHorizontal, paddingVertical: paddingVertical, extraRadius: extraRadius })) })), renderInnerCircle(innerRadius - inwardExtraLengthForFocused, inwardExtraLengthForFocused ? 0 : innerCircleBorderWidth), showTooltip && tooltipSelectedIndex !== -1 ? renderTooltip() : null] }));
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, {});
146
153
  };
@@ -92,18 +92,19 @@ export var PieChartMain = function (props) {
92
92
  }) }), data.length === 1 || !total ? (_jsx(_Fragment, { children: _jsx(Circle, { cx: cx, cy: cy, r: radius, fill: showGradient
93
93
  ? "url(#grad".concat(0, ")")
94
94
  : ((_a = data[0]) === null || _a === void 0 ? void 0 : _a.color) || pieColors[0 % 9] }) })) : (data.map(function (item, index) {
95
- var _a = coordinates[index], sx = _a.sx, sy = _a.sy, ax = _a.ax, ay = _a.ay;
95
+ var _a;
96
+ var _b = coordinates[index], sx = _b.sx, sy = _b.sy, ax = _b.ax, ay = _b.ay;
96
97
  if (isBiggerPie && index)
97
98
  return null;
98
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
99
100
  ? 0
100
101
  : item.strokeWidth === 0
101
102
  ? 0
102
- : item.strokeWidth || strokeWidth, fill: props.selectedIndex === index || item.peripheral
103
+ : item.strokeWidth || strokeWidth, fill: item.peripheral
103
104
  ? 'none'
104
105
  : showGradient
105
106
  ? "url(#grad".concat(index, ")")
106
- : 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'));
107
108
  })), (showText || showInnerComponent || showExternalLabels) &&
108
109
  data.map(function (item, index) {
109
110
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
@@ -162,7 +163,7 @@ export var PieChartMain = function (props) {
162
163
  item.textSize ||
163
164
  textSize, fill: item.textBackgroundColor || textBackgroundColor })) : null, showText && (_jsx(SvgText, { fill: item.textColor ||
164
165
  textColor ||
165
- pieColors[(index + 2) % 9], fontSize: item.textSize || textSize, fontFamily: item.font || font, fontWeight: item.fontWeight || fontWeight, fontStyle: item.fontStyle || fontStyle || 'normal', x: x +
166
+ 'black', fontSize: item.textSize || textSize, fontFamily: item.font || font, fontWeight: item.fontWeight || fontWeight, fontStyle: item.fontStyle || fontStyle || 'normal', x: x +
166
167
  (item.shiftTextX || 0) -
167
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));
168
169
  })] }), isThreeD && shadow && !semiCircle ? (_jsx(View, { style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harveylx/react-native-gifted-charts",
3
- "version": "1.4.72",
3
+ "version": "1.4.74",
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": [
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@react-native/babel-preset": "^0.76.9",
30
- "@harveylx/gifted-charts-core": "0.1.72"
30
+ "@harveylx/gifted-charts-core": "0.1.74"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@babel/cli": "^7.24.8",