Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

95
Views
Plotly.js - Cambio de valor dentro de las propiedades del objeto

Soy un principiante de javascript y tengo un proyecto en el que necesito usar Plotly.js para visualizar datos en el gráfico. Actualmente estoy aprendiendo a hacer un gráfico de barras básico. aquí está mi código:

HTML

 <head> <script src='https://cdn.plot.ly/plotly-2.4.2.min.js'></script> </head> <body> <input type="checkbox" id="cb15">2015 <input type="checkbox" id="cb16">2016 <input type="checkbox" id="cb17">2017 <div id='grafik'></div> </body>

JavaScript

 var data = [ { x: ['Banyumanik', 'Gunungpati', 'Mijen', 'Tembalang'], y: [18, 29, 20, 23], type: 'bar', width: '0.5', marker: { color: 'red' } } ]; function switchBar() { var cb15 = document.getElementById('cb15'); var cb16 = document.getElementById('cb16'); var cb17 = document.getElementById('cb17'); if (cb15.checked) { data[0].y = [19,25,16,21]; } else if (cb16.checked) { data[0].y = [10,23,7,20] } else if (cb17.checked) { data[0].y = [21,17,14,26] } } Plotly.newPlot('grafik', data);

¿Alguien puede ayudarme a hacer que mi gráfico de barras cambie el valor según la casilla de verificación marcada? Muchas gracias por adelantado.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!