juba / robservable

Observable notebooks as R htmlwidgets
https://juba.github.io/robservable/
163 stars 11 forks source link

Allow the TOJSON_FUNC attribute to flow through robservable #39

Closed draben closed 3 years ago

draben commented 3 years ago

Feature request: htmlwidgets allows the user to override the use of jsonlite by supplying their own R->JSON serialization function. Would it be possible to expose this ability through robservable? See here.

Use case: Currently data frames are serialized into arrays of objects. Excellent. Many of the D3 team's visualization examples have data objects that have which are arrays of objects with additional attributes attached (e.g., [ {data1}...{data2} ] with a columns array attribute). Standard use of jsonlite prevents direct construction of such an object, but a simple user-defined function could do the trick. Passing such a user-defined function would prevent the need to fork visualizations by enabling their direct use.

juba commented 3 years ago

There are now two new arguments to robservable :

I'm not really able to test the second one as I don't really have a use case, but feel free to send your feedback.

Thanks for your useful suggestion.

draben commented 3 years ago

Holy cow, that was fast! Thank you. I will report any issues I discover, but am closing the issue.