I'm trying to create a flexdashboard using plotly and crosstalk (but without Shiny as ideally needs to be deployed in an environment without access to a Shiny server).
I'm running into a particular problem trying to create charts that use both static and dynamic data. My data is made up of scores for different groups, including a benchmark score. What I'd like to be able to do is display a bar chart of the scores for all groups including the benchmark score, and then overlay a trace for the group selected by the user. I've tried using
highlight but there's a second chart which I want to show some other measures for the selected group again against a benchmark.
From reading the crosstalk documentation, my assumption was that calling
sd$data(withSelection = TRUE) would return a reactive data frame of all the data with a column that indicated whether data was selected or not. Therefore I could add traces that are based on the full data and on the selected data. However, when I tried this it did not update, further inspection using
DT::datatable suggests that the column that
withSelection adds is actually blank and does not update.
I also tried using the base dataset for the frame, adding a trace which has sd as data. Plotly however dynamically resizes the y axis as the selection for sd changes. If for this trace I set
inherit = FALSE then its basically the same as the other example.
Two dummy dashboards with code can be found in this gist: https://gist.github.com/mattkerlogue/0ba01758ed6155136707505191012a4e
If you unselect trace 3 when it first initialises you can see that the plotly transforms work to add a trace that gives the benchmark a different value. Also in this example the benchmark is calculated as a simple mean, but in reality it's not a simple aggregation so included in the data as a particular observation.
Perhaps what I'm trying to do can't be done, but I'm assuming that
withSelection should be updating the table with a logical vector whenever filter_select is modified?