簡體   English   中英

plotly.graph_objects.table static 表

[英]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. 我試圖找到一種簡單的方法來制作表格 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')

我試過使用staticPlot: true ,但它似乎不是 graph_objects 中的屬性。

通過將以下代碼添加到代碼中,我能夠獲得 static 表:

fig.show()
fig.to_html('table.html', config={'staticPlot': True})

需要記住的一件事是鼠標圖標仍然會變為可以拖動的列,但列是 static。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM