Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chart doesn't reload when new data is added to it #834

Closed
erayerdem opened this issue Apr 3, 2019 · 2 comments
Closed

Chart doesn't reload when new data is added to it #834

erayerdem opened this issue Apr 3, 2019 · 2 comments
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@erayerdem
Copy link

erayerdem commented Apr 3, 2019

class App extends Component {
  
   state= {
    data : {
      labels: ['A', 'B', 'C'],
      datasets: [
        {
          data: [300, 50, 100],
          backgroundColor: [
            "#FF6384",
            "#36A2EB",
            "#FFCE56"
          ],
          hoverBackgroundColor: [
            "#FF6384",
            "#36A2EB",
            "#FFCE56"
          ]
        }]
    }
   }
  handle =(event)=> {
   let a={...this.state};
   ++a.data.datasets[0].data[0]; 
   this.setState({
     ...a
   }); 
   
  
   event.preventDefault();
  }
  render() {
      
    return (
      <div>
        <div className="buttonlike">       
         <button   onClick={this.handle}>
          Hello World</button>
          </div>
        <div>
          <Chart  type="pie" data={this.state.data} />
        </div>
      </div>
    );
  }
}

export default App;

@mertsincan mertsincan changed the title Chart not reload shouldComponentUpdate always false Chart doesn't reload when new data is added to it Apr 22, 2019
@mertsincan mertsincan self-assigned this Apr 22, 2019
@mertsincan mertsincan added the Type: Bug Issue contains a defect related to a specific component. label Apr 22, 2019
@mertsincan mertsincan added this to the 3.1.3 milestone Apr 22, 2019
@mertsincan
Copy link
Member

Hi,

Thanks a lot for the sample code. But, next time, please use our codesandbox link to create a test project;
https://codesandbox.io/s/qjx332qq4

@RevanthGovindan
Copy link

HI, even there is no data change chart rerenders again and again please resolve this as soon as possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

No branches or pull requests

3 participants