-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
143 lines (119 loc) · 4.64 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
from dash import Dash, html, dcc, callback, Output, Input
import plotly.express as px
import dash_bootstrap_components as dbc
from dash_bootstrap_templates import load_figure_template
# loads the "darkly" template and sets it as the default
load_figure_template("darkly")
import pandas as pd
from ingest import ingest
from plots import agsf_dollar_hist, dollar_per_acre_hist
url='https://gist.githubusercontent.com/rselover/a82f17ec1a97538080940248880597fe/raw/69c797301be90b135eccc00d2015a28edc630b95/weston.json'
df=ingest(url)
app = Dash(__name__, external_stylesheets=[dbc.themes.DARKLY])
agsf=agsf_dollar_hist(df)
dollar_per_acre=dollar_per_acre_hist(df)
app.layout = dbc.Container([
html.Div(className='row', children=[
html.H1(children='Weston Real Estate', style={'textAlign':'center'}),
html.Div(className='parent', children=[
dcc.Graph(id='$/AGSF', className='plot', figure=agsf),
html.Div(className='spacer'),
dcc.Graph(id='plot 2', className='plot', figure=dollar_per_acre)
]),
]),
dcc.Dropdown(df.Address.unique(), '144 SUDBURY RD', id='dropdown-selection', className='dash-bootstrap'),
html.Div(className='parent', children=[
html.Div([
html.Label('Acres: ', className='textTileLabel'),
html.Br(),
html.P(className='textTile', id='textTile1'),
]),
html.Div(className='spacer'),
html.Div([
html.Label('Above Ground Square Footage (AGSF): ', className='textTileLabel'),
html.Br(),
html.P(className='textTile', id='textTile2'),
]),
html.Div(className='spacer'),
html.Div([
html.Label('Total Square Footage (ELA): ', className='textTileLabel'),
html.Br(),
html.P(className='textTile', id='textTile3'),
]),
html.Div(className='spacer'),
html.Div([
html.Label('Below Ground Square Footage (BGSF): ', className='textTileLabel'),
html.Br(),
html.P(className='textTile', id='textTile4'),
])
]),
html.Hr(),
html.Div(className='row', children=[
dcc.Slider(800000.00, 1500000.00, step=1,
marks={
800000: '$800K',
1000000: '$1M',
1250000: '$1.25M',
1500000: '$1.5M'
},
tooltip={"placement": "bottom", "always_visible": True, "transform": "formatCurrency"},
value=800000.00, id='offer-slider', className='slider'),
dcc.Slider(0.5, 1, 0.05, value=0.65, id='basement-slider', className='slider',
tooltip={"placement": "bottom", "always_visible": True}),
]),
html.Hr(),
html.Div(className='parent', children=[
html.Div([
html.Label('Discounted Total Square Footage', className='textTileLabel'),
html.Br(),
html.P(className='textTile', id='textTile5'),
]),
html.Div(className='spacer'),
html.Div([
html.Label('Overall $/SF', className='textTileLabel'),
html.Br(),
html.P(className='textTile', id='textTile6'),
]),
html.Div(className='spacer'),
html.Div([
html.Label('Weighted $/SF', className='textTileLabel'),
html.Br(),
html.P(className='textTile', id='textTile7'),
]),
])
])
@callback(
Output('textTile1', 'children'),
Output('textTile2', 'children'),
Output('textTile3', 'children'),
Output('textTile4', 'children'),
Input('dropdown-selection', 'value')
)
def update_text(address):
dff = df[df.Address==address]
acres=dff['Acres'].values[0]
gla=dff['GLA (Above Grade)'].values[0]
ela=dff['ELA'].values[0]
bgsf=dff['BGSF'].values[0]
return f"{acres}" , f"{gla}", f"{ela}", f"{bgsf}"
@callback(
Output('textTile5', 'children'),
Output('textTile6', 'children'),
Output('textTile7', 'children'),
Input('dropdown-selection', 'value'),
Input('basement-slider', 'value'),
Input('offer-slider', 'value')
)
def update_text5(address, bgsf_factor, offer_price):
dff = df[df.Address==address]
discount_bgsf=dff['BGSF'].values[0]*bgsf_factor
dtsf=dff['GLA (Above Grade)'].values[0]+discount_bgsf
# Overall $/SF
odsf=round(offer_price/dff['ELA'].values[0],2)
# Weighted $/SF
wdsf=round(offer_price/dtsf,2)
# Proportion AGSF to Weighted SF
wagsf=dff['GLA (Above Grade)'].values[0]/dtsf
return f"{dtsf}", f"${odsf}/SF", f"${wdsf}/SF"
if __name__ == '__main__':
app.run(debug=True)