Вы можете построить ту же самую HTML-структуру внутри графика.
Следующий код является рабочим примером.
Требование: ваш код CSS должен храниться в static / stylesheet.css
Пример:
import dash
import dash_core_components as dcc
import dash_html_components as html
from flask import send_from_directory
import os
app = dash.Dash(__name__)
server = app.server
# Configure Samples
sample1 = html.Div([
dcc.Link('Sample1', href='javascript:void(0);', className='summary'),
html.Div('Details of this summary', className='detail')
], className='wrapper')
sample2 = html.Div([
dcc.Link('Sample2', href='javascript:void(0);', className='summary'),
html.Div('Details of this summary', className='detail')
], className='wrapper')
sample3 = html.Div([
dcc.Link('Sample3', href='javascript:void(0);', className='summary'),
html.Div('Details of this summary', className='detail')
], className='wrapper')
# Define layout
app.layout = html.Div([
sample1,
sample2,
sample3
])
app.scripts.append_script({"external_url": [
"https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"
]})
# Add css file (locally hosted)
app.css.append_css({"external_url": [
"static/stylesheet.css"
]})
# Serving local static files
@app.server.route('/static/<path:path>')
def static_file(path):
static_folder = os.path.join(os.getcwd(), 'static')
return send_from_directory(static_folder, path)
if __name__ == '__main__':
app.run_server(debug=True)