From 3a0fb89baabe163f4325e7b7c38098f44b27ff05 Mon Sep 17 00:00:00 2001 From: Abhinandan Kushwaha Date: Tue, 19 Oct 2021 18:39:15 +0530 Subject: [PATCH 1/2] Added props shiftTextX and shiftTextY --- docs/PieChart/PieChartProps.md | 2 ++ src/PieChart/index.tsx | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/docs/PieChart/PieChartProps.md b/docs/PieChart/PieChartProps.md index 4c49e04..1279b94 100644 --- a/docs/PieChart/PieChartProps.md +++ b/docs/PieChart/PieChartProps.md @@ -27,6 +27,8 @@ | value | number | Value of the item, representing a section of the Pie chart | | shiftX | number | Translates (shifts) the particular section horizontally by given value | | shiftY | number | Translates (shifts) the particular section vertically by given value | +| shiftTextX | number | Translates (shifts) the position of label text horizontally | +| shiftTextY | number | Translates (shifts) the position of label text vertically | | color | ColorValue | Color (background color) of the section | | text | string | Label text for the sections | | textColor | ColorValue | Color of the text (label) inside the section | diff --git a/src/PieChart/index.tsx b/src/PieChart/index.tsx index c151404..7f09c81 100644 --- a/src/PieChart/index.tsx +++ b/src/PieChart/index.tsx @@ -42,6 +42,8 @@ type itemType = { textSize?: number; textBackgroundColor?: string; textBackgroundRadius?: number; + shiftTextX?: number; + shiftTextY?: number; }; export const PieChart = (props: propTypes) => { const {data, isThreeD} = props; @@ -144,6 +146,9 @@ export const PieChart = (props: propTypes) => { const shiftX = dataItem.shiftX || 0; const shiftY = dataItem.shiftY || 0; + const shiftTextX = dataItem.shiftTextX || 0; + const shiftTextY = dataItem.shiftTextY || 0; + /**************** This section is to prevent the shadow from ***************/ /**************** being visible inside the chart content if ***************/ /**************** the color of sections is transparent ***************/ @@ -260,6 +265,9 @@ export const PieChart = (props: propTypes) => { ctx.fill(); } + xx += shiftTextX; + yy += shiftTextY; + ctx.fillStyle = dataItem.textColor || textColor || colors[i++ % 8]; let labelText = dataItem.text || ''; if (showValuesAsLabels && !labelText) { From 1893f5ec291b7f2089a526a9f03a22f3d56f9193 Mon Sep 17 00:00:00 2001 From: Abhinandan Kushwaha Date: Tue, 19 Oct 2021 18:40:50 +0530 Subject: [PATCH 2/2] Added props shiftTextX and shiftTextY --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4d802b2..bce9d51 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-gifted-charts", - "version": "0.1.9", + "version": "0.1.10", "description": "The most complete library for Bar, Line, Area, Pie and Donut charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.", "main": "src/index.tsx", "files": [