I currently use Plotly Dash to create a webapp to visualize data. The syntax involves using dcc.Graph to render an HTML Div as follows. Below the html.Div is the code to render the plot figure. The x and y axis values come from a Pandas DF. Can anyone recommend a way to use an IF statement to check if a given column exists and then proceed to return the following code. Plotly Dash gives an error when a 'fig' variable does not exist
html.Div([
html.Div([
html.H3('Chart'),
dcc.Graph(id='Chart',figure = chart_fig
)
sensor3_trace_day1 = Scatter(
y = sensor_3_day1['BG Calibration (mg/dl)'],
x = sensor_3_day1['Current (nA)'],
mode = 'markers',
name = 'Sensor 3 Day 1'
)
data = [sensor1_trace]
layout = Layout(showlegend=True, height = 600, width = 600, title='Day 1: BG Cal vs Current',xaxis={'title':'Current [nA]'},yaxis={'title':'BG Calibration (mg/dl)'})
chart_fig = dict(data=data, layout=layout)
iplot(chart_fig)