Slackbot
05/04/2023, 6:51 PMJakob Listabarth
05/05/2023, 7:01 AMR
for the paths to the images:
```{r}
fig_list <- list(
"kitten a" = "<https://cdn.pixabay.com/photo/2019/11/08/11/56/kitten-4611189_1280.jpg>",
"kitten b" = "<https://cdn.pixabay.com/photo/2016/03/28/10/05/kitten-1285341_1280.jpg>",
"kitten c" = "<https://cdn.pixabay.com/photo/2017/07/25/01/22/cat-2536662_1280.jpg>"
)
ojs_define(fig_list)
{ojs}
viewof file = Inputs.select(Object.keys(fig_list), {label: "Choose feature"})
{ojs}
html`<img src="${fig_list[file]}" />`
```
R
lists seem to get converted to objects in javascript. That might be one issue with your code: I think Inputs.select expects an array.
Also, the viewof
and the html for the <image>
need to be in separate observable cells 🙂
Does this help?Fabian Iwand
05/05/2023, 8:22 AMI think Inputs.select expects an array.Small clarification, Inputs.select accepts an iterable. It works best with Maps where it will automatically handle key and value. To avoid having to provide the format and valueof options, pass your object in as
new Map(Object.entries(obj))
.Nima Rafati
05/05/2023, 9:11 AM