Skip to content

Commit c68b21d

Browse files
authored
Merge pull request #56 from tlyon3/dash-builtin-colorscales
DASH builtin-colorscales
2 parents 76b4dfb + f681557 commit c68b21d

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

dash/builtin-colorscales.jl

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Dash
2+
using DashCoreComponents
3+
using DashHtmlComponents
4+
using PlotlyJS, CSV, DataFrames
5+
6+
df = dataset(DataFrame, "iris")
7+
8+
app = dash(external_stylesheets=["https://codepen.io/chriddyp/pen/bWLwgP.css"])
9+
10+
app.layout = html_div() do
11+
html_p("Color scale"),
12+
dcc_dropdown(
13+
id="colorscale",
14+
options=[
15+
(label = x, value = x)
16+
for x in sort(collect(keys(colors.all)))
17+
],
18+
value=Symbol("tableau_hue_circle")
19+
),
20+
dcc_graph(id="graph")
21+
22+
end
23+
24+
callback!(app, Output("graph", "figure"), Input("colorscale", "value")) do val
25+
fig = plot(
26+
df,
27+
mode="markers",
28+
x=:sepal_width,
29+
y=:sepal_length,
30+
marker=attr(
31+
color=df.sepal_length,
32+
coloraxis="coloraxis",
33+
showscale=true
34+
),
35+
Layout(coloraxis_colorscale=colors.all[Symbol(val)])
36+
)
37+
end
38+
39+
run_server(app, "0.0.0.0", 8080)

0 commit comments

Comments
 (0)