Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

187
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda