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

213
Vistas
Buttons for horizontal and vertical bar chart views, but axes failed to change

I’m using plotly.js to work on a bar chart and want to create two buttons to switch between horizontal and vertical views.

However, my code for the change in x-axis doesn’t seem to work.

Below are screenshots of the malfunction and my code:

Horizontal view image

Vertical view image (x-axis did not switch, y-axis not in counts but in categories)

    var data = [
    //horizontal graph
    {
      type: 'bar',
      x: xData2,
      y: yData2,
      marker: {
        color: 'rgba(255, 100, 102, 0.7)',
      },
      name:'Bar Chart',
      orientation:'h',
      xaxis: { title: 'Count' },
      yaxis: { title: xAxisAttribute },
      
    },
    //vertical graph
    {
      type: 'bar',
      y: yData,
      x: xData,
      orientation:'v',
      marker: {
        color: 'rgba(255, 100, 102, 0.7)',
      },
      name:'Bar Chart',
      visible: false
    }]
  var button_layer_2_height = 1.2;
  var updatemenus=[
      {
          buttons: [
              {
                  args: [{'visible': [true, false]}],
                  label: 'Horizontal View',
                  method: 'update'
              },
              {
                  args: [{'visible': [false, true]}],
                  label: 'Vertical View',
                  method: 'update'
              },
          ],
          direction: 'left',
          pad: {'r': 10, 't': 10},
          showactive: true,
          type: 'buttons',
          x: 0.1,
          xanchor: 'left',
          y: button_layer_2_height,
          yanchor: 'top'
      },
  ]  
  let layout = {
    title: title || 'Untitled',
    autosize: true,
    hovermode:'closest',
    updatemenus: updatemenus,
    };

  return (
    <div>
      <Plot
        data ={data}
        layout = {layout}
        config = {config}
          />
      </div>
    ) 
    }

Thanks in advance!

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