Afficher un tableau que me retrourne une fonction
Bonjour,
En fait, je test un exemple de la librairie Angular-nvd3 avec le plunker dont le lien est http://plnkr.co/edit/zsNxBJ?p=preview
Par contre, ne n'ai aucun moyen de savoir ce que renvoie la fonction generate(). En fait, ce que je veux, c'est juste voir à quoi ressemble le tableau renvoyé par la fonction generate().
Même si cela concerne une librairie AngularJS, le code ci-dessous est du Javascript, d'où ma question dans ce forum.
Voilà le code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
function generateData(){
var testdata = stream_layers(7,10+Math.random()*100,.1).map(function(data, i) {
return {
key: 'Stream' + i,
values: data.map(function(a){a.y = a.y * (i <= 1 ? -1 : 1); return a})
};
});
testdata[0].type = "area"
testdata[0].yAxis = 1
testdata[1].type = "area"
testdata[1].yAxis = 1
testdata[2].type = "line"
testdata[2].yAxis = 1
testdata[3].type = "line"
testdata[3].yAxis = 2
testdata[4].type = "bar"
testdata[4].yAxis = 2
testdata[5].type = "bar"
testdata[5].yAxis = 2
testdata[6].type = "bar"
testdata[6].yAxis = 2
return testdata;
}
/* Inspired by Lee Byron's test data generator. */
function stream_layers(n, m, o) {
if (arguments.length < 3) o = 0;
function bump(a) {
var x = 1 / (.1 + Math.random()),
y = 2 * Math.random() - .5,
z = 10 / (.1 + Math.random());
for (var i = 0; i < m; i++) {
var w = (i / m - y) * z;
a[i] += x * Math.exp(-w * w);
}
}
return d3.range(n).map(function() {
var a = [], i;
for (i = 0; i < m; i++) a[i] = o + o * Math.random();
for (i = 0; i < 5; i++) bump(a);
return a.map(stream_index);
});
}
function stream_index(d, i) {
return {x: i, y: Math.max(0, d)};
} |
J'ai essayé d'afficher le contenu de ce que renvoie generate() en faisant:
Code:
1 2 3
|
var test = generate();
alert(test); |
Mais ça ne fonctionne pas. Pouvez vous me dire un moyen d'afficher le contenu de cette fonction s'il vous plaît?
Je vous remercie par avance,