-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathchoropleth-maps.jl
46 lines (40 loc) · 1.11 KB
/
choropleth-maps.jl
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
using Dash
using DashCoreComponents
using DashHtmlComponents
using PlotlyJS, CSV, DataFrames
app = dash(external_stylesheets=["https://codepen.io/chriddyp/pen/bWLwgP.css"])
df = dataset(DataFrame, "election")
candidates = unique(df.winner)
election_geo = dataset("election_geo")
app.layout = html_div() do
html_p("Candidates"),
dcc_radioitems(
id="candidates",
options=[
(label = x, value = x)
for x in candidates
],
value=candidates[1],
labelStyle=(display = "inline-block",)
),
dcc_graph(id="graph")
end
callback!(app, Output("graph", "figure"), Input("candidates", "value")) do val
fig = plot(
df,
geojson=election_geo,
kind="choropleth",
range_color=[0,6500],
featureidkey="properties.district",
locations=:district,
z=df[!, val],
Layout(
geo_fitbounds="locations",
geo_projection_type="mercator",
geo_visible=false,
margin=(r = 0, t = 0, l = 0, b = 0)
)
)
return fig
end
run_server(app, "0.0.0.0", 8080)