Hello i have the following JSON object
This is created by the following code :
$( document ).ready( function(){
$.ajax({
type: 'GET',
url: 'DonneesGraph.php?Base='+jsvar,
dataType: 'json',
success: function( retour ) {
// Ici le traitement des données retournées placé dans quelquechose=JSON ? appelé retour
console.log( "retour" , retour );
And then i have sorted this with following code witch is working :
let newArray4 = retour.map((d) => ({ date: timeConv(d.MoyDate), measurement: +d.ProductionPV}));
let newArray6 = retour.map((d) => ({ date: timeConv(d.MoyDate), measurement: +d.EauDepart }));
let newArray7 = retour.map((d) => ({ date: timeConv(d.MoyDate), measurement: +d.EauRetour }));
Now i am trying to do it dynamically with the following :
while(i <= Lenght)
{
if (typeof Nom[i] !== 'undefined') //Test si array présent et défini et initialisé
{
console.log('Içi',Nom[i]);// Nom[i] is defined AND initialized
var NomCourbe = Nom[i];
var NomArray = 'newArray'+[i];
var testing = 'd.EauRetour';
console.log('Nom de la courbe',NomCourbe);
console.log('Nom de l array',NomArray);
console.log('Colonne',C2);
newArray[i] = retour.map((d) => ({ date: timeConv(d.MoyDate), measurement: +Nom[i] }));
i++;
} else
{
console.log('Là',i);
i++;}
}
But this is not working.The console.log is showing newArray1 undefined.
I have tried different things as :
newArray1 = retour.map((d) => ({ date: timeConv(d.MoyDate), measurement: +testing }));
or
NomArray = retour.map((d) => ({ date: timeConv(d.MoyDate), measurement: +testing }));
But nothing works if someone can explain me why ? Thanks