Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

161
Visualizações
Update data in Barchart from API in Vue

Calling an Api to get the values and putting them in the List but the list in data function is not being updated.

created() {
  // API CALL FOR BARCHAR
  var getStandardBarchart = async() => {
  //var currentarray =[]

  // API CALL TO KEIKAI for BARCGARTS
  var myHeaders = new Headers();
   myHeaders.append("Content-Type", "application/json");
   //var raw = JSON.stringify({"input_values": input_values, "output_values": output_values});
   var raw = JSON.stringify({"input_values": {},"output_values": [ "barchart1","barchart2","barchart3","barchart4","barchart5","barchart6","barchart7","barchart8"  ]});

   var requestOptions = {
     method: 'POST',
     headers: myHeaders,
     body: raw,
     redirect: 'follow'
   };


   await fetch("/api", requestOptions)
     .then(response => response.json())
     .then(result => {
        var barChart = [];

        //var value
        Object.keys(result).forEach(function(key) {
        let specificValue = parseInt(result[key])
          barChart.push(specificValue) 
        })
        console.log(barChart)
        console.log(this.Agricultural_production_Animal_production_Cattle[1].imagecontent.barchart1.values[0][2])
       // this.Agricultural_production_Animal_production_Cattle[1].imagecontent.barchart1.values[0][1]=15

        // this.Agricultural_production_Animal_production_Cattle[1].imagecontent.barchart1.values[0] = barChart.splice(0, 4);
        // this.Agricultural_production_Animal_production_Cattle[1].imagecontent.barchart1.values[1] = barChart.splice(0, 4);


      })
     .catch(error => console.log('error', error));



 }

getStandardBarchart()
}

What I want is that the values in the data function should be updated by the barchart[] list. But if I push something in list before api or give some default value to the list it is not undefined in Values : [barchart[0]] gives undefined.

data:function(){
  {imagecontent:
    
   {barchart1:{barid: "bar_Agricultural_production_Animal_production_Cattle",names:["sdjhfb", "derfgas", "Pdft", "dfdfs", "dfsdfat"],
   values:[[barchart[0], 10, 5, 150],[87, 80, 25, 35]],
   textxaxis:["future", "present"] }}
   }]
  }
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda