mirror of
https://github.com/status-im/react-native-gifted-charts.git
synced 2025-02-23 09:08:13 +00:00
Added adjustToWidth prop in Line and Area Charts, added xAxisLabelTexts and xAxisLabelTextStyle props to Bar, Line and Area charts
This commit is contained in:
parent
783a4a6304
commit
40aea30c92
@ -154,6 +154,8 @@ The properties of this line chart can be controlled using the `lineConfig` prop
|
|||||||
| yAxisIndicesColor | ColorValue | Color of the pointers on the X axis | black |
|
| yAxisIndicesColor | ColorValue | Color of the pointers on the X axis | black |
|
||||||
| yAxisIndicesColor | Boolean | To hide axes, rules, labels altogether | false |
|
| yAxisIndicesColor | Boolean | To hide axes, rules, labels altogether | false |
|
||||||
| yAxisLabelTexts | Array<string> | Array of label texts to be displayed along y axis | null |
|
| yAxisLabelTexts | Array<string> | Array of label texts to be displayed along y axis | null |
|
||||||
|
| xAxisLabelTexts | Array<string> | Array of label texts to be displayed below x axis | null |
|
||||||
|
| xAxisLabelTextStyle | object | Style of label texts to be displayed below x axis | null |
|
||||||
| rotateLabel | Boolean | To rotate the X axis labels (by 60deg) | false |
|
| rotateLabel | Boolean | To rotate the X axis labels (by 60deg) | false |
|
||||||
| hideOrigin | Boolean | To hide the y Axis label at origin (i.e. 0) | false |
|
| hideOrigin | Boolean | To hide the y Axis label at origin (i.e. 0) | false |
|
||||||
| labelWidth | number | Width of the Label text appearing below the bar (under the X axis) | barWidth |
|
| labelWidth | number | Width of the Label text appearing below the bar (under the X axis) | barWidth |
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
| stepValue | number | Value of 1 step/section in the Y axis | 20 |
|
| stepValue | number | Value of 1 step/section in the Y axis | 20 |
|
||||||
| stepHeight | number | Height of 1 step/section in the Y axis | 20 |
|
| stepHeight | number | Height of 1 step/section in the Y axis | 20 |
|
||||||
| spacing | number | Distance between 2 consecutive bars in the Bar chart | 20 |
|
| spacing | number | Distance between 2 consecutive bars in the Bar chart | 20 |
|
||||||
|
| adjustToWidth | Boolean | When set to true, it auto computes the spacing value to fit the Line chart in the available width | false |
|
||||||
| backgroundColor | ColorValue | Background color of the Bar chart | \_ |
|
| backgroundColor | ColorValue | Background color of the Bar chart | \_ |
|
||||||
| disableScroll | Boolean | To disable horizontal scroll | false |
|
| disableScroll | Boolean | To disable horizontal scroll | false |
|
||||||
| showScrollIndicator | Boolean | To show horizontal scroll indicator | false |
|
| showScrollIndicator | Boolean | To show horizontal scroll indicator | false |
|
||||||
@ -142,6 +143,8 @@ When you are using the `dataPointLabelComponent`, make sure to provide the `data
|
|||||||
| yAxisIndicesColor | ColorValue | Color of the pointers on the X axis | black |
|
| yAxisIndicesColor | ColorValue | Color of the pointers on the X axis | black |
|
||||||
| yAxisIndicesColor | Boolean | To hide axes, rules, labels altogether | false |
|
| yAxisIndicesColor | Boolean | To hide axes, rules, labels altogether | false |
|
||||||
| yAxisLabelTexts | Array<string> | Array of label texts to be displayed along y axis | null |
|
| yAxisLabelTexts | Array<string> | Array of label texts to be displayed along y axis | null |
|
||||||
|
| xAxisLabelTexts | Array<string> | Array of label texts to be displayed below x axis | null |
|
||||||
|
| xAxisLabelTextStyle | object | Style of label texts to be displayed below x axis | null |
|
||||||
| rotateLabel | Boolean | To rotate the X axis labels (by 60deg) | false |
|
| rotateLabel | Boolean | To rotate the X axis labels (by 60deg) | false |
|
||||||
| hideOrigin | Boolean | To hide the y Axis label at origin (i.e. 0) | false |
|
| hideOrigin | Boolean | To hide the y Axis label at origin (i.e. 0) | false |
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-gifted-charts",
|
"name": "react-native-gifted-charts",
|
||||||
"version": "1.2.2",
|
"version": "1.2.3",
|
||||||
"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": [
|
||||||
|
@ -25,6 +25,7 @@ type Props = {
|
|||||||
|
|
||||||
item: itemType;
|
item: itemType;
|
||||||
index: number;
|
index: number;
|
||||||
|
label: String;
|
||||||
containerHeight?: number;
|
containerHeight?: number;
|
||||||
maxValue: number;
|
maxValue: number;
|
||||||
spacing?: number;
|
spacing?: number;
|
||||||
@ -108,6 +109,8 @@ const RenderBars = (props: Props) => {
|
|||||||
opacity,
|
opacity,
|
||||||
animationDuration,
|
animationDuration,
|
||||||
autoShiftLabels,
|
autoShiftLabels,
|
||||||
|
label,
|
||||||
|
labelTextStyle,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const barMarginBottom =
|
const barMarginBottom =
|
||||||
@ -527,8 +530,8 @@ const RenderBars = (props: Props) => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{isAnimated
|
{isAnimated
|
||||||
? renderAnimatedLabel(item.label || '', item.labelTextStyle, item.value)
|
? renderAnimatedLabel(label, labelTextStyle, item.value)
|
||||||
: renderLabel(item.label || '', item.labelTextStyle, item.value)}
|
: renderLabel(label, labelTextStyle, item.value)}
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -11,6 +11,7 @@ type Props = {
|
|||||||
topLabelComponent?: Component;
|
topLabelComponent?: Component;
|
||||||
topLabelContainerStyle?: Style;
|
topLabelContainerStyle?: Style;
|
||||||
opacity?: number;
|
opacity?: number;
|
||||||
|
label: String;
|
||||||
labelTextStyle?: any;
|
labelTextStyle?: any;
|
||||||
disablePress?: boolean;
|
disablePress?: boolean;
|
||||||
|
|
||||||
@ -66,6 +67,8 @@ const RenderStackBars = (props: Props) => {
|
|||||||
spacing,
|
spacing,
|
||||||
rotateLabel,
|
rotateLabel,
|
||||||
xAxisThickness,
|
xAxisThickness,
|
||||||
|
label,
|
||||||
|
labelTextStyle,
|
||||||
} = props;
|
} = props;
|
||||||
const disablePress = props.disablePress || false;
|
const disablePress = props.disablePress || false;
|
||||||
const renderLabel = (label: String, labelTextStyle: any) => {
|
const renderLabel = (label: String, labelTextStyle: any) => {
|
||||||
@ -246,7 +249,7 @@ const RenderStackBars = (props: Props) => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{static2DSimple(item)}
|
{static2DSimple(item)}
|
||||||
{renderLabel(item.label || '', item.labelTextStyle)}
|
{renderLabel(label || '', labelTextStyle)}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -119,6 +119,8 @@ type PropTypes = {
|
|||||||
hideOrigin?: Boolean;
|
hideOrigin?: Boolean;
|
||||||
labelWidth?: number;
|
labelWidth?: number;
|
||||||
yAxisLabelTexts?: Array<string>;
|
yAxisLabelTexts?: Array<string>;
|
||||||
|
xAxisLabelTexts?: Array<string>;
|
||||||
|
xAxisLabelTextStyle?: any;
|
||||||
yAxisLabelPrefix?: String;
|
yAxisLabelPrefix?: String;
|
||||||
yAxisLabelSuffix?: String;
|
yAxisLabelSuffix?: String;
|
||||||
autoShiftLabels?: Boolean;
|
autoShiftLabels?: Boolean;
|
||||||
@ -1385,6 +1387,15 @@ export const BarChart = (props: PropTypes) => {
|
|||||||
barBorderRadius={props.barBorderRadius}
|
barBorderRadius={props.barBorderRadius}
|
||||||
barBackgroundPattern={props.barBackgroundPattern}
|
barBackgroundPattern={props.barBackgroundPattern}
|
||||||
patternId={props.patternId}
|
patternId={props.patternId}
|
||||||
|
label={
|
||||||
|
item.label ||
|
||||||
|
(props.xAxisLabelTexts && props.xAxisLabelTexts[index]
|
||||||
|
? props.xAxisLabelTexts[index]
|
||||||
|
: '')
|
||||||
|
}
|
||||||
|
labelTextStyle={
|
||||||
|
item.labelTextStyle || props.xAxisLabelTextStyle
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
@ -1436,6 +1447,15 @@ export const BarChart = (props: PropTypes) => {
|
|||||||
barBackgroundPattern={props.barBackgroundPattern}
|
barBackgroundPattern={props.barBackgroundPattern}
|
||||||
patternId={props.patternId}
|
patternId={props.patternId}
|
||||||
barMarginBottom={props.barMarginBottom}
|
barMarginBottom={props.barMarginBottom}
|
||||||
|
label={
|
||||||
|
item.label ||
|
||||||
|
(props.xAxisLabelTexts && props.xAxisLabelTexts[index]
|
||||||
|
? props.xAxisLabelTexts[index]
|
||||||
|
: '')
|
||||||
|
}
|
||||||
|
labelTextStyle={
|
||||||
|
item.labelTextStyle || props.xAxisLabelTextStyle
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
@ -247,6 +247,8 @@ type propTypes = {
|
|||||||
textShiftX?: number;
|
textShiftX?: number;
|
||||||
textShiftY?: number;
|
textShiftY?: number;
|
||||||
yAxisLabelTexts?: Array<string>;
|
yAxisLabelTexts?: Array<string>;
|
||||||
|
xAxisLabelTexts?: Array<string>;
|
||||||
|
xAxisLabelTextStyle?: any;
|
||||||
width?: number;
|
width?: number;
|
||||||
yAxisLabelPrefix?: String;
|
yAxisLabelPrefix?: String;
|
||||||
yAxisLabelSuffix?: String;
|
yAxisLabelSuffix?: String;
|
||||||
@ -254,6 +256,7 @@ type propTypes = {
|
|||||||
scrollAnimation?: Boolean;
|
scrollAnimation?: Boolean;
|
||||||
noOfSectionsBelowXAxis?: number;
|
noOfSectionsBelowXAxis?: number;
|
||||||
labelsExtraHeight?: number;
|
labelsExtraHeight?: number;
|
||||||
|
adjustToWidth?: Boolean;
|
||||||
};
|
};
|
||||||
type referenceConfigType = {
|
type referenceConfigType = {
|
||||||
thickness: number;
|
thickness: number;
|
||||||
@ -422,7 +425,15 @@ export const LineChart = (props: propTypes) => {
|
|||||||
props.initialSpacing === 0 ? 0 : props.initialSpacing || 40;
|
props.initialSpacing === 0 ? 0 : props.initialSpacing || 40;
|
||||||
const thickness = props.thickness || 2;
|
const thickness = props.thickness || 2;
|
||||||
|
|
||||||
const spacing = props.spacing === 0 ? 0 : props.spacing || 60;
|
const adjustToWidth = props.adjustToWidth || false;
|
||||||
|
|
||||||
|
const spacing =
|
||||||
|
props.spacing === 0
|
||||||
|
? 0
|
||||||
|
: props.spacing ||
|
||||||
|
(adjustToWidth
|
||||||
|
? ((props.width || 200) - initialSpacing) / data.length
|
||||||
|
: 60);
|
||||||
|
|
||||||
const xAxisThickness = props.xAxisThickness || 1;
|
const xAxisThickness = props.xAxisThickness || 1;
|
||||||
const dataPointsHeight1 =
|
const dataPointsHeight1 =
|
||||||
@ -2941,14 +2952,20 @@ export const LineChart = (props: propTypes) => {
|
|||||||
{isAnimated
|
{isAnimated
|
||||||
? renderAnimatedLabel(
|
? renderAnimatedLabel(
|
||||||
index,
|
index,
|
||||||
item.label,
|
item.label ||
|
||||||
item.labelTextStyle,
|
(props.xAxisLabelTexts && props.xAxisLabelTexts[index]
|
||||||
|
? props.xAxisLabelTexts[index]
|
||||||
|
: ''),
|
||||||
|
item.labelTextStyle || props.xAxisLabelTextStyle,
|
||||||
item.labelComponent,
|
item.labelComponent,
|
||||||
)
|
)
|
||||||
: renderLabel(
|
: renderLabel(
|
||||||
index,
|
index,
|
||||||
item.label,
|
item.label ||
|
||||||
item.labelTextStyle,
|
(props.xAxisLabelTexts && props.xAxisLabelTexts[index]
|
||||||
|
? props.xAxisLabelTexts[index]
|
||||||
|
: ''),
|
||||||
|
item.labelTextStyle || props.xAxisLabelTextStyle,
|
||||||
item.labelComponent,
|
item.labelComponent,
|
||||||
)}
|
)}
|
||||||
{/* {renderLabel(index, item.label, item.labelTextStyle)} */}
|
{/* {renderLabel(index, item.label, item.labelTextStyle)} */}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user