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

179
Visualizações
How can I add new values (arrays) to chartjs after completing a simulation

I have a app that stores the value when you complete a simluation, the first question have 4 alternatives, if the user press one of theese he gets a new alternative and each alternative have different choises like:

Beginning of simulation

[one] [two] [tree] [four]

If a user press [one] he gets alternatives: [red] [green] [blue]:

If a user press [two] he gets alternatives: [apple][kiwi]:

If a user press [tree] he gets alternatives: [sky] [ocean] [dirt] [earth]:

If a user press [four] he gets alternatives: [black][red]

I have stored the value of the end results in MongoDB and i would like to use it in ChartJS to create a Pie chart so i can see what people are selecting from the start of the simulation in each [one] [two] [tree] [four].

I also need to keep the chartjs updated so when a customer do a simulation it should add another value to the chartjs

So the question is how can i make a function that adds new values from the simulation and shows it in the chartJS

here is the simulation database

const SIMULATION = [
  {
    id: "1",
    name: "one",
    applications: [
      {
        id: "A10",
        name: "red",
      },
      {
        id: "A20",
        name: "green",
      },
      {
        id: "A30",
        name: "blue",
      },
    ],
  },
  {
    id: "2",
    name: "two",
    applications: [
      {
        id: "B1",
        name: "apple",
      },
      {
        id: "B2",
        name: "kiwi",
      },
    ],
  },
  {
    id: "3",
    name: "tree",
    applications: [
      {
        id: "C1",
        name: "sky",
      },
      {
        id: "C2",
        name: "ocean",
      },
      {
        id: "C3",
        name: "dirt",
      },
      {
        id: "C4",
        name: "earth",
      },
    ],
  },
  {
    id: "4",
    name: "four",
    applications: [
      {
        id: "D1",
        name: "black",
      },
      {
        id: "D2",
        name: "red",
      },
    ],
  },
];

I need to filter the respone I get in:

{
  id:"1",
  name: "two",
  application: "red"
}
         

{
  id:"3",
  name: "one",
  application: "kiwi"
}

to add upp in the chartJs pie

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