Chartjs-AngularJS hide and show a char

1πŸ‘

I assume you are not using any angular directive for Chart.js (from the SO tags). If so, you need to draw the line only after the Chart.js canvas is visible. So wrap the $scope.secondGraph=false; in a block and put the var cts=... ; new Chart(ctx).Bar...; right after that.

Fiddle = https://jsfiddle.net/pbog134e/

Also looking at your HTML, if you dynamically want the chart to update, you either have to watch the data and labels or use something like http://jtblin.github.io/angular-chart.js/

0πŸ‘

You are using simple canvas bit do you if Angular is aware of your chart present on the page? It’s not!

Best approach would be to try to bring charts into Angular eco system i.e. either write your own chart directives or use a angular chart library..

Check this :
http://krispo.github.io/angular-nvd3/#/

Leave a comment