robservable icon indicating copy to clipboard operation
robservable copied to clipboard

Input argument not working

Open pensivedog opened this issue 3 years ago • 13 comments

The input argument is not working. This can be observed in the "Update cell values" section of the package vignette:

https://juba.github.io/robservable/articles/introduction.html#update-cell-values

The example from the project documentation is also not working:

Change data frame cells data df <- data.frame(table(mtcars$cyl)) names(df) <- c("name", "value") robservable( "@d3/horizontal-bar-chart", include = "chart", input = list(data = df) )

pensivedog avatar Jun 27 '22 10:06 pensivedog

You're right, this seems to be linked to a recent Observable runtime update.

I'll look into it, thanks for taking the time to report the issue.

juba avatar Jun 27 '22 12:06 juba

So I think inputs are working now. Part of the problem was that the notebooks used in the introduction vignettes have been rewritten on Observable and were not functional anymore.

This should now be fixed in the development version.

Thanks again and don't hesitate to let us know if there is any other problem.

juba avatar Jun 27 '22 15:06 juba

Thanks for this update. I'm getting a "RuntimeError: invalid module" message now when trying to run this in RStudio:

robservable( "@juba/robservable-bar-chart", include = "chart" )

pensivedog avatar Jun 30 '22 10:06 pensivedog

Urf, I get the same error in RStudio but it works ok in VSCode or in a browser. Could you confirm that if you click on "show in new window" the chart is displayed correctly ?

juba avatar Jun 30 '22 10:06 juba

It seems to be linked to the Plot library, which can't be loaded into RStudio, surely because its underlying chromium engine is now too old. Notebooks which don't use plot seem to be working just fine.

juba avatar Jun 30 '22 10:06 juba

More precisely, the Plot library uses the ?. optional chaining operator which is supported since Chromium 80, whereas RStudio is still at Chromium 69...

juba avatar Jun 30 '22 10:06 juba

I fear we're stuck here, not sure there is a workaround. core-js doesn't seem to provide a polyfill for optional chaining operator, and even RStudio preview is still on Chromium 69.

juba avatar Jun 30 '22 10:06 juba

Thanks for helping troubleshoot. I confirm that Observable charts not using Plot are previewing fine in RStudio.

pensivedog avatar Jun 30 '22 10:06 pensivedog

But... the input argument still seems to not be working. For instance, this does not successfully update the color:

robservable( "@d3/horizontal-bar-chart", include = "chart", input = list(color="red") )

pensivedog avatar Jun 30 '22 11:06 pensivedog

Yes, that's normal, this code doesn't work now because the notebook has been changed and there isn't any cell named color anymore.

input only allows to change the value of a named cell in the Observable notebook, so in this example you could change alphabet for example, but not color.

juba avatar Jun 30 '22 11:06 juba

Apologies, I'm still figuring out how this works. In this example, input = list(color="red") doesn't work, but input = list(width=100) does work, even though there isn't a cell named width. What am I missing here?

pensivedog avatar Jun 30 '22 11:06 pensivedog

You're right, width is an exception here, it is always available as it is a variable which is part of Observable standard library. So you can change its value even if it is not defined as a cell. But other inputs must exist in the notebook to be modified.

juba avatar Jun 30 '22 11:06 juba

Ok, very helpful! Thank you for taking the time to answer these questions :)

pensivedog avatar Jun 30 '22 11:06 pensivedog