Shiny R在地图上悬停时添加工具提示

时间:2017-08-11 04:37:27

标签: html css r shiny tooltip

地图图片Image of the map所以我用闪亮的r创建了一张地图。但是,我正在尝试添加工具提示,以便在人们盘旋在该国时显示信息。例如:当它继续进入俄罗斯时,它会将俄罗斯的数据显示为弹出或工具提示。

我无法成功地做到这一点。我找到了几个代码,可以在侧边栏中添加工具提示,但我希望在悬停在国家/地区上时将其显示在地图上。

> library(shiny)
> library(shinyBS)
> ui<-fluidPage(
+   mainPanel(
+     tabsetPanel(id="tp",
+                 tabPanel("Map View", plotOutput("mPlot", height="560px", width="950px"))
+     )
+   )))


> sPDF <- joinCountryData2Map(data, joinCode='NAME', nameJoinColumn='Country.code')

> server<- function(input, output, session){
+   output$mPlot <- renderPlot({
+     mapParams <- mapPolys(sPDF, 
nameColumnToPlot="Truth.Commission.Total", mapRegion="world",
+                           missingCountryCol="dark grey", catMethod = 
"fixedWith", numCats=20, 
+                           colourPalette=brewer.pal(20,"YlOrRd"),
+                           addLegend=TRUE,
+                           oceanCol="light blue")
+     mtext("[Grey Color: No Data Available]",side=1,line=-1)
+   })
+ }

> shinyApp(ui=ui, server=server)

以前的一般解决方案是用

完成的
>addTooltip(session, id = "someInput", title = "This is an input.",
       placement = "left", trigger = "hover")

但是,由于地图上的国家/地区没有明确的ID显示在页面上,但是在绘制地图时有数据,此解决方案对我不起作用。

0 个答案:

没有答案