'Plotly table subplot disable dragging columns
I have 2 plotly subplots, a surface plot and table plot. By default table plots have columns which you can drag and move, I want to disable this feature, I have found the command
config = {'staticPlot': True}
fig.show(config=config)
works but this also affects the surface plot which doesn't display properly. how do I set this config only on the table subplot? Also is there a way the table can behave like regular html text where i can select and copy values? Right now it is like an image i cannot select a cell. Thank you
fig = make_subplots(
rows=2, cols=1,
row_heights=[0.9, 0.5],
vertical_spacing=0.03,
specs=[[{"type": "surface"}],
[{"type": "table"}]])
fig_table = go.Table(
header=dict(
values=[""] + desired_x_axis,
font=dict(size=12),
align="left"
),
cells=dict(
font=dict(size=11),
values=z_values,
align = "left",
fill=dict(color=['#ced9e4','#F0F8FF']))
)
config = {'staticPlot': True}
fig.show(config=config)
Solution 1:[1]
I have been looking for a Plotly funcionality to easily disable this drag-and-drop behavior for a while and I did not found anything. One simply way to achieve it -only for the first table, extendible for others- is to add this JavaScript line to the code (I use the argument include_plotlyjs of the function fig.to_html(), but there should be other ways):
document.getElementsByClassName("table")[0].style.pointerEvents = "none";
With this is not needed to include {'staticPlot': True}.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Carlos P |
