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

162
Views
Volver a la vista anterior plotly JS

Tengo una trama que se parece a:

Gráfica de series temporales apiladas.

El eje x se comparte y los ejes y no. Actualmente tengo un código que al hacer doble clic en un rastro en la leyenda eliminará los otros dos rastros y mostrará solo un rastro. Aquí está el código relevante:

 var myPlot = document.getElementById('graph'); myPlot.on('plotly_legenddoubleclick', function(data){ var trace = data.curveNumber + 1; if (trace == 1 && flag2 == 0) { var layout_update = {title: "Historical Trend", autosize: true, xaxis: {title:"Date", type: "date", rangeselector: {buttons: [{count: 1,label: '1m',step: 'month',stepmode: 'backward'},{count: 3,label: '3m',step: 'month',stepmode: 'backward'},{count: 6,label: '6m',step: 'month',stepmode: 'backward'},{step: 'all'}]}},yaxis: {title:"Vertical",fixedrange: true}}; Plotly.update('graph', layout_update); Plotly.deleteTraces('graph', 1); Plotly.deleteTraces('graph', 1); flag2 = 1; } else if (trace == 2 && flag2 == 0) { var layout_update = {title: "Historical Trend", autosize: true, xaxis: {title:"Date", type: "date", rangeselector: {buttons: [{count: 1,label: '1m',step: 'month',stepmode: 'backward'},{count: 3,label: '3m',step: 'month',stepmode: 'backward'},{count: 6,label: '6m',step: 'month',stepmode: 'backward'},{step: 'all'}]}},yaxis: {title:"Horizontal",fixedrange: true}}; Plotly.update('graph', layout_update); Plotly.deleteTraces('graph', 0); Plotly.deleteTraces('graph', 1); flag2 = 1; } else if (trace == 3 && flag2 == 0) { var layout_update = {title: "Historical Trend", autosize: true, xaxis: {title:"Date", type: "date", rangeselector: {buttons: [{count: 1,label: '1m',step: 'month',stepmode: 'backward'},{count: 3,label: '3m',step: 'month',stepmode: 'backward'},{count: 6,label: '6m',step: 'month',stepmode: 'backward'},{step: 'all'}]}},yaxis: {title:"Axial",fixedrange: true}}; Plotly.update('graph', layout_update); Plotly.deleteTraces('graph', 0); Plotly.deleteTraces('graph', 0); flag2 = 1; } });

Quiero incluir una cláusula con flag == 1 que devolverá la vista a la vista de trama 3. ¿Cómo puedo hacer esto?

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!