我有一个闪亮的应用程序,我在其中绘制了一个带有plotGoogleMaps
和 的地图rChart
,其值与地图中的某些标记相关,通过rPlot
.
应用程序用户可以单击地图中的标记以显示工具提示。
我希望当他点击标记时,图表中的相关值会突出显示。
有人知道如何执行此任务吗?
谢谢你。
我有一个闪亮的应用程序,我在其中绘制了一个带有plotGoogleMaps
和 的地图rChart
,其值与地图中的某些标记相关,通过rPlot
.
应用程序用户可以单击地图中的标记以显示工具提示。
我希望当他点击标记时,图表中的相关值会突出显示。
有人知道如何执行此任务吗?
谢谢你。
@贾哈里森
R代码可以是这样的:
suppressPackageStartupMessages(library(googleVis))
## Hurricane Andrew (1992) storm track with Google Maps
AndrewMap <- gvisMap(Andrew, "LatLong", "Tip", options = list(showTip = TRUE,
showLine = TRUE, enableScrollWheel = TRUE, mapType = "hybrid", useMapTypeControl = TRUE))
print(AndrewMap, "chart")
该示例取自此处。您可以在此处下载该软件包。在这个例子中,使用了库googleVis,但我认为答案可能是相似的。
# Author: Denis Petrov
# Date: 2014-07-04
# Example is based on http://rpubs.com/gallery/googleVis
library (shiny)
suppressPackageStartupMessages (library (googleVis))
# Define server logic required to summarize and view the selected dataset
shinyServer ( function (input, output, session)
{
GetDataAndrew <- function ()
{
# Hurricane Andrew (1992) storm track with Google Maps
AndrewMap <- gvisMap (Andrew, "LatLong", "Tip",
options = list(showTip = TRUE,
showLine = TRUE,
enableScrollWheel = TRUE,
mapType = "hybrid",
useMapTypeControl = TRUE))
return (AndrewMap)
}
output$viewchart <- renderGvis({
GetDataAndrew ()
})
output$info <- renderPrint ({
cat ('Hurricane\n')
cat ('Pressure=937\n')
cat ('Speed=120')
})
}
)
# Author: Denis Petrov
# Date: 2014-07-04
# Define UI for dataset viewer application
shinyUI(pageWithSidebar(
# Application title
headerPanel('Hurricane Andrew (1992)'),
# Sidebar with controls to provide a caption, select a dataset, and
# specify the number of observations to view. Note that changes made
# to the caption in the textInput control are updated in the output
# area immediately as you type
sidebarPanel(
p ('Hurricane Andrew (1992) storm track with Google Maps'),
p ('I would like the following output be changed based on
selected pin.'),
verbatimTextOutput ('info')
),
# Show the caption, a summary of the dataset and an HTML table with
# the requested number of observations
mainPanel(
htmlOutput ('viewchart')
)
))