Merge pull request #242 from Abhinandan-Kushwaha/abhi
Added leftShiftForTooltip to Bar and stack charts
This commit is contained in:
commit
afd46531eb
|
@ -30,6 +30,7 @@
|
||||||
| scrollAnimation | Boolean | When set to true, scroll animation is visible when the chart automatically scrolls to the rightmost bar | true |
|
| scrollAnimation | Boolean | When set to true, scroll animation is visible when the chart automatically scrolls to the rightmost bar | true |
|
||||||
| initialSpacing | number | distance of the first bar from the Y axis | 40 |
|
| initialSpacing | number | distance of the first bar from the Y axis | 40 |
|
||||||
| renderTooltip | Function | tooltip component appearing above the bar when it is pressed, takes item and index as parameters | null |
|
| renderTooltip | Function | tooltip component appearing above the bar when it is pressed, takes item and index as parameters | null |
|
||||||
|
| leftShiftForTooltip | number | The distance by which the tooltip component should shift towards left | 0 |
|
||||||
| leftShiftForLastIndexTooltip | number | The distance by which the tooltip component of the last bar should shift towards left | 0 |
|
| leftShiftForLastIndexTooltip | number | The distance by which the tooltip component of the last bar should shift towards left | 0 |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -109,6 +110,7 @@ The properties of this line chart can be controlled using the `lineConfig` prop
|
||||||
| spacing | number | Distance of the next Bar from the currennt Bar |
|
| spacing | number | Distance of the next Bar from the currennt Bar |
|
||||||
| barBackgroundPattern | Component | A svg component containing the background pattern for bars |
|
| barBackgroundPattern | Component | A svg component containing the background pattern for bars |
|
||||||
| patternId | String | ID of the pattern component |
|
| patternId | String | ID of the pattern component |
|
||||||
|
| leftShiftForTooltip | number | The distance by which the tooltip component should shift towards left |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "react-native-gifted-charts",
|
"name": "react-native-gifted-charts",
|
||||||
"version": "1.2.37",
|
"version": "1.2.38",
|
||||||
"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.",
|
"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",
|
"main": "src/index.tsx",
|
||||||
"files": [
|
"files": [
|
||||||
|
|
|
@ -64,6 +64,7 @@ type Props = {
|
||||||
onPress?: Function;
|
onPress?: Function;
|
||||||
xAxisTextNumberOfLines: number;
|
xAxisTextNumberOfLines: number;
|
||||||
renderTooltip: Function;
|
renderTooltip: Function;
|
||||||
|
leftShiftForTooltip?: number;
|
||||||
leftShiftForLastIndexTooltip: number;
|
leftShiftForLastIndexTooltip: number;
|
||||||
initialSpacing: number;
|
initialSpacing: number;
|
||||||
selectedIndex: number;
|
selectedIndex: number;
|
||||||
|
@ -95,6 +96,7 @@ type itemType = {
|
||||||
barBackgroundPattern?: Function;
|
barBackgroundPattern?: Function;
|
||||||
patternId?: String;
|
patternId?: String;
|
||||||
barMarginBottom?: number;
|
barMarginBottom?: number;
|
||||||
|
leftShiftForTooltip?: number;
|
||||||
};
|
};
|
||||||
const RenderBars = (props: Props) => {
|
const RenderBars = (props: Props) => {
|
||||||
const {
|
const {
|
||||||
|
@ -120,6 +122,7 @@ const RenderBars = (props: Props) => {
|
||||||
labelTextStyle,
|
labelTextStyle,
|
||||||
xAxisTextNumberOfLines,
|
xAxisTextNumberOfLines,
|
||||||
renderTooltip,
|
renderTooltip,
|
||||||
|
leftShiftForTooltip,
|
||||||
leftShiftForLastIndexTooltip,
|
leftShiftForLastIndexTooltip,
|
||||||
initialSpacing,
|
initialSpacing,
|
||||||
selectedIndex,
|
selectedIndex,
|
||||||
|
@ -580,7 +583,8 @@ const RenderBars = (props: Props) => {
|
||||||
left:
|
left:
|
||||||
index === data.length - 1
|
index === data.length - 1
|
||||||
? leftSpacing - leftShiftForLastIndexTooltip
|
? leftSpacing - leftShiftForLastIndexTooltip
|
||||||
: leftSpacing,
|
: leftSpacing -
|
||||||
|
(item.leftShiftForTooltip ?? leftShiftForTooltip),
|
||||||
zIndex: 1000,
|
zIndex: 1000,
|
||||||
}}>
|
}}>
|
||||||
{renderTooltip(item, index)}
|
{renderTooltip(item, index)}
|
||||||
|
|
|
@ -39,6 +39,7 @@ type Props = {
|
||||||
patternId?: String;
|
patternId?: String;
|
||||||
xAxisTextNumberOfLines: number;
|
xAxisTextNumberOfLines: number;
|
||||||
renderTooltip: Function;
|
renderTooltip: Function;
|
||||||
|
leftShiftForTooltip?: number;
|
||||||
leftShiftForLastIndexTooltip: number;
|
leftShiftForLastIndexTooltip: number;
|
||||||
initialSpacing: number;
|
initialSpacing: number;
|
||||||
selectedIndex: number;
|
selectedIndex: number;
|
||||||
|
@ -70,6 +71,7 @@ type itemType = {
|
||||||
barBackgroundPattern?: Function;
|
barBackgroundPattern?: Function;
|
||||||
barBorderRadius?: Number;
|
barBorderRadius?: Number;
|
||||||
patternId?: String;
|
patternId?: String;
|
||||||
|
leftShiftForTooltip?: number;
|
||||||
};
|
};
|
||||||
const RenderStackBars = (props: Props) => {
|
const RenderStackBars = (props: Props) => {
|
||||||
const {
|
const {
|
||||||
|
@ -87,13 +89,13 @@ const RenderStackBars = (props: Props) => {
|
||||||
labelTextStyle,
|
labelTextStyle,
|
||||||
xAxisTextNumberOfLines,
|
xAxisTextNumberOfLines,
|
||||||
renderTooltip,
|
renderTooltip,
|
||||||
|
leftShiftForTooltip,
|
||||||
leftShiftForLastIndexTooltip,
|
leftShiftForLastIndexTooltip,
|
||||||
initialSpacing,
|
initialSpacing,
|
||||||
selectedIndex,
|
selectedIndex,
|
||||||
setSelectedIndex,
|
setSelectedIndex,
|
||||||
activeOpacity,
|
activeOpacity,
|
||||||
stackData,
|
stackData,
|
||||||
data,
|
|
||||||
} = props;
|
} = props;
|
||||||
let leftSpacing = initialSpacing;
|
let leftSpacing = initialSpacing;
|
||||||
for (let i = 0; i < index; i++) {
|
for (let i = 0; i < index; i++) {
|
||||||
|
@ -328,9 +330,10 @@ const RenderStackBars = (props: Props) => {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
bottom: totalHeight + 60,
|
bottom: totalHeight + 60,
|
||||||
left:
|
left:
|
||||||
index === data.length - 1
|
index === stackData.length - 1
|
||||||
? leftSpacing - leftShiftForLastIndexTooltip
|
? leftSpacing - leftShiftForLastIndexTooltip
|
||||||
: leftSpacing,
|
: leftSpacing -
|
||||||
|
(item.leftShiftForTooltip ?? leftShiftForTooltip),
|
||||||
zIndex: 1000,
|
zIndex: 1000,
|
||||||
}}>
|
}}>
|
||||||
{renderTooltip(item, index)}
|
{renderTooltip(item, index)}
|
||||||
|
|
|
@ -144,6 +144,7 @@ type PropTypes = {
|
||||||
barMarginBottom?: number;
|
barMarginBottom?: number;
|
||||||
onPress?: Function;
|
onPress?: Function;
|
||||||
renderTooltip?: Function;
|
renderTooltip?: Function;
|
||||||
|
leftShiftForTooltip?: number;
|
||||||
leftShiftForLastIndexTooltip?: number;
|
leftShiftForLastIndexTooltip?: number;
|
||||||
};
|
};
|
||||||
type lineConfigType = {
|
type lineConfigType = {
|
||||||
|
@ -1542,6 +1543,7 @@ export const BarChart = (props: PropTypes) => {
|
||||||
onPress={props.onPress}
|
onPress={props.onPress}
|
||||||
xAxisTextNumberOfLines={xAxisTextNumberOfLines}
|
xAxisTextNumberOfLines={xAxisTextNumberOfLines}
|
||||||
renderTooltip={props.renderTooltip}
|
renderTooltip={props.renderTooltip}
|
||||||
|
leftShiftForTooltip={props.leftShiftForTooltip || 0}
|
||||||
leftShiftForLastIndexTooltip={
|
leftShiftForLastIndexTooltip={
|
||||||
props.leftShiftForLastIndexTooltip || 0
|
props.leftShiftForLastIndexTooltip || 0
|
||||||
}
|
}
|
||||||
|
@ -1610,6 +1612,7 @@ export const BarChart = (props: PropTypes) => {
|
||||||
onPress={props.onPress}
|
onPress={props.onPress}
|
||||||
xAxisTextNumberOfLines={xAxisTextNumberOfLines}
|
xAxisTextNumberOfLines={xAxisTextNumberOfLines}
|
||||||
renderTooltip={props.renderTooltip}
|
renderTooltip={props.renderTooltip}
|
||||||
|
leftShiftForTooltip={props.leftShiftForTooltip || 0}
|
||||||
leftShiftForLastIndexTooltip={
|
leftShiftForLastIndexTooltip={
|
||||||
props.leftShiftForLastIndexTooltip || 0
|
props.leftShiftForLastIndexTooltip || 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue