Created
August 21, 2024 14:05
-
-
Save jtrive84/210c92fb90fe0ab83ab397c7e14b1ca7 to your computer and use it in GitHub Desktop.
Simple Dash pinmap application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import io | |
import os | |
import os.path | |
import sys | |
import time | |
import dash | |
from dash.dependencies import Input, Output | |
# import dash_auth | |
from dash import dcc | |
from dash import html | |
from dash import dash_table | |
import dash.dash_table.FormatTemplate as FormatTemplate | |
import numpy as np | |
import pandas as pd | |
import plotly.graph_objs as go | |
import pygeohash | |
VALID_AUTH_PAIRS = { | |
"skydog": "skydog", | |
} | |
__file__ = "C:/Users/i103455/repos/pinmap/app.py" | |
add2path = os.path.dirname(__file__) | |
sys.path.append(add2path) | |
# from prepdata import * | |
# excl_ = ["ATTAINED_AGE", "POLICY_NUMBER", "CLAIM_NUMBER", "FRAUD_INDICATIOR", | |
# "RESIDENT_STATE", "score", "priority", "DAILY_BENEFIT_INFL_BANDED", | |
# "SITUS_CURRENT", "PREMIUM_PAYMENT_MODE",] | |
# dfinput = dfall | |
# dfinput = dfinput.drop("FRAUD_INDICATOR", axis=1) # imported from prepdata | |
# claim_numbers = sorted(dfinput["CLAIM_NUMBER"].unique().tolist()) | |
# dftypes = dfinput.dtypes | |
# dftypes = dftypes[~dftypes.index.isin(excl_)].reset_index(drop=False) | |
# dftypes.columns = ["fieldname", "datatype"] | |
# dftypes["plot"] = dftypes["datatype"].map(lambda v: "hist" if v==np.float_ else "bar") | |
# dftypes = dftypes.sort_values("fieldname").reset_index(drop=True) | |
# dftypes["varid"] = ["var" + "{}".format(i).zfill(2) for i in range(dftypes.shape[0])] | |
def load_data(): | |
df = pd.read_csv("C:/Users/i103455/repos/pinmap/customers.csv") | |
# Get geohash for each lat lon pair. | |
df["Geohash"] = df.apply(lambda r: pygeohash.encode(latitude=r.Lat, longitude=r.Lon, precision=10), axis=1) | |
return df | |
dfinput = load_data() | |
# Dashboard initialization ----------------------------------------------------- | |
app = dash.Dash(__name__, external_stylesheets=["assets/css/bWLwgP.css"]) | |
# auth = dash_auth.BasicAuth(app, VALID_AUTH_PAIRS) | |
app.config["suppress_callback_exceptions"] = True | |
# Layout ----------------------------------------------------------------------- | |
layout_init = [ | |
html.Div([ | |
html.Div([ | |
html.H2("Policy Map"), | |
], style={"textAlign":"left", "width":"65%", "display":"inline-block"} | |
), | |
html.Div([ | |
html.Img(src="assets/logo2.jpg", style={"height":"70%", "width":"70%"}), | |
], style={"float":"right", "width":"35%", "display":"inline-block", "padding":2} | |
) | |
]), | |
] | |
# Hidden div to facilitate data update. | |
app.layout = html.Div([ | |
dcc.Tabs(id="tabs", children=[ | |
# dcc.Tab(label="Policy View", children=[ | |
# html.Div(layout_init), | |
# html.Div(id="intermediate", style={"display": "none"}), | |
# html.Div(id="ph", style={"display": "none"}) | |
# ]), | |
dcc.Tab(label="Tabular Summary", children=[ | |
html.Div(id="intermediate", style={"display": "none"}), | |
html.Div(id="ph", style={"display": "none"}), | |
html.Div([ | |
html.H2("Policy Viewer"), | |
], style={"textAlign":"left", "width":"65%", "display":"inline-block"} | |
), | |
html.Div([ | |
dash_table.DataTable( | |
# columns=[{"name": i, "id": i} for i in ["CLAIM_NUMBER", "POLICY_NUMBER", "priority"]], | |
# style_data={"border": "1px solid blue"}, | |
# style_table={"overflowX":"scroll"}, | |
# style_cell={'width': '150px'}, | |
# style_data_conditional=[{"if": {"row_index": 4}, "backgroundColor": "#3D9970", 'color': 'white'}] | |
# fixed_rows={"headers":True, "data":0}, | |
data=dfinput[["AccountNo", "Lat", "Lon", "Premium", "Geohash"]].to_dict("records"), | |
columns=[ | |
{"id": "AccountNo", "name": "AccountNo", "type": "text"}, | |
{"id": "Lat", "name": "Latitude", "type": "numeric"}, | |
{"id": "Lon", "name": "Longitude", "type": "numeric"}, | |
{"id": "Premium", "name": "Premium", "type": "numeric"}, | |
{"id": "Geohash", "name": "Geohash", "type": "text"} | |
], | |
style_header={"border":"1px solid pink", "textAlign":"center"}, | |
style_data_conditional=[ | |
{"if": {"row_index":"odd"}, "backgroundColor":"rgb(248, 248, 248)"}, | |
], | |
style_cell_conditional=[ | |
{"if": {"column_id": "AccountNo"}, "textAlign": "left", "width": "10px", "maxWidth": "10px", "minWidth": "10px"}, | |
{"if": {"column_id": "Lat"}, "textAlign": "right", "width": "10px", "maxWidth": "10px", "minWidth": "10px"}, | |
{"if": {"column_id": "Lon"}, "textAlign": "right", "width": "10px", "maxWidth": "10px", "minWidth": "10px"}, | |
{"if": {"column_id": "Premium"}, "textAlign": "right", "width": "10px", "maxWidth": "10px", "minWidth": "10px"}, | |
{"if": {"column_id": "Geohash"}, "textAlign": "right", "width": "10px", "maxWidth": "10px", "minWidth": "10px"}, | |
] | |
)], style={"padding":25, "width":"50%", "margin-left":"25%", "margin-right":"25%"} | |
) | |
]), | |
dcc.Tab(label="Map View", children=[ | |
# html.Div([ | |
# html.Label("Select Priority Threshold:"), | |
# html.Div(dcc.Dropdown( | |
# id="threshold", options=[{"label":i, "value":i} for i in np.arange(50, 101, 1)], | |
# value="90", placeholder="")), | |
# ], style={"width":200, "vertical-align":"middle", "padding":8}, | |
# ), | |
html.Div([ | |
dcc.Graph(id="mapview") | |
], style={"padding":0}) | |
]), | |
]) | |
]) | |
# ------------------------------------------------------------------------------ | |
# @app.callback( | |
# dash.dependencies.Output("claim_number", "options"), | |
# [dash.dependencies.Input("which_subset", "value")]) | |
# def update_claim_numbers(which_subset): | |
# """ | |
# Update options available in dropdown based on selcted radioitem. | |
# """ | |
# if which_subset=="both": | |
# claim_numbers_ = sorted(np.unique(dfinput["CLAIM_NUMBER"].values)) | |
# elif which_subset=="high": | |
# claim_numbers_ = sorted(np.unique(dfinput[dfinput.priority>50].CLAIM_NUMBER.values)) | |
# elif which_subset=="low": | |
# claim_numbers_ = sorted(np.unique(dfinput[dfinput.priority<=50].CLAIM_NUMBER.values)) | |
# return([{"label":i, "value":i} for i in claim_numbers_]) | |
# @app.callback( | |
# dash.dependencies.Output("mdsumm", "children"), | |
# [dash.dependencies.Input("intermediate", "children"), | |
# dash.dependencies.Input("claim_number", "value")] | |
# ) | |
# def update_md(_json, claim_number): | |
# """ | |
# Update markdown summary of given claim's values per attribute. | |
# """ | |
# # claim_number = "4301064194" | |
# # dfsubset_ = dfinput[dfinput["CLAIM_NUMBER"]==claim_number].reset_index(drop=True) | |
# dfsubset_ = pd.read_json(_json, orient="split").reset_index(drop=True) | |
# priority_ = dfsubset_.priority.values[0] | |
# md_str_ = "#### Summary for **{}** (priority score: {:.2f}): \n```".format(claim_number, priority_) | |
# vardict = {} | |
# for indx_ in range(dftypes.shape[0]): | |
# var_ = dftypes.loc[indx_, "fieldname"] | |
# val_ = dfsubset_.loc[0, var_] | |
# plot_ = dftypes.loc[indx_, "plot"] | |
# if plot_=="bar": | |
# # Determine which proportion of variable equal var_. | |
# dfvar_ = dfinput[var_].value_counts().sort_index().reset_index(drop=False) | |
# dfvar_["ratio"] = dfvar_[var_] / dfvar_[var_].sum() | |
# prop_ = dfvar_[dfvar_["index"]==val_]["ratio"].values[0] | |
# summstr_ = "* Proportion of records with {} = {}: {:.3f} \n".format(var_, val_, prop_) | |
# elif plot_=="hist": | |
# dfvar_ = dfinput[[var_]].sort_values(var_).reset_index(drop=True) | |
# dfvar_["cdf"] = dfvar_[var_] / dfvar_[var_].max() | |
# dfvar_["ecdf"] = (1 / dfvar_.shape[0]) | |
# dfvar_["ecdf"] = np.cumsum(dfvar_["ecdf"]) | |
# prop_ = dfvar_[dfvar_[var_]==val_]["ecdf"].values[0] | |
# summstr_ = "* Proportion of records with {} <= {}: {:.3f} \n".format(var_, val_, prop_) | |
# vardict[prop_] = summstr_ | |
# _, varstrs_ = zip(*sorted(vardict.items(), key=lambda v: abs(.5 - v[0]), reverse=True)) | |
# for mds_ in varstrs_: md_str_+=mds_ | |
# md_str_+="```" | |
# return(md_str_) | |
@app.callback( | |
dash.dependencies.Output("intermediate", "children"), | |
[dash.dependencies.Input("ph", "children")] | |
) | |
def filter_data(ph): | |
""" | |
Filter dfinput to selected claim_number. | |
""" | |
return dfinput.to_json(orient="split") | |
# @app.callback( | |
# dash.dependencies.Output("table", "children"), | |
# [dash.dependencies.Input("ph", "value")] | |
# ) | |
# def update_table(_json): | |
# """ | |
# Update rendered HTML table. Uses dash_table.DataTable. | |
# """ | |
# df = pd.read_json(_json, orient="split").reset_index(drop=True) | |
# data = df.to_dict("records") | |
# columns = [{"name": ii, "id": ii} for ii in df.columns] | |
# table = dash_table.DataTable( | |
# data=data, columns=columns, style_table={"overflowX": "scroll"}, | |
# # style_cell={"minWidth":"0px", "maxWidth":"250px",}, | |
# ) | |
# return table | |
@app.callback( | |
dash.dependencies.Output("mapview", "figure"), | |
[dash.dependencies.Input("intermediate", "children")] | |
) | |
def update_map(_json): | |
""" | |
Update rendered dash_table.DataTable. | |
""" | |
mapbox_token = "pk.eyJ1IjoianRyaXZlIiwiYSI6ImNseTYwdzJsZzAwbXQydnByZm9yMXZyOHAifQ.pKr-NmN905Wyi9xmjR25hQ" | |
df = pd.read_json(io.StringIO(_json), orient="split") | |
lats = df["Lat"].tolist() | |
lons = df["Lon"].tolist() | |
acct = df["AccountNo"].tolist() | |
prem = df["Premium"].tolist() | |
desc = [f"{ii}: {jj}" for ii, jj in zip(acct, prem)] | |
mid_lat = sum(lats) / len(lats) | |
mid_lon = sum(lons) / len(lons) | |
trace = go.Scattermapbox( | |
lat=lats, | |
lon=lons, | |
mode='markers', | |
marker=go.scattermapbox.Marker(size=20, color="red"), | |
text=desc | |
) | |
layout = go.Layout( | |
title=None, | |
autosize=True, | |
hovermode='closest', | |
height=825, | |
width=1200, | |
margin=dict(l=20, r=20, b=20, t=20, pad=4), | |
mapbox=dict( | |
accesstoken=mapbox_token, | |
bearing=0, | |
center=dict(lat=mid_lat, lon=mid_lon), | |
pitch=0, | |
zoom=6 | |
), | |
) | |
return({"data": [trace], "layout": layout}) | |
# @app.callback( | |
# dash.dependencies.Output("mapping", "figure"), | |
# [dash.dependencies.Input("intermediate", "children"), | |
# dash.dependencies.Input("threshold", "value")] | |
# ) | |
# def update_map(_json, threshold): | |
# """ | |
# Update rendered dash_table.DataTable. | |
# """ | |
# # dfsubset_ = dfinput[dfinput["CLAIM_NUMBER"]=="4301064194"].reset_index(drop=True) | |
# dfsubset_ = pd.read_json(_json, orient="split").reset_index(drop=True) | |
# dfmap_ = dfinput[dfinput.priority>=int(threshold)].reset_index(drop=True) | |
# dfmap_["count"] = 1 | |
# dfmap_["avg_priority"] = dfmap_.groupby("RESIDENT_STATE", as_index=False)["priority"].transform("mean") | |
# keepcols_ = ["RESIDENT_STATE", "count", "avg_priority"] | |
# dfmap_ = dfmap_[keepcols_].groupby(["RESIDENT_STATE", "avg_priority"], as_index=False).sum() | |
# dfmap_["text"] = dfmap_["RESIDENT_STATE"] + "<br>" + " Count " + dfmap_["count"].astype(np.str) + \ | |
# "<br>" + " Average Priority " + dfmap_["avg_priority"].astype(np.str) | |
# scl = [ | |
# [0.0, 'rgb(242,240,247)'], [0.2, 'rgb(218,218,235)'], [0.4, 'rgb(188,189,220)'], | |
# [0.6, 'rgb(158,154,200)'], [0.8, 'rgb(117,107,177)'], [1.0, 'rgb(84,39,143)'] | |
# ] | |
# trace_ = go.Choropleth( | |
# colorscale=scl, | |
# autocolorscale=False, | |
# locations=dfmap_["RESIDENT_STATE"], | |
# z=dfmap_["count"], | |
# locationmode="USA-states", | |
# text=dfmap_["text"], | |
# marker=go.choropleth.Marker(line=go.choropleth.marker.Line(color="rgb(255,255,255)", width=1)), | |
# # colorbar=go.choropleth.ColorBar(title="Frequency"), | |
# ) | |
# layout_ = go.Layout( | |
# title=go.layout.Title(text="Distribution of Priority Scores by State"), | |
# geo = go.layout.Geo( | |
# scope="usa", | |
# projection=go.layout.geo.Projection(type="albers usa"), | |
# showlakes=True, | |
# lakecolor='rgb(255, 255, 255)' | |
# ), | |
# ) | |
# return({"data":[trace_], "layout":layout_}) | |
# @app.callback( | |
# dash.dependencies.Output("var00", "figure"), | |
# [dash.dependencies.Input("intermediate", "children"), | |
# dash.dependencies.Input("claim_number", "value"),] | |
# ) | |
# def update_var00(_json, claim_number): | |
# """ | |
# Update visualizations based on attributes of selected CLAIM_NUMBER. | |
# Note that a figure represents a dictionary containing two keys: | |
# {"data":trace, "layout":layout}. | |
# """ | |
# # dfsubset_ = dfinput[dfinput["CLAIM_NUMBER"]=="4301064194"].reset_index(drop=True) | |
# dfsubset_ = pd.read_json(_json, orient="split") | |
# fieldname_ = dftypes.loc[0, "fieldname"] | |
# fieldval_ = dfsubset_.loc[0, fieldname_] | |
# plot_ = dftypes.loc[0, "plot"] | |
# if plot_=="bar": | |
# dexhibit_ = update_categorical( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# elif plot_=="hist": | |
# dexhibit_ = update_continuous( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# return(dexhibit_) | |
# @app.callback( | |
# dash.dependencies.Output("var01", "figure"), | |
# [dash.dependencies.Input("intermediate", "children"), | |
# dash.dependencies.Input("claim_number", "value"),] | |
# ) | |
# def update_var01(_json, claim_number): | |
# """ | |
# Update visualizations based on attributes of selected CLAIM_NUMBER. | |
# Note that a figure represents a dictionary containing two keys: | |
# {"data":trace, "layout":layout}. | |
# """ | |
# # dfsubset_ = dfinput[dfinput["CLAIM_NUMBER"]=="4301064194"].reset_index(drop=True) | |
# dfsubset_ = pd.read_json(_json, orient="split") | |
# fieldname_ = dftypes.loc[1, "fieldname"] | |
# fieldval_ = dfsubset_.loc[0, fieldname_] | |
# plot_ = dftypes.loc[1, "plot"] | |
# if plot_=="bar": | |
# dexhibit_ = update_categorical( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# elif plot_=="hist": | |
# dexhibit_ = update_continuous( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# return(dexhibit_) | |
# @app.callback( | |
# dash.dependencies.Output("var02", "figure"), | |
# [dash.dependencies.Input("intermediate", "children"), | |
# dash.dependencies.Input("claim_number", "value"),] | |
# ) | |
# def update_var02(_json, claim_number): | |
# """ | |
# Update visualizations based on attributes of selected CLAIM_NUMBER. | |
# Note that a figure represents a dictionary containing two keys: | |
# {"data":trace, "layout":layout}. | |
# """ | |
# # dfsubset_ = dfinput[dfinput["CLAIM_NUMBER"]=="4301064194"].reset_index(drop=True) | |
# dfsubset_ = pd.read_json(_json, orient="split") | |
# fieldname_ = dftypes.loc[2, "fieldname"] | |
# fieldval_ = dfsubset_.loc[0, fieldname_] | |
# plot_ = dftypes.loc[2, "plot"] | |
# if plot_=="bar": | |
# dexhibit_ = update_categorical( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# elif plot_=="hist": | |
# dexhibit_ = update_continuous( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# return(dexhibit_) | |
# @app.callback( | |
# dash.dependencies.Output("var03", "figure"), | |
# [dash.dependencies.Input("intermediate", "children"), | |
# dash.dependencies.Input("claim_number", "value"),] | |
# ) | |
# def update_var03(_json, claim_number): | |
# """ | |
# Update visualizations based on attributes of selected CLAIM_NUMBER. | |
# Note that a figure represents a dictionary containing two keys: | |
# {"data":trace, "layout":layout}. | |
# """ | |
# # dfsubset_ = dfinput[dfinput["CLAIM_NUMBER"]=="4301064194"].reset_index(drop=True) | |
# dfsubset_ = pd.read_json(_json, orient="split") | |
# fieldname_ = dftypes.loc[3, "fieldname"] | |
# fieldval_ = dfsubset_.loc[0, fieldname_] | |
# plot_ = dftypes.loc[3, "plot"] | |
# if plot_=="bar": | |
# dexhibit_ = update_categorical( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# elif plot_=="hist": | |
# dexhibit_ = update_continuous( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# return(dexhibit_) | |
# @app.callback( | |
# dash.dependencies.Output("var04", "figure"), | |
# [dash.dependencies.Input("intermediate", "children"), | |
# dash.dependencies.Input("claim_number", "value"),] | |
# ) | |
# def update_var04(_json, claim_number): | |
# """ | |
# Update visualizations based on attributes of selected CLAIM_NUMBER. | |
# Note that a figure represents a dictionary containing two keys: | |
# {"data":trace, "layout":layout}. | |
# """ | |
# # dfsubset_ = dfinput[dfinput["CLAIM_NUMBER"]=="4301064194"].reset_index(drop=True) | |
# dfsubset_ = pd.read_json(_json, orient="split") | |
# fieldname_ = dftypes.loc[4, "fieldname"] | |
# fieldval_ = dfsubset_.loc[0, fieldname_] | |
# plot_ = dftypes.loc[4, "plot"] | |
# if plot_=="bar": | |
# dexhibit_ = update_categorical( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# elif plot_=="hist": | |
# dexhibit_ = update_continuous( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# return(dexhibit_) | |
# @app.callback( | |
# dash.dependencies.Output("var05", "figure"), | |
# [dash.dependencies.Input("intermediate", "children"), | |
# dash.dependencies.Input("claim_number", "value"),] | |
# ) | |
# def update_var05(_json, claim_number): | |
# """ | |
# Update visualizations based on attributes of selected CLAIM_NUMBER. | |
# Note that a figure represents a dictionary containing two keys: | |
# {"data":trace, "layout":layout}. | |
# """ | |
# # dfsubset_ = dfinput[dfinput["CLAIM_NUMBER"]=="4301064194"].reset_index(drop=True) | |
# dfsubset_ = pd.read_json(_json, orient="split") | |
# fieldname_ = dftypes.loc[5, "fieldname"] | |
# fieldval_ = dfsubset_.loc[0, fieldname_] | |
# plot_ = dftypes.loc[5, "plot"] | |
# if plot_=="bar": | |
# dexhibit_ = update_categorical( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# elif plot_=="hist": | |
# dexhibit_ = update_continuous( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# return(dexhibit_) | |
# @app.callback( | |
# dash.dependencies.Output("var06", "figure"), | |
# [dash.dependencies.Input("intermediate", "children"), | |
# dash.dependencies.Input("claim_number", "value"),] | |
# ) | |
# def update_var06(_json, claim_number): | |
# """ | |
# Update visualizations based on attributes of selected CLAIM_NUMBER. | |
# Note that a figure represents a dictionary containing two keys: | |
# {"data":trace, "layout":layout}. | |
# """ | |
# # dfsubset_ = dfinput[dfinput["CLAIM_NUMBER"]=="4301064194"].reset_index(drop=True) | |
# dfsubset_ = pd.read_json(_json, orient="split") | |
# fieldname_ = dftypes.loc[6, "fieldname"] | |
# fieldval_ = dfsubset_.loc[0, fieldname_] | |
# plot_ = dftypes.loc[6, "plot"] | |
# if plot_=="bar": | |
# dexhibit_ = update_categorical( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# elif plot_=="hist": | |
# dexhibit_ = update_continuous( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# return(dexhibit_) | |
# @app.callback( | |
# dash.dependencies.Output("var07", "figure"), | |
# [dash.dependencies.Input("intermediate", "children"), | |
# dash.dependencies.Input("claim_number", "value"),] | |
# ) | |
# def update_var07(_json, claim_number): | |
# """ | |
# Update visualizations based on attributes of selected CLAIM_NUMBER. | |
# Note that a figure represents a dictionary containing two keys: | |
# {"data":trace, "layout":layout}. | |
# """ | |
# # dfsubset_ = dfinput[dfinput["CLAIM_NUMBER"]=="4301064194"].reset_index(drop=True) | |
# dfsubset_ = pd.read_json(_json, orient="split") | |
# fieldname_ = dftypes.loc[7, "fieldname"] | |
# fieldval_ = dfsubset_.loc[0, fieldname_] | |
# plot_ = dftypes.loc[7, "plot"] | |
# if plot_=="bar": | |
# dexhibit_ = update_categorical( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# elif plot_=="hist": | |
# dexhibit_ = update_continuous( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# return(dexhibit_) | |
# @app.callback( | |
# dash.dependencies.Output("var08", "figure"), | |
# [dash.dependencies.Input("intermediate", "children"), | |
# dash.dependencies.Input("claim_number", "value"),] | |
# ) | |
# def update_var08(_json, claim_number): | |
# """ | |
# Update visualizations based on attributes of selected CLAIM_NUMBER. | |
# Note that a figure represents a dictionary containing two keys: | |
# {"data":trace, "layout":layout}. | |
# """ | |
# # dfsubset_ = dfinput[dfinput["CLAIM_NUMBER"]=="4301064194"].reset_index(drop=True) | |
# dfsubset_ = pd.read_json(_json, orient="split") | |
# fieldname_ = dftypes.loc[8, "fieldname"] | |
# fieldval_ = dfsubset_.loc[0, fieldname_] | |
# plot_ = dftypes.loc[8, "plot"] | |
# if plot_=="bar": | |
# dexhibit_ = update_categorical( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# elif plot_=="hist": | |
# dexhibit_ = update_continuous( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# return(dexhibit_) | |
# @app.callback( | |
# dash.dependencies.Output("var09", "figure"), | |
# [dash.dependencies.Input("intermediate", "children"), | |
# dash.dependencies.Input("claim_number", "value"),] | |
# ) | |
# def update_var09(_json, claim_number): | |
# """ | |
# Update visualizations based on attributes of selected CLAIM_NUMBER. | |
# Note that a figure represents a dictionary containing two keys: | |
# {"data":trace, "layout":layout}. | |
# """ | |
# # dfsubset_ = dfinput[dfinput["CLAIM_NUMBER"]=="4301064194"].reset_index(drop=True) | |
# dfsubset_ = pd.read_json(_json, orient="split") | |
# fieldname_ = dftypes.loc[9, "fieldname"] | |
# fieldval_ = dfsubset_.loc[0, fieldname_] | |
# plot_ = dftypes.loc[9, "plot"] | |
# if plot_=="bar": | |
# dexhibit_ = update_categorical( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# elif plot_=="hist": | |
# dexhibit_ = update_continuous( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# return(dexhibit_) | |
# @app.callback( | |
# dash.dependencies.Output("var10", "figure"), | |
# [dash.dependencies.Input("intermediate", "children"), | |
# dash.dependencies.Input("claim_number", "value"),] | |
# ) | |
# def update_var10(_json, claim_number): | |
# """ | |
# Update visualizations based on attributes of selected CLAIM_NUMBER. | |
# Note that a figure represents a dictionary containing two keys: | |
# {"data":trace, "layout":layout}. | |
# """ | |
# # dfsubset_ = dfinput[dfinput["CLAIM_NUMBER"]=="4301064194"].reset_index(drop=True) | |
# dfsubset_ = pd.read_json(_json, orient="split") | |
# fieldname_ = dftypes.loc[10, "fieldname"] | |
# fieldval_ = dfsubset_.loc[0, fieldname_] | |
# plot_ = dftypes.loc[10, "plot"] | |
# if plot_=="bar": | |
# dexhibit_ = update_categorical( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# elif plot_=="hist": | |
# dexhibit_ = update_continuous( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# return(dexhibit_) | |
# @app.callback( | |
# dash.dependencies.Output("var11", "figure"), | |
# [dash.dependencies.Input("intermediate", "children"), | |
# dash.dependencies.Input("claim_number", "value"),] | |
# ) | |
# def update_var11(_json, claim_number): | |
# """ | |
# Update visualizations based on attributes of selected CLAIM_NUMBER. | |
# Note that a figure represents a dictionary containing two keys: | |
# {"data":trace, "layout":layout}. | |
# """ | |
# # dfsubset_ = dfinput[dfinput["CLAIM_NUMBER"]=="4301064194"].reset_index(drop=True) | |
# dfsubset_ = pd.read_json(_json, orient="split") | |
# fieldname_ = dftypes.loc[11, "fieldname"] | |
# fieldval_ = dfsubset_.loc[0, fieldname_] | |
# plot_ = dftypes.loc[11, "plot"] | |
# if plot_=="bar": | |
# dexhibit_ = update_categorical( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# elif plot_=="hist": | |
# dexhibit_ = update_continuous( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# return(dexhibit_) | |
# @app.callback( | |
# dash.dependencies.Output("var12", "figure"), | |
# [dash.dependencies.Input("intermediate", "children"), | |
# dash.dependencies.Input("claim_number", "value"),] | |
# ) | |
# def update_var12(_json, claim_number): | |
# """ | |
# Update visualizations based on attributes of selected CLAIM_NUMBER. | |
# Note that a figure represents a dictionary containing two keys: | |
# {"data":trace, "layout":layout}. | |
# """ | |
# # dfsubset_ = dfinput[dfinput["CLAIM_NUMBER"]=="4301064194"].reset_index(drop=True) | |
# dfsubset_ = pd.read_json(_json, orient="split") | |
# fieldname_ = dftypes.loc[12, "fieldname"] | |
# fieldval_ = dfsubset_.loc[0, fieldname_] | |
# plot_ = dftypes.loc[12, "plot"] | |
# if plot_=="bar": | |
# dexhibit_ = update_categorical( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# elif plot_=="hist": | |
# dexhibit_ = update_continuous( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# return(dexhibit_) | |
# @app.callback( | |
# dash.dependencies.Output("var13", "figure"), | |
# [dash.dependencies.Input("intermediate", "children"), | |
# dash.dependencies.Input("claim_number", "value"),] | |
# ) | |
# def update_var13(_json, claim_number): | |
# """ | |
# Update visualizations based on attributes of selected CLAIM_NUMBER. | |
# Note that a figure represents a dictionary containing two keys: | |
# {"data":trace, "layout":layout}. | |
# """ | |
# # dfsubset_ = dfinput[dfinput["CLAIM_NUMBER"]=="4301064194"].reset_index(drop=True) | |
# dfsubset_ = pd.read_json(_json, orient="split") | |
# fieldname_ = dftypes.loc[13, "fieldname"] | |
# fieldval_ = dfsubset_.loc[0, fieldname_] | |
# plot_ = dftypes.loc[13, "plot"] | |
# if plot_=="bar": | |
# dexhibit_ = update_categorical( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# elif plot_=="hist": | |
# dexhibit_ = update_continuous( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# return(dexhibit_) | |
# @app.callback( | |
# dash.dependencies.Output("var14", "figure"), | |
# [dash.dependencies.Input("intermediate", "children"), | |
# dash.dependencies.Input("claim_number", "value"),] | |
# ) | |
# def update_var14(_json, claim_number): | |
# """ | |
# Update visualizations based on attributes of selected CLAIM_NUMBER. | |
# Note that a figure represents a dictionary containing two keys: | |
# {"data":trace, "layout":layout}. | |
# """ | |
# # dfsubset_ = dfinput[dfinput["CLAIM_NUMBER"]=="4301064194"].reset_index(drop=True) | |
# dfsubset_ = pd.read_json(_json, orient="split") | |
# fieldname_ = dftypes.loc[14, "fieldname"] | |
# fieldval_ = dfsubset_.loc[0, fieldname_] | |
# plot_ = dftypes.loc[14, "plot"] | |
# if plot_=="bar": | |
# dexhibit_ = update_categorical( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# elif plot_=="hist": | |
# dexhibit_ = update_continuous( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# return(dexhibit_) | |
# @app.callback( | |
# dash.dependencies.Output("var15", "figure"), | |
# [dash.dependencies.Input("intermediate", "children"), | |
# dash.dependencies.Input("claim_number", "value"),] | |
# ) | |
# def update_var15(_json, claim_number): | |
# """ | |
# Update visualizations based on attributes of selected CLAIM_NUMBER. | |
# Note that a figure represents a dictionary containing two keys: | |
# {"data":trace, "layout":layout}. | |
# """ | |
# # dfsubset_ = dfinput[dfinput["CLAIM_NUMBER"]=="4301064194"].reset_index(drop=True) | |
# dfsubset_ = pd.read_json(_json, orient="split") | |
# fieldname_ = dftypes.loc[15, "fieldname"] | |
# fieldval_ = dfsubset_.loc[0, fieldname_] | |
# plot_ = dftypes.loc[15, "plot"] | |
# if plot_=="bar": | |
# dexhibit_ = update_categorical( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# elif plot_=="hist": | |
# dexhibit_ = update_continuous( | |
# dfsubset=dfsubset_, fieldname=fieldname_, claim_number=claim_number, | |
# ) | |
# return(dexhibit_) | |
if __name__ == "__main__": | |
app.run_server(host='0.0.0.0', port=9999, debug=True, threaded=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment