-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_hist.qmd
41 lines (35 loc) · 1.18 KB
/
_hist.qmd
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
```{ojs}
//| panel: input
viewof x_var = Inputs.select(cont_opts, {value: Array.from(cont_opts.values())[0], label: "X axis"})
viewof y_var = Inputs.select(cont_opts, {value: Array.from(cont_opts.values())[1], label: "Y axis"})
viewof color_var = Inputs.select(disc_opts, {value: Array.from(disc_opts.values())[1], label: "Color"})
```
```{ojs}
default_color = d3.schemeCategory10[0]
plt_color = color_var || default_color
all_vars = cont_vars.concat(disc_vars)
channels = Object.fromEntries(all_vars.map(k => [k[1], k[1]]))
viewof x_hist = Plot.plot({
style: { fontFamily: "var(--sans-serif)" },
width: 640/2,
x: { tickFormat: "" },
y: { grid: true },
marks: [
Plot.rectY(d, Plot.binX({y: "count"}, {x: x_var, fill: plt_color})),
Plot.ruleY([0])
]
})
viewof y_hist = Plot.plot({
style: { fontFamily: "var(--sans-serif)" },
width: 640/2,
y: { grid: true },
marks: [
Plot.rectY(d, Plot.binX({y: "count"}, {x: y_var, fill: plt_color})),
Plot.ruleY([0])
]
})
html`<div style="display: flex; flex-wrap: wrap; align-items: flex-end;">
<div style="flex-basis: 25%"> ${viewof y_hist} </div>
<div style="flex-basis: 25%"> ${viewof x_hist} </div>
</div>`
```