From a917955110f3622afe5eae7ca84ae2c8f0caae2d Mon Sep 17 00:00:00 2001 From: Abhinandan-Kushwaha Date: Sat, 21 May 2022 03:22:09 +0530 Subject: [PATCH] Added prop stripOverPointer to Line and Area charts --- docs/LineChart/LineChartProps.md | 1 + package.json | 2 +- src/LineChart/index.tsx | 9 ++++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/LineChart/LineChartProps.md b/docs/LineChart/LineChartProps.md index b7148e6..8e8822e 100644 --- a/docs/LineChart/LineChartProps.md +++ b/docs/LineChart/LineChartProps.md @@ -297,6 +297,7 @@ type Pointer = { pointerStripColor?: ColorValue; // default: 'black' pointerStripUptoDataPoint?: boolean; // default: false pointerLabelComponent?: Function; // default: null + stripOverPointer?: boolean; // default: false shiftPointerLabelX?: number; // default: 0 shiftPointerLabelY?: number; // default: 0 pointerLabelWidth?: number; // default: 20 diff --git a/package.json b/package.json index 2ba4e89..d78491d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-gifted-charts", - "version": "1.2.20", + "version": "1.2.21", "description": "The most complete library for Bar, Line, Area, Pie, Donut and Stacked Bar charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.", "main": "src/index.tsx", "files": [ diff --git a/src/LineChart/index.tsx b/src/LineChart/index.tsx index 96fe7d0..7c02b13 100644 --- a/src/LineChart/index.tsx +++ b/src/LineChart/index.tsx @@ -347,6 +347,7 @@ type Pointer = { pointerStripColor?: ColorValue; pointerStripUptoDataPoint?: boolean; pointerLabelComponent?: Function; + stripOverPointer?: boolean; autoAdjustPointerLabelPosition?: boolean; shiftPointerLabelX?: number; shiftPointerLabelY?: number; @@ -1412,6 +1413,7 @@ export const LineChart = (props: propTypes) => { pointerStripColor: 'black', pointerStripUptoDataPoint: false, pointerLabelComponent: null, + stripOverPointer: false, shiftPointerLabelX: 0, shiftPointerLabelY: 0, pointerLabelWidth: 20, @@ -1473,6 +1475,10 @@ export const LineChart = (props: propTypes) => { pointerConfig && pointerConfig.pointerLabelComponent ? pointerConfig.pointerLabelComponent : defaultPointerConfig.pointerLabelComponent; + const stripOverPointer = + pointerConfig && pointerConfig.stripOverPointer + ? pointerConfig.stripOverPointer + : defaultPointerConfig.stripOverPointer; const shiftPointerLabelX = pointerConfig && pointerConfig.shiftPointerLabelX ? pointerConfig.shiftPointerLabelX @@ -3469,12 +3475,13 @@ export const LineChart = (props: propTypes) => { width: totalWidth, zIndex: 20, }}> + {!stripOverPointer && renderStripAndLabel()} {renderPointer(1)} {points2 ? renderPointer(2) : null} {points3 ? renderPointer(3) : null} {points4 ? renderPointer(4) : null} {points5 ? renderPointer(5) : null} - {renderStripAndLabel()} + {stripOverPointer && renderStripAndLabel()} ) : null} {data.map((item: itemType, index: number) => {