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

163
Visualizações
Go back to previous view plotly JS

I have a plot which looks like:

Stacked time series plot.

The x-axis is shared and the y-axes are not. I currently have a code which when double-clicking a trace in the legend will delete the other two traces and show only the one trace. Here is the relevant code:

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;
                
                }

});

I want to include a clause with flag == 1 that will return the view to the 3 plot view. How can I do this?

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