Struggling to wrap my head around how to update data on a graph without the proper Angular service knowledge. All I want is to retrieve a JSON object with one GET request and save it locally on my controller. This way, I can use the original JSON to display the initial chart and a modified version based on user input for an updated view. Below is the code snippet from my controller:
`
angular.module('scattChartApp')
.controller('ChartCtrl', function($scope, $http, $cacheFactory) {
$http.get('chartConfig.json').success(function(response) {
$scope.options = response.options;
$scope.data = response.data;
$scope.initData = angular.copy($scope.data);
});
$scope.update = function(user){
var a, b, c, d, e;
a = user.a; b = user.b; c = user.c; d = user.d; e = user.e;
var data = $scope.data;
if(a !== "" && b !== "" && c !== "" && d !== "" && e !== ""){
for(var i = 0; i<$scope.data.length; i++){
for(var j = 0; j<$scope.data[i].values.length; j++){
var x = $scope.data[i].values[j].x;
var y = $scope.data[i].values[j].y;
var z = $scope.data[i].values[j].size;
data[i].values[j].x = a*x + b*y;
data[i].values[j].y = c*x + d*y;
data[i].values[j].size = e*e*z;
}
}
$scope.$apply();
}
};
$scope.reset = function(){
$scope.user = {};
$scope.data = angular.copy($scope.initData);
$scope.$apply();
};
});`
Having issues with continuity in the scaling process when using this Plunker (input proper values and click update): http://plnkr.co/edit/n4bDl7LYoylW5tWbRA6g?p=preview