Chartjs-Storybook: Changing the value of the control doesnot rerender the Chart.js canvas

1👍

The getGeoData method which sets up the chart is called only during component initialization and it wont run when @Input values change. For these scenarios Angular provides ngOnChanges lifecycle hook. And this is where we need to tell Angular what needs to be done when @Input values change.

ngOnChanges(changes: SimpleChanges) {
  for (const propName in changes) {
    switch(propName) {
      case 'url':
      // action that needs to happen when url changes
      break;
      case 'chartProjection':
      // action that needs to happen when chartProjection changes
      break;
    }
  }
}

Leave a comment