[英]plotly.graph_objects.table static table
I am using plotly.go to make a table and export to html, however the columns on the table are not static, they can be dragged and rearranged with the mouse. I am using plotly.go to make a table and export to html, however the columns on the table are not static, they can be dragged and rearranged with the mouse. I'm trying to find a simple way to make the table static while still exporting to html.
我试图找到一种简单的方法来制作表格 static,同时仍导出到 html。
import pandas as pd
import plotly.graph_objects as go
df = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
columns=['a', 'b', 'c'])
fig = go.Figure(data=[go.Table(
header=dict(
values=list(df),
line_color='darkslategray',
fill_color = 'lightskyblue',
align='center'),
cells=dict(
values=[df.a, df.b, df.c],
line_color='darkslategray',
fill_color='lightcyan',
align='center'))
])
fig.show()
fig.to_html('table.html')
I've tried using staticPlot: true
, but it doesn't seem like that's an attribute in graph_objects.我试过使用
staticPlot: true
,但它似乎不是 graph_objects 中的属性。
I was able to get a static table by adding the following to the code:通过将以下代码添加到代码中,我能够获得 static 表:
fig.show()
fig.to_html('table.html', config={'staticPlot': True})
The one thing to keep in mind is that the mouse icon still changes to look like columns can be dragged, but the columns are static.需要记住的一件事是鼠标图标仍然会变为可以拖动的列,但列是 static。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.