javascript - 水平和垂直条形图视图的按钮,但轴无法更改
问题描述
我正在使用plotly.js处理条形图,并希望创建两个按钮来在水平视图和垂直视图之间切换。
但是,我的 x 轴更改代码似乎不起作用。
以下是故障的屏幕截图和我的代码:
垂直视图图像 (x 轴没有切换,y 轴不是计数而是类别)
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>
)
}
提前致谢!
解决方案
推荐阅读
- anylogic - 如何使按钮触发事件(定时器)?
- javascript - 需要从数组中删除字符串
- sql - SQL:分组和计数,但前提是所有记录都大于阈值
- corda - 如何在不重新部署节点的情况下创建 CorDapp jar 文件?
- java - jSerialComm - SerialPortEvent.getReceivedData() 在收到 Arduino 消息时返回 null
- google-cloud-platform - Google Cloud Console - 通过克隆设置 VM 实例
- azure - Azure asp.net core 2.2 获得高 CPU 使用率
- java - 同步多个线程之间的状态
- spring-boot - Spring Boot & RabbitMQ:消息转换内容类型
- javascript - 将 React 添加到工作区失败,EACCES:权限被拒绝,mkdir '/home/mint/.cache/Cypress'