fixed issue with yAxisLabelTexts having . and pointerStrip still visible when set to hidden

This commit is contained in:
Abhinandan-Kushwaha 2022-05-21 16:20:42 +05:30
parent 651a2d3f59
commit ae7f22f991
3 changed files with 19 additions and 11 deletions

View File

@ -1,6 +1,6 @@
{
"name": "react-native-gifted-charts",
"version": "1.2.21",
"version": "1.2.22",
"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": [

View File

@ -630,9 +630,12 @@ export const BarChart = (props: PropTypes) => {
outputRange: [0, totalWidth],
});
const getLabel = val => {
const getLabel = (val, index) => {
let label = '';
if (showFractionalValues) {
if (
showFractionalValues ||
(props.yAxisLabelTexts && props.yAxisLabelTexts[index] !== undefined)
) {
if (val) {
label = val;
} else {
@ -731,7 +734,7 @@ export const BarChart = (props: PropTypes) => {
props.hideAxesAndRules !== true &&
!hideYAxisText &&
horizSections.map((sectionItems, index) => {
let label = getLabel(sectionItems.value);
let label = getLabel(sectionItems.value, index);
if (hideOrigin && index === horizSections.length - 1) {
label = '';
}
@ -852,6 +855,7 @@ export const BarChart = (props: PropTypes) => {
horizSectionsBelow.map((sectionItems, index) => {
let label = getLabel(
horizSectionsBelow[horizSectionsBelow.length - 1 - index].value,
index,
);
return (
<View
@ -906,7 +910,7 @@ export const BarChart = (props: PropTypes) => {
props.hideAxesAndRules !== true &&
!hideYAxisText &&
horizSections.map((sectionItems, index) => {
let label = getLabel(sectionItems.value);
let label = getLabel(sectionItems.value, index);
if (hideOrigin && index === horizSections.length - 1) {
label = '';
}

View File

@ -1452,8 +1452,8 @@ export const LineChart = (props: propTypes) => {
: defaultPointerConfig.pointerComponent;
const showPointerStrip =
pointerConfig && pointerConfig.showPointerStrip
? pointerConfig.showPointerStrip
pointerConfig && pointerConfig.showPointerStrip === false
? false
: defaultPointerConfig.showPointerStrip;
const pointerStripHeight =
pointerConfig && pointerConfig.pointerStripHeight
@ -1779,9 +1779,12 @@ export const LineChart = (props: propTypes) => {
// )
// }
const getLabel = val => {
const getLabel = (val, index) => {
let label = '';
if (showFractionalValues) {
if (
showFractionalValues ||
(props.yAxisLabelTexts && props.yAxisLabelTexts[index] !== undefined)
) {
if (val) {
label = props.yAxisOffset
? (Number(val) + props.yAxisOffset).toString()
@ -1882,7 +1885,7 @@ export const LineChart = (props: propTypes) => {
props.hideAxesAndRules !== true &&
!hideYAxisText &&
horizSections.map((sectionItems, index) => {
let label = getLabel(sectionItems.value);
let label = getLabel(sectionItems.value, index);
if (hideOrigin && index === horizSections.length - 1) {
label = '';
}
@ -1987,6 +1990,7 @@ export const LineChart = (props: propTypes) => {
horizSectionsBelow.map((sectionItems, index) => {
let label = getLabel(
horizSectionsBelow[horizSectionsBelow.length - 1 - index].value,
index,
);
return (
<View
@ -2041,7 +2045,7 @@ export const LineChart = (props: propTypes) => {
props.hideAxesAndRules !== true &&
!hideYAxisText &&
horizSections.map((sectionItems, index) => {
let label = getLabel(sectionItems.value);
let label = getLabel(sectionItems.value, index);
if (hideOrigin && index === horizSections.length - 1) {
label = '';
}