jbkunst / highcharter

R wrapper for highcharts
http://jkunst.com/highcharter/
Other
720 stars 148 forks source link

adding custom events functionality to hcmap #739

Closed kaya-atakan closed 1 year ago

kaya-atakan commented 2 years ago

Hi, Below, I'm pasting two blocks of cod to make comparisons. Specifically, I'm wondering if hcmap supports the following part where you can have world map initialized as zoomed in to the specific area? If not, it would be nice if it's added to hcmap's existing functionalities.

events = list(
                   load = JS("function(){
                        this.mapZoom(0.5, 100, 100);
                   }"))

First Code


 df <- data.frame(
     country = c("China", "Slovenia", "Bosnia and Herzegovina", "Serbia"),
     countryCode = c("CN", "SI", "BA", "RS"),
     index = c("20.5", "22.9", "25.6", "27.8"),
    log_color = c(3.65, 3.00, 2.5, 1.5)
              )

hcmap(
  map = "custom/world-highres3",
  data = df,
  joinBy = c("iso-a2","countryCode"),
  name="Index",
  value = "log_color",
  showInLegend = F,
  nullColor = "#000000",
  tooltip = list(
    pointFormat = paste(' Bounce Rate: <b>%{point.index}</b><br><br>
<br> Country: <b>{point.country}</b>')
  )
)%>%
  hc_mapNavigation(enabled = TRUE) %>%
  hc_colorAxis(
    maxColor = "#00c98d",
    minColor = "#00617a",
    minorTickInterval = 0.05
    ) %>%
  hc_legend(enabled = F, align = 'left', verticalAlign = 'bottom')

Second Code


highchart(type='map') %>%
    hc_chart(type = "map",
             map = map,
             spacingBottom = 20,
             events = list(
                   load = JS("function(){
                        this.mapZoom(0.5, 100, 100);
                   }"))
    )%>%
  hc_add_series(
                mapData = map,
                data= df,
                joinBy = c("iso-a2","countryCode"),
                name="index",
                value="log_color",
                tooltip = list(
                              pointFormat = paste(' Bounce Rate: <b>%{point.index}</b><br><br>
                              <br> Country: <b>{point.country}</b>')
                              )
                ) %>%
  hc_colorAxis(
              maxColor = "#00c98d",
              minColor = "#00617a",
              minorTickInterval = 0.05
              ) %>%
  hc_legend(enabled = F, align = 'left', verticalAlign = 'bottom')
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Feel free to reopen it if you find it necessary.