@harveylx/react-native-gifted-charts 1.4.731 → 1.4.733

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.
@@ -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
21
  opacity: 1,
28
- } }, "bg-slice-".concat(item.id, "-").concat(index)));
22
+ } }, "bg-slice-".concat(i)));
29
23
  });
30
24
  };
@@ -1137,5 +1137,5 @@ export var LineChart = function (props) {
1137
1137
  pointerConfig.dynamicLegendContainerStyle,
1138
1138
  ], children: pointerConfig.dynamicLegendComponent(pointerItemLocal, pointerIndex) })) : null] }));
1139
1139
  };
1140
- 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 })));
1141
1141
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harveylx/react-native-gifted-charts",
3
- "version": "1.4.731",
3
+ "version": "1.4.733",
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.731"
30
+ "@harveylx/gifted-charts-core": "0.1.733"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@babel/cli": "^7.24.8",