带有javascript-R Shiny中本地文件的hcmap

时间:2019-02-13 14:16:16

标签: javascript r highcharts

我正在Shiny(UI和服务器)上开发应用程序,并且我想使用Highchart包的hcmap函数实现地图。但是,在实施地图时,我发现hcmap函数与以下站点有关:https://code.highcharts.com/mapdata/

因此,我的目标是在不使用Internet连接的情况下以本地方式实现地图以及相关的javascript文件。我尝试了以下解决方案:我从https://code.highcharts.com/mapdata/检索了javascript文件,并在www目录中列出了该文件,但结果不佳。这是我使用的代码:

library(shinydashboard)
library(shinydashboardPlus)
library(highcharter)
library(shiny)

shinyUI(

dashboardPagePlus(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
fluidRow(box(width = 6,title="map",highchartOutput("map")))
        )
            )
              )

shinyServer(function(input, output) {

output$map=renderHighchart({
data_fake=data.frame(code=c("RZ","MT","TD","OR","FB","SM","MK","DA"
,"GE","LB","OD","TO","TH","GB","CO","GC"),
value=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)
                     )

hcmap(map=tags$head(tags$script(src="map.js")), data = data_fake, value = 
"value",joinBy = c("hc-a2", "code"), name = "Fake data",download_map_data=FALSE,
 dataLabels = list(enabled = TRUE, format = '{point.name}'),
 borderColor = "gray", borderWidth = 0.9,
 tooltip = list(valueDecimals = 2, valuePrefix = "DH", valueSuffix = " 
 MAD"))%>% hc_mapNavigation(enabled = TRUE)
})

})

我希望输出结果是地图,但不依赖于https://code.highcharts.com/mapdata/网站,即以本地方式在应用程序目录中使用javascript文件。

Map result with the code I used

0 个答案:

没有答案