onPress in PieChart response slow or no response
See original GitHub issueWhen does it happen?
1、iOS:on iPhone6P、 iPhone7P、 iPhone8P、iPhonX click pieChart, onPress function in PieChart response slow or no response 2、Android: After clicking the page, click pieChart no response.
What platform?
- iOS (11.3) iPhone6P、 iPhone7P、 iPhone8P、iPhonX
- Android
React Native version: 0.55.4
Code to reproduce
// put code here
import React, { Component } from 'react';
import {
View,
Text,
Dimensions
} from 'react-native';
import { PieChart } from 'react-native-svg-charts'
export default class App extends Component {
constructor(props){
super(props);
this.state = {
selectedSlice: {
label: '',
value: ''
},
labelWidth: 0
}
}
render() {
const {labelWidth, selectedSlice} = this.state;
const {label, value} = selectedSlice;
const keys = ['google', 'facebook', 'linkedin', 'youtube', 'Twitter'];
const values = [15, 25, 35, 30, 55];
const colors = ['#600080', '#9900cc', '#c61aff', '#d966ff', '#ecb3ff'];
const data = keys.map((key, index) => {
return {
key,
value: values[index],
svg: {fill: colors[index]},
arc: {outerRadius: label === key ? '100%' : '90%', padAngle: 0},
onPress: () => {this.setState({selectedSlice: {label: key, value: values[index]}}); console.log(key, index)}
}
})
const deviceWidth = Dimensions.get('window').width
return (
<View style={{ justifyContent: 'center', flex: 1 }}>
<PieChart
style={{ height: 200 }}
outerRadius={ '90%' }
innerRadius={ '40%' }
data={data}
/>
<Text
onLayout={({ nativeEvent: { layout: { width }}}) => {
this.setState({ labelWidth: width});
}}
style={{
position: 'absolute',
left: deviceWidth / 2 - labelWidth / 2,
textAlign: 'center'
}}>
{`${label} \n ${value}`}
</Text>
</View>
)
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top Results From Across the Web
How to render labels along the circumference of PieChart ...
Asking for help, clarification, or responding to other answers. · Making statements based on opinion; back them up with references or personal ...
Read more >A Complete Guide to Pie Charts | Tutorial by Chartio
Pie charts are a common but often misused visualization to show division of a whole into parts. Learn how to get the most...
Read more >Controls and Dashboards | Charts - Google Developers
On this page, you'll see how to combine multiple charts into dashboards and give users controls to manipulate what data they show.
Read more >Pie Chart (Results) - Qualtrics
The Inner Radius setting controls what percentage of the center of the Pie Chart should be empty. By default, this is set to...
Read more >Fullstack react native sample code - Weebly
There's no specific answer to how often we should isolate different UI logic ... After slowly beginning with hardcoded data and building our...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found a workaround by reading other issues. You can use “onPressIn” or “onPressOut” instead of “onPress”
Closing due to no activity.