I'm using angular charts, and I'm trying to display a chart that updates depending the current item selected, It works well on the first item I select, but after I select a second Item, It seems like the data from the first item selected is still present on the chart (although the data has changed completely), the problem looks like this:
app.controller("itemsAppController", function ($scope, $timeout, itemsData, itemsFactory, $filter) {
$scope.items = itemsData.Items;
$scope.itemSelected = false;
$scope.currentItem = {};
$scope.selectItem = function (itemId) {
$scope.itemSelected = false;
var foundItem = $filter('filter')($scope.items, { ItemId: itemId }, true);
var item = foundItem[0];
$scope.currentItem = item;
$timeout(function () {
$scope.itemSelected = true;
}, 500);
};
$scope.chartOptions = {
tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>%"
}
});
The canvas:
<div ng-show="itemSelected">
<canvas class="chart chart-pie" data="currentItem.MostUsedChampionsPrePatchData" labels="currentItem.MostUsedChampionsPrePatchLabels" legend="true" options="chartOptions"></canvas>
</div>
And the object data looks like this:
Any ideas of what is causing this problem?
EDIT: Here's a fiddle showing the problem: https://jsfiddle.net/PGjtS/130/
When recreating it, the problem arise when I included the animation and the ng-show