I have a compiled directive that contains an angular-charts.js directive in it.
I've noticed that when the container of that chart has ng-show
or ng-hide
as an attribute, the chart wont update -- it just doesn't show at all.
Here is a plunker that demonstrates this (see listeningComponent
in scripts.js
directive)
Here the problem is not with the ng-show and ng-hide attribute.
The root cause behind this is is DOM manupulation.
Here ng-show condition is executing first and directive is loading after that so your variable value is changing here after directive loading.
So try with ng-if
instead ng-show. It will solve your problem.
Change your listner.html template.
<h4>listeningComponent Directive</h4>
<div class="listener">
<p>
{{listenertext}}
</p>
<div class="bar-chart-box" ng-if="loading === false">
Bar Graph with ng-show<br>
<canvas class="chart chart-bar"
data="chartData.data"
labels="chartData.labels"
series="chartData.series">
</canvas>
</div>
<hr>
<div class="bar-chart-box">
Bar Graph without ng-show<br>
<canvas class="chart chart-bar"
data="chartData.data"
labels="chartData.labels"
series="chartData.series">
</canvas>
</div>
</div>