Highcharts NG一次只显示一个点。动画

时间:2016-10-28 05:45:41

标签: javascript angularjs highcharts

我想一次只显示一个点。作为其传播点。

 var dataLength = $scope.performanceConfig.series[0].data.length;
    for (var i = 0; i <= dataLength; i++) {
                    appendBar(i,timeOutTime)
    }
  function appendBar(i) {

                $timeout(function () {
                    $scope.fullScreenPerformanceConfig.series[0].data = [];
                    $scope.fullScreenPerformanceConfig.series[1].data = [];
                    $scope.fullScreenPerformanceConfig.series[0].data.push($scope.performanceConfig.series[0].data[i])
                    $scope.fullScreenPerformanceConfig.series[1].data.push($scope.performanceConfig.series[1].data[i])
                    $timeout(function () {
                        $scope.$apply();
                    }, 500);
                }, 1000);
            }

通过这种方法,我的浏览器卡住了。哪种方式更好。

1 个答案:

答案 0 :(得分:0)

解决了我自己:P

appendBar(0,dataLength);
function appendBar(i,dataLength) {
            var percentAge =(i / dataLength ) * 100;

                $timeout(function () {
                    if(i!=dataLength){
                        $scope.fullScreenPerformanceConfig.series = [];
                        angular.forEach($scope.performanceConfig.series, function (item, i) {
                            $scope.fullScreenPerformanceConfig.series.push({name: item.name, data: [],color:item.color});
                        });
                        $scope.fullScreenPerformanceConfig.series[0].data = [];
                        $scope.fullScreenPerformanceConfig.series[1].data = [];

                    }
                    $scope.fullScreenPerformanceConfig.series[0].data.push($scope.performanceConfig.series[0].data[i])
                    $scope.fullScreenPerformanceConfig.series[1].data.push($scope.performanceConfig.series[1].data[i])
                    $scope.barLoadStatus = Number(percentAge);
                    $timeout(function () {
                        $scope.$apply();
                        $scope.fullScreenChartConfig['chartObj'].redraw()
                    }, 100);
                    appendBar(i+1,dataLength);
                }, 1500);

        }