简体   繁体   English

R:“闪亮”应用中的悬停事件

[英]R: Hover Event in Shiny App

I have a datatable within a Shiny app containing thousands of records and 10 fields. 我在Shiny应用程序中有一个数据表,其中包含数千条记录和10个字段。 One of the fields, 'Notes', contains the body of a unique email sent to each record. “注释”字段之一包含发送给每个记录的唯一电子邮件的正文。 Due to the size of some of the emails, it takes up a lot of room in the datatable. 由于某些电子邮件的大小,它在数据表中占用了大量空间。 I would like to create an info icon for each row that when hovered over will display the email associated with that row in a popup window which will subsequently go away after moving the mouse off of the icon. 我想为每行创建一个信息图标,当将鼠标悬停在每行上时,它将在弹出窗口中显示与该行关联的电子邮件,随后将鼠标移出该图标后,该图标将消失。 Is this possible in Shiny? 这在Shiny中可能吗?

Yes. 是。 First, you'll need to process that email text as HTML and add the following tags: 首先,您需要将该电子邮件文本处理为HTML并添加以下标签:

<i class='fa fa-info-circle' data-toggle='tooltip' data-placement='right' title='YOUR EMAIL TEXT'></i>

Depending on the size of your email, that tooltip might become a bit heavy, but this does what you want it to do. 根据您电子邮件的大小,该工具提示可能会变得很繁琐,但这确实可以满足您的要求。

Note that this is assuming you're running shinyDashboard (although I think any of the options - fluidPage, navbarPage etc - will work). 请注意,这是假设您正在运行ShinyDashboard(尽管我认为任何选项-fluidPage,navbarPage等-都可以使用)。

You also need to set escape = FALSE in datatable(x, escape = FALSE) 您还需要在datatable(x, escape = FALSE)设置escape = FALSE

You can have a look at this implementation. 您可以看一下此实现。 For a table demo, click on GO , then click on the 'Health Behaviors' tab. 对于表格演示,单击GO ,然后单击“健康行为”选项卡。

http://healthpolicy.ucla.edu/health-profiles/adults/Pages/dashboard.aspx http://healthpolicy.ucla.edu/health-profiles/adults/Pages/dashboard.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM