diff --git a/src/app/components/filehandling/fileHandlingService.js b/src/app/components/filehandling/fileHandlingService.js index 232782e..f64f19e 100644 --- a/src/app/components/filehandling/fileHandlingService.js +++ b/src/app/components/filehandling/fileHandlingService.js @@ -206,7 +206,7 @@ // Start loading bar $timeout(function () { cfpLoadingBar.start(); - }, 100); + }, 77); if (!fs.existsSync(config.api.script)) { // If there is no AcmacsCore.bundle return api.asyncTest().then(function () { @@ -396,21 +396,24 @@ ]).then(function (data) { var unprocessed_data = JSON.parse(data); var progressive_data = []; - var intermediate_size = unprocessed_data.intermediate_layouts.length; - var frequency = parseInt(intermediate_size/40); // selected intermediate states so that total number of steps be 40 (40 has been selected randomly) - //@TODO, write an algorithm which finds most distinguished changes to show as animation/intermediate states - var count = 0; - unprocessed_data.intermediate_layouts.forEach(function (layout, index) { - if(index ==0 || (index%frequency) == 0 || isNaN(index%frequency) || index == intermediate_size) { - progressive_data[count] = parseLayoutData(formatDataForIntermediateLayout(unprocessed_data, index)); - count ++; - } - }); + if(unprocessed_data.intermediate_layouts) { + var intermediate_size = unprocessed_data.intermediate_layouts.length; + var frequency = parseInt(intermediate_size / 77); // selected intermediate states so that total number of steps be 77 (77 has been selected randomly) + //@TODO, write an algorithm which finds most distinguished changes to show as animation/intermediate states + var count = 0; + unprocessed_data.intermediate_layouts.forEach(function (layout, index) { + if (index == 0 || (index % frequency) == 0 || isNaN(index % frequency) || index == intermediate_size) { + progressive_data[count] = parseLayoutData(formatDataForIntermediateLayout(unprocessed_data, index)); + count++; + } + }); + } var map = unprocessed_data.map; var map_data = {map:map[0], stress: map[0].stress}; mapData = parseLayoutData((map_data)); progressive_data[progressive_data.length] = mapData; fileHandler.setMapIsChanged(true); + cfpLoadingBar.set(0.7); return progressive_data; }); }, function (reason) { diff --git a/src/app/components/map/mapController.js b/src/app/components/map/mapController.js index cab9890..5a573fa 100644 --- a/src/app/components/map/mapController.js +++ b/src/app/components/map/mapController.js @@ -46,7 +46,6 @@ $scope.pointsMoved = false; $scope.data = result; getErrorConnectionLines(); - cfpLoadingBar.complete(); }); }); diff --git a/src/app/components/map/mapDirective.js b/src/app/components/map/mapDirective.js index 3d5274d..20b5bde 100644 --- a/src/app/components/map/mapDirective.js +++ b/src/app/components/map/mapDirective.js @@ -162,6 +162,7 @@ app.directive('d3Map', ['$rootScope', '$window', '$timeout', 'toolbar', 'toolbar // Enter nodeGroup = nodeGroup.data(data.layout); + scope.data.stress = data.stress; nodeGroup.enter().append("path") .attr("class", "point") @@ -1198,6 +1199,7 @@ app.directive('d3Map', ['$rootScope', '$window', '$timeout', 'toolbar', 'toolbar scope.$watch('data', function (newVals) { if (!_.isUndefined(newVals)) { if(_.isArray(newVals)) { + cfpLoadingBar.set(0.7); var size = newVals.length; var count = 0; _.each(newVals, function(newVal) { @@ -1207,6 +1209,7 @@ app.directive('d3Map', ['$rootScope', '$window', '$timeout', 'toolbar', 'toolbar if(size == count) { scope.data = newVal; scope.data.stress = newVal.stress; + cfpLoadingBar.complete(); } }, 2000); })