4

I am programming a flexdashboard and trying to use crosstalk for interactivity because shiny is sadly no alternative due to not using a shiny webserver. What i try to do is having three filters (crosstalk) on SharedData-object. This is working fine.

What I'm trying to achieve is that only a part of my filters (which are used in a datatable) is used in my plot_ly plot.

Also I'm trying to get a standard selection on my filters and ideally to prevent the user from deleting the filter (so that one filter has to be active based on the selection).

I did a research via google to find a solution (either with crosstalk or with an alternative without having to use shiny), but didn't find anything.

Below you can find my reduced lines of code.

---
title: "Untitled"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
require(crosstalk)
require(plotly)
```

```{r einlesen, include=FALSE}
mydata = data.frame(la = c("li", "la", "laune", "baer"), Jahr = c(2013, 2014, 2015, 2016), le = c("la", "le", "lu", "lol"), numbers = c(10, 100, 1000, 10000))
shared_mydata = SharedData$new(mydata)
```

Column {data-width=500}
-----------------------------------------------------------------------

### Tabellen

```{r}
bscols(widths = c(4,4,4),
filter_select("Gebiet", "Gebiet", shared_mydata, ~la, multiple = F),
filter_select("Jahr", "Jahr", shared_mydata, ~Jahr, multiple = F),
filter_select("Tätigkeit", "Tätigkeit", shared_mydata, ~le, multiple = F)
)
DT::datatable(shared_mydata, rownames = FALSE, options=list(columnDefs = list(list(visible=FALSE, targets=c(0:1)))))
```

Column {data-width=500}
-----------------------------------------------------------------------

### Zeitreihe

```{r}
plot_ly(shared_mydata, y = ~numbers, x = ~Jahr)
```

### Altersdiagramm

```{r}

```

The datatable is working as expected (although I would like to have a preset filter without the possibility to remove the whole filter).

Is there any possibility to prevent for example the filter "Jahr" from having any effect on the plot without losing the filter effect from the other filters? Is there any alternative package to achieve this?

M.K.
  • 87
  • 5
  • 1
    This is quite a bit late and doesn't answer the main problem here, re: your subquestion about setting defaults for filters, there is a way of setting defaults for crosstalk filters - see the response at: https://stackoverflow.com/questions/64234585/selecting-a-default-value-in-an-r-plotly-plot-using-a-selectize-box-via-crosstal/64310052#64310052 – FelixST Oct 13 '20 at 04:02

0 Answers0