Skip to content

Commit fa1e473

Browse files
percent size
1 parent c1ef57d commit fa1e473

4 files changed

Lines changed: 10 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ yarn add react-native-speedometer-chart
3333
| innerCircleStyle | null | object | no | |
3434
| outerCircleStyle | null | object | no | |
3535
| halfCircleStyle | null | object | no | |
36+
| percentSize | 0.5 | number | no | |
3637

3738

3839
## Basic Usage

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-speedometer-chart",
3-
"version": "0.6.3",
3+
"version": "0.6.4",
44
"description": "Speedometer Chart component for React Native",
55
"main": "src/index.js",
66
"author": "Lucas Monteiro",

src/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { View, Text } from 'react-native';
33
import PropTypes from 'prop-types';
44
import { getStyles } from './rules';
55

6-
const Speedometer = ({ value, totalValue, size, outerColor, innerColor, internalColor, style, innerCircleStyle, outerCircleStyle, halfCircleStyle, showText, text, textStyle, showLabels, labelStyle, showPercent, percentStyle }) => {
7-
const styles = getStyles(size);
6+
const Speedometer = ({ value, totalValue, size, outerColor, innerColor, internalColor, style, innerCircleStyle, outerCircleStyle, halfCircleStyle, showText, text, textStyle, showLabels, labelStyle, showPercent, percentStyle, percentSize }) => {
7+
const styles = getStyles(size, percentSize);
88
const degreesValue = (value > totalValue) ? totalValue : value;
99
const percentValue = parseInt(String((value * 100) / totalValue).split('.')[0]);
1010
const degrees = ((degreesValue * 180) / ((totalValue === 0) ? 1 : totalValue)) - 90;
@@ -60,9 +60,10 @@ Speedometer.propTypes = {
6060
labelStyle: PropTypes.object,
6161
showPercent: PropTypes.bool,
6262
percentStyle: PropTypes.object,
63-
innerCircleStyle: PropTypes.object,
63+
innerCircleStyle: PropTypes.object,
6464
outerCircleStyle: PropTypes.object,
6565
halfCircleStyle: PropTypes.object,
66+
percentSize: PropTypes.number,
6667
};
6768

6869
Speedometer.defaultProps = {
@@ -78,6 +79,7 @@ Speedometer.defaultProps = {
7879
labelStyle: {},
7980
showPercent: false,
8081
percentStyle: {},
82+
percentSize: 0.5,
8183
};
8284

8385
export default Speedometer;

src/rules.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const getStyles = (size) => ({
1+
export const getStyles = (size, percent = 0.5) => ({
22
outerCircle: {
33
justifyContent: 'flex-end',
44
alignItems: 'center',
@@ -13,8 +13,8 @@ export const getStyles = (size) => ({
1313
justifyContent: 'flex-end',
1414
alignItems: 'center',
1515
backgroundColor: '#fff',
16-
width: size * 0.5,
17-
height: (size / 2) * 0.5,
16+
width: size * percent,
17+
height: (size / 2) * percent,
1818
borderTopLeftRadius: size / 2,
1919
borderTopRightRadius: size / 2,
2020
paddingLeft: 3,

0 commit comments

Comments
 (0)