Open vinwol opened 1 year ago
Unfortunately no, scatterD3
is not crosstalk-compatible.
In fact there doesn't seem to be many crosstalk-compatible html widgets if this page is accurate :
Could it be an option to modify the code so that the Javascript part could be used inside an R Markdown HTML document?
What "JavaScript part" are you talking about exactly ?
I saw this example: https://stackoverflow.com/questions/56361986/zoom-function-in-rmarkdown-html-plot Not sure the underlying JS code of scatterD3 can be adopted to work directly in the HTML document? On a different note, could scatterD3 be included in an interactive fashion in the R Markdown HTML document, e.g. using widgetframe::frameWidget()?
You are still talking about crosstalk compatibility ? Because single scatterD3 plots should work fine in HTML document, if I remember correctly.
My reporting involves a pipeline where many outputs are generated in a for loop. I managed to include scatterD3 in the loop in the following way: print(htmltools::tagList(scatterD3::scatterD3(...))). Recently I came across Quarto, which supports Observable and this could make it fairly easy to go with JS for the front end. Link: https://quarto.org/
Is it possible to use crosstalk with scatterD3 in a standalone R Markdown HTML Report?
Running the following code works fine as expected:
library(scatterD3) scatterD3::scatterD3(data=iris, x=Sepal.Width, y=Sepal.Length, col_var=Species)
Trying to use this example in an R Markdown HTML Report like this:
library(crosstalk) library(scatterD3) library(d3scatter) df <- iris df$helper_select_all <- T shared_data <- SharedData$new(df) crosstalk::filter_select("flower", "Select a flower", shared_data, ~Species, multiple = FALSE) d3scatter::d3scatter(data=shared_data, x=~Sepal.Width, y=~Sepal.Length, color=~Species) scatterD3::scatterD3(data=shared_data, x=~Sepal.Width, y=~Sepal.Length, col_var=~Species)
throws this error: Error in data[, deparse(substitute(x))]: object of type 'environment' is not subsettable
The d3scatter code however works fine.