question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onPress in PieChart response slow or no response

See original GitHub issue

When 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:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

4reactions
MatthieuCoelhocommented, Dec 26, 2018

I found a workaround by reading other issues. You can use “onPressIn” or “onPressOut” instead of “onPress”

0reactions
usrbowecommented, Nov 16, 2019

Closing due to no activity.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found