I have a Dash app that uses some callbacks for an interactive graph with some radio buttons, is it possible to export all of this as a HTML object? I want to host it somewhere for people to come and see but it would be only for selected users.
Here’s my code.
import matplotlib.pyplot as plt
from dash.exceptions import PreventUpdate
import plotly.io as pio
pio.renderers.default = "browser"
pio.renderers
from dash import Dash, dcc, html, Input, Output
import dash
import pandas as pd
path = r'C:\Users\T\22.csv'
df = pd.read_csv(path)
df.columns = df.columns.str.replace('Unnamed: 0', 'DateTimeUtc')
b_z = ['DK1','DK2','FI','NO1','NO2','NO3','NO4','NO5','SE1','SE2','SE3','SE4']
zone_dict = {'DK':'Denmark', 'FI':'Finland', 'NO':'Norway', 'SE':'Sweden' }
ID = 'DK'
zone_ID = zone_dict[ID]
app = dash.Dash(__name__)
app.layout = html.Div(children = [html.H1('Errors)'),
dcc.Checklist(id='my-checklist', options=[{'label': col, 'value': col} for col in df.columns[1:]],
value=df.columns.tolist(),
labelStyle={'display': 'inline-block'}
),
dcc.Graph(id='my-line-graph', figure={}),
])
@app.callback(
Output(component_id='my-line-graph', component_property='figure'),
Input(component_id='my-checklist', component_property='value')
)
def update_plot(input_zone):
if input_zone !=[]:
figure = px.line(data_frame= df, x='DateTimeUtc', y= input_zone, width=1900, height=900)
figure.update_xaxes(rangeslider_visible=True) #ranges slider
return figure
else:
raise PreventUpdate
if __name__ == '__main__':
app.run_server(debug=False)