Estou a receber um array na variavel "myObj" ([00, 12, 45, 34, 23, 34, 34, 34, 05, 42, 21, 11, 31]). E precisava de colocar esse valor no series, ou seja substituir o array que lá está hardcoded. Tipo: series = [myObj, ...]
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myObj = JSON.parse(this.responseText); // Valor que tenho
}
};
xmlhttp.open("GET", "api/api_get_fogo.php", true);
xmlhttp.send();
var dataSales = {
labels: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
series: [
[00, 12, 45, 34, 23, 34, 34, 34, 05, 42, 21, 11, 31], // Onde quero substituir
[00, 24, 36, 03, 34, 10, 15, 20, 48, 19, 49, 32, 02]
]
};
if
é executado muito depois dodataSales
ter sido executado.