mardi 4 août 2015

jQuery flot load x-axis from array

I have a jQuery flot graph that loads the x-axis like so:

xaxis: {
  tickColor: 'transparent',
  tickDecimals: 0,
  ticks: ticks
},

If I set the ticks variable like so it works, and the x-axis contains the 7 dates:

var ticks = [[1,"27/07"],[2,"28/07"],[3,"29/07"],[4,"30/07"],[5,"31/07"],[6,"01/08"],[7,"02/08"]];
console.log(ticks);

working

However if I generate the variable from an array like so:

var ticks = JSON.stringify(myArray);
console.log(ticks);

It doesn't work, the x-axis contains the numbers 1 - 7.

not working

Here is what the console.log shows:

console

It looks like my JSON.stringify is correct but I'm not sure what to do! Any ideas? Why is the first console.log entry coloured but the second one not? Is the format incorrect?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire