angularjs指令上的DevExtreme图表更新-仅上次创建的图表更新

angularjs指令上的DevExtreme图表更新-仅上次创建的图表更新,angularjs,angularjs-directive,devexpress,angularjs-scope,Angularjs,Angularjs Directive,Devexpress,Angularjs Scope,我正在尝试更新多个DevExtreme图表。每个图表都绑定到指令隔离范围上的聊天设置。指令作用域数据源绑定到其作用域上的应用程序控制器模型。更新一个图表时,一切都正常,但当它有更多的图表时,只更新最后创建的图表 遵循我的指令代码 app.directive('prismaHistogram', function () { var directiveDefinitionObject = { restrict: 'E', scope: {

我正在尝试更新多个DevExtreme图表。每个图表都绑定到指令隔离范围上的聊天设置。指令作用域数据源绑定到其作用域上的应用程序控制器模型。更新一个图表时,一切都正常,但当它有更多的图表时,只更新最后创建的图表

遵循我的指令代码

app.directive('prismaHistogram', function () {
    var directiveDefinitionObject = {
        restrict: 'E',
        scope: {
            name:  '@',
            model: '=',
            id: '=id',
            deleteFunction: '&',
        },
        replace: false,
        templateUrl: './directives/prismaHistogram.html',
        controller: ['$scope', function ($scope) {

            $scope.refresh = function(model){

                $scope.model = model;
                $scope.datasource = [];

                $scope.model.stats.avg = parseFloat($scope.model.stats.avg).toFixed(2).toString();

                $scope.model.bins.forEach(function (bin, indxex) {
                    var temp = { Label: bin.label, Freq: +bin.count };
                    $scope.datasource.push(temp);
                });

                $scope.serviceChartSettings = {
                    //dataSource: $scope.datasource,
                    adaptiveLayout: {
                        keepLabels: false,
                    },
                    legend: {
                        visible: false
                    },
                    size: {
                        height: 250
                    },
                    argumentAxis: {
                        axisDivisionFactor: 30
                    },
                    series: {
                        argumentField: "Label",
                        valueField: "Freq",
                        //name: "My oranges",
                        type: "bar",
                        color: '#005b82'
                    },
                    bindingOptions: {
                        dataSource: 'datasource'
                    }
                };

                //$scope.$apply(function () {
                //    // force chartjs refresh
                //});

            }

            $scope.$watch('model', function (newModelVal, oldModelVal){
                $scope.refresh(newModelVal);
            });      //attaches an watcher to model to do grid refresh

            //$scope.$watch('model', $scope.refresh());      //attaches an watcher to model to do grid refresh

            $scope.onCloseClick = function () {
                $scope.deleteFunction({ id: $scope.id });
            };

            $scope.refresh($scope.model);
        }]
    }

    return directiveDefinitionObject;
});
Dev建议使用数据存储进行更新,并将刷新显式封装在$apply(function(){})调用中,这对我来说不起作用,因为触发图表更新的事件是范围变量更改,这已在apply()中完成。我试过使用这家商店,但结果是一样的

这是一个DevExtreme图表错误吗?有人能找到解决办法吗?谢谢大家