react-native-pie icon indicating copy to clipboard operation
react-native-pie copied to clipboard

strokeCap={'round'} Produces undesired results

Open SiyabongaNzulwana opened this issue 5 years ago • 4 comments

@nihgwu @SpencerLynn @zgordon01 @kevkevinpal are you guys aware of this issue? Screenshot 2020-08-24 at 16 58 08

if you know of a solution to this please share... Thank you in advance.

SiyabongaNzulwana avatar Aug 25 '20 09:08 SiyabongaNzulwana

Can you please provide a code snippet?

Also note a few disclaimers in the strokeCap section of our docs, which might be applying here.

strokeCap ( round , butt ) defaults to butt - string, optional PLEASE NOTE If using strokeCap={'round'} it is highly recommended to use a higher innerRadius (around 60% of radius and higher) in addition to not having very small percentage sections. This will ensure proper display. We hope to address these issues in future PRs

zgordon01 avatar Aug 25 '20 22:08 zgordon01

@zgordon01 thanks for the response, I did read the disclaimers, however even if I change/play around with the radius and inner_Radius, I still get the same results. below is the snippet of code you asked for.

  render() {
    return (
      <View style={styles.container}>
        <View style={styles.pieViewWrapper}>
          <View style={styles.yourConnections}>
            <Pie
              radius={120}
              innerRadius={100}
              sections={[
                {
                  percentage: 50,
                  color: '#48d1cc',
                },
              ]}
              backgroundColor="#EBECF0"
              strokeCap={'round'}
            />
          </View>
        </View>
        <View style={styles.pieViewWrapper}>
          <View style={styles.connectionsPerfomance}>
            <Pie
              radius={150}
              innerRadius={130}
              sections={[
                {
                  percentage: 90,
                  color: '#66cdaa',
                },
              ]}
              backgroundColor="#EBECF0"
              strokeCap={'round'}
            />
          </View>
        </View>
        <View style={styles.pieViewWrapper}>
          <View style={styles.communityPerfomance}>
            <Pie
              radius={180}
              innerRadius={160}
              sections={[
                {
                  percentage: 40,
                  color: '#ffd700',
                },
              ]}
              backgroundColor="#EBECF0"
              strokeCap={'round'}
            />
          </View>
        </View>
      </View>
    )
  }
}

const styles = StyleSheet.create({
  container: {
    justifyContent: 'center',
    alignItems: 'center',
    height: height * 0.5,
    width: width,
  },
  pieViewWrapper: {
    position: 'absolute',
    justifyContent: 'center',
    alignItems: 'center',
  },
  yourConnections: {
    alignItems: 'center',
    justifyContent: 'center',
  },
  connectionsPerfomance: {
    alignItems: 'center',
    justifyContent: 'center',
  },
  communityPerfomance: {
    alignItems: 'center',
    justifyContent: 'center',
  },
  points: {
    color: '#000',
    fontSize: 35,
    fontWeight: 'bold',
  },
  pointsText: {
    color: 'grey',
    fontSize: 10,
    alignSelf: 'center',
  },
})

SiyabongaNzulwana avatar Aug 26 '20 12:08 SiyabongaNzulwana

@zgordon01, @nihgwu I have managed to figure out what was going wrong with the strokeCap prop on version 1.1.2 of react-native-pie I have sent a PR for it.

SiyabongaNzulwana avatar Aug 27 '20 16:08 SiyabongaNzulwana

I'm still getting this issue how do u guys solve this

gokulrajkp avatar Jun 22 '22 08:06 gokulrajkp