I'm using n-3 charts (http://n3-charts.github.io/) to create some graphs in my angular web app. Here is some sample data of some points where there is a data values with 3 series:
$scope.data = [
{x: new Date(1391448620668), current: 0, baseline: 0, original: 0, val_3: 0},
{x: new Date(1391535020668), current: 0.993, baseline: 3.894, original: 8.47, val_3: 14.347},
{x: new Date(1391621420668), current: 1.947, baseline: 7.174, original: 13.981, val_3: 19.991},
{x: new Date(1391707820668), current: 2.823, baseline: 9.32, original: 14.608, val_3: 13.509},
{x: new Date(1391794220668), current: 3.587, baseline: 9.996, original: 10.132, val_3: -1.167},
];
In my code I'm trying to create this under that same construct like so:
$scope.addGraphData = function(){
var firstSubDate = $scope.FirstSubjectDoseDt;
var xValues = new Array(); // date data points
var cValues = new Array(); // current values
var bValues = new Array(); // baseline values
var oValues = new Array(); // original baseline values
for (var i = 0; i < $scope.currentData.length; i++) {
xValues[i] = new Date(firstSubDate+([i]*2628000000));
cValues[i] = $scope.currentData[i].currentValue;
bValues[i] = $scope.currentData[i].baselineValue;
oValues[i] = $scope.currentData[i].origValue;
};
for (var i = 0; i < $scope.currentData.length; i++) {
$scope.data[i] = {x: xValues[i], current: cValues[i], baseline: bValues[i], original: oValues[i]};
};
console.log("Graph Data: " + $scope.data);
};
But the values in the $scope.data array exist, but the console gives me
Graph Data: [object Object],[object Object],[object Object]
for my 3 data points and it plots nothing. Where am I going wrong here?
$digest
loop? – rtcherry Mar 4 '14 at 0:12console.log("Graph Data:", $scope.data)
is usually more useful – Jesse the Game Mar 4 '14 at 0:38