Hello,
I know I can render plotly graphs in raw html, can I do the same thing with dash_table.DataTable
instances?
For example, the following code produces a standalone html file that we can open in a browser
import plotly.express as px
import pandas as pd
df = pd.DataFrame({'field': ['a', 'b'], 'total': [3, 4]})
fig = px.bar(df, x='field', y='total')
html_output = f"""<html>
<head>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
<div id='divPlotly'></div>
<script>
var plotly_data = {fig.to_json()}
Plotly.react('divPlotly', plotly_data.data, plotly_data.layout);
</script>
</body>
</html>
"""
with open('file.html', 'w') as f:
f.write(html_output)
Can I do something similar with a dash_table.DataTable
? For example, consider
from dash_table import DataTable
from dash_table.Format import Format, Scheme
INTEGER_FORMAT = Format(precision=2, scheme=Scheme.decimal_integer, group=',')
df = pd.DataFrame({'a': [1, 2, 3], 'b': [2, 1, 3]})
columns = [dict(id=col, name=col,
type='numeric',
format=INTEGER_FORMAT,
hideable=True) for col in df.columns]
table = DataTable(columns=columns,
data=df.to_dict('records'),
sort_action="native")
Is there a way that I can display table
in a standalone html file?
Many thanks!