Estoy usando plotly.js para trabajar en un gráfico de barras y quiero crear dos botones para cambiar entre vistas horizontales y verticales .
Sin embargo, mi código para el cambio en el eje x no parece funcionar.
A continuación se muestran capturas de pantalla del mal funcionamiento y mi código:
Imagen de vista vertical (el eje x no cambió, el eje y no en recuentos sino en categorías)
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> ) }¡Gracias por adelantado!