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

Is it possible to clear LineChart view along with its data? #37

Closed
nbat opened this issue Jan 9, 2014 · 2 comments
Closed

Is it possible to clear LineChart view along with its data? #37

nbat opened this issue Jan 9, 2014 · 2 comments

Comments

@nbat
Copy link

nbat commented Jan 9, 2014

Hello, I'm feeding $scope.chart.data (see example) with arrays multiple times during app runtime. Everything works fine and it redraws well. But sometimes I get empty arrays from the server which is normal, thats when the api starts complaining about empty columns and leaves me with an error.

Is there any way to clear the chart when I dont have any data to feed it with and really dont want to leave the old data visible as well as any irrelevant errors?

Thanks

@jonnysamps
Copy link

I use ng-show for this.

<div google-chart chart="chart" ng-show="chart.data" />

@nbat
Copy link
Author

nbat commented Jan 9, 2014

Thanks, real neat, somehow I overlooked such a simple solution. Though in production it would flash an error message when data comes back.

I was thinking of adding an event listener to 'link' function,like 'clearChartData' right next to 'resizeMsg' listener, and then call the $scope.chartWrapper.clear() inside it. To my surprise it works only after the listener gets this message second time when its being $rootScope.$emit('clearChartData'). Calling $scope.chartWrapper.clear() twice doesn't help. Hope I will have more time to pin that weird thing.

@nbering nbering closed this as completed Jun 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants