简体   繁体   English

R ggiraph onclick javascript-发光

[英]R ggiraph onclick javascript -Shiny

I have a ggplot and I try to make it interactive with ggiraph package. 我有一个ggplot ,我尝试使其与ggiraph软件包交互。 The tooltip works fine, the "onclick" function seems to appear in the Shiny console when I click on the geom_line . 工具提示工作正常,当我单击geom_line时, “ onclick”功能似乎出现在Shiny控制台中。

But I can't make it work so when I click a geom_line_interactive , to change(using js) the input type (from search to submit ) and set the value of a dataTable search input . 但是我无法使其工作,因此,当我单击geom_line_interactive ,要更改(使用js) input type (从searchsubmit )并设置 dataTable search inputvalue

The html of the table's search input : 表格search input的html:

<input type="search" class="form-control input-sm" placeholder aria-controls="DataTables_Table_0">

Make new column for js used in onclick feature: onclick功能中使用的js创建新列:

dfMonth$onclick <- sprintf(
  "function clickLine(){document.getElementsByClassName(\"form-control input-sm\").type=\"submit\".value=\"%s\";}",as.character(dfMonth$ISBN) )

In server.R file, use the js from onclick column: 在server.R文件中,使用onclick列中的js:

geom_line_interactive(aes(color=ISBN, group=ISBN, tooltip=ISBN, onclick=onclick))

I did try using only document.getElementsByClassName(..... without including it in a function (it has no effect on the input field). I can't modify the html, so I can't add an id to the input field. 我确实尝试仅使用document.getElementsByClassName(.....,而未将其包含在函数中(它对input字段没有影响)。我无法修改html,因此无法向输入添加id领域。

This gist demonstrate how to fill the search input field of a DT from ggiraph in shiny: 该要点演示了如何从ggiraph中填充闪亮的DT的搜索输入字段:

https://gist.github.com/davidgohel/68623058bad5b42f253ec8823a732a45 https://gist.github.com/davidgohel/68623058bad5b42f253ec8823a732a45

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

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