r crosstalk filter_select:无法解开已经选择的值

发布于 2025-01-19 02:19:06 字数 1318 浏览 5 评论 0原文

我正在尝试使用 crosstalk 来过滤 plotly 图表。我使用 crosstalkfilter_select 来(取消)过滤 plotly 图表。当使用下面的 reprex 尝试选择一朵花(例如 setosa)时,一切正常。但是,当我取消选择花朵时,这些值不会“返回”到 plotly 图表。选择“(全部)”似乎也不起作用。仅当从花过滤器中取消选择并在 helper_select_all 中勾选 TRUE 时,这些值才会重新出现。

library(crosstalk)
library(plotly)

df <- iris
df$helper_select_all <- T

shared_data <- SharedData$new(df)

filter <- bscols(
  list(
    filter_select("flower", "Select a flower", shared_data, ~Species),
    filter_checkbox(
      "helper_select_all",
      label = "Reset filtering as deselecting from 'Select a flower' is not working",
      shared_data, ~helper_select_all)
  )
)


p <- plot_ly(shared_data, x = ~Sepal.Length, y = ~Sepal.Width) %>% 
  add_markers()


bscols(filter, p)

此图演示了问题,因为未选择过滤值,但丢失了部分数据。 输入图片此处描述

此图显示了所有数据点都存在时的情况。 输入图片此处描述

“(全部)”似乎也不起作用。 输入图片此处描述

I am trying to use crosstalk to filter a plotly chart. I use crosstalk's filter_select to (un)filter a plotly chart. When using the reprex below trying to select a flower (e.g. setosa), all works fine. But when I unselect the flower, the values are not 'returned' to the plotly chart. Selecting '(All)' does not seem to be working either. The values reappear only when deselecting from flower filter AND ticking TRUE in the helper_select_all.

library(crosstalk)
library(plotly)

df <- iris
df$helper_select_all <- T

shared_data <- SharedData$new(df)

filter <- bscols(
  list(
    filter_select("flower", "Select a flower", shared_data, ~Species),
    filter_checkbox(
      "helper_select_all",
      label = "Reset filtering as deselecting from 'Select a flower' is not working",
      shared_data, ~helper_select_all)
  )
)


p <- plot_ly(shared_data, x = ~Sepal.Length, y = ~Sepal.Width) %>% 
  add_markers()


bscols(filter, p)

This picture demonstrates the issue as no filtering value is selected, but a part of the data is missing.
enter image description here

This picture shows what it looks like when all datapoints are present.
enter image description here

"(All)" does not seem to be working either.
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文