jbkunst/highcharter

Feature: enable color sea / oceans option - hc_add_series

mathiasleroy opened this issue · 0 comments

Hi,
I don't think there is any option to color water bodies, like oceans and seas, in maps yet.
I'm using hc_add_series_map and hc_add_series, but I suppose this should also work in hcmap.

Basically it should be a background color for the map, but not for the chart.
You can't use hc_chart(backgroundColor = "lightblue") because that also colors titles and legends for example.

Perhaps there should be a backgroundColor in hc_add_series_map?

(I cant provide a world map dataset here so I cut it to ISR only for the reproducible example.
Please consider this shape is an island and everything around it should be blue.)

mapISR |> dput()
new("SpatialPolygonsDataFrame", data = structure(list(ISO3 = "ISR"
    ISO2 = "IL", cat = "EURO", name = "Israel"), row.names = 37L, 
    polygons = list(new("Polygons", Polygons = list(new("Polygon",
        labpt = c(34.9687651840375, 31.3612675920041), area = 1.96
        hole = FALSE, ringDir = 1L, coords = structure(c(35.115,
        35.2958, 35.3782, 35.5323, 35.563, 35.6244, 35.663, 35.653
        35.6468, 35.632, 35.6332, 35.629, 35.6243, 35.6231, 35.643
        35.6416, 35.6557, 35.6627, 35.6986, 35.68, 35.6639, 35.564
        35.5608, 35.4303, 35.4027, 35.2109, 35.0731, 35.0161,
        35.0302, 34.9641, 35.0018, 34.9863, 35.0393, 35.2252,
        35.2293, 35.0123, 34.8791, 34.9259, 35.2333, 35.3923,
        35.476, 35.4736, 35.4001, 35.456, 35.4019, 35.3348, 35.340
        35.2036, 35.1619, 35.188, 35.1458, 35.1575, 35.0754,
        33.0249, 32.9902, 32.9559, 32.9169, 32.8903, 32.8618,
        32.8343, 32.8085, 32.7771, 32.7121, 32.6976, 32.6803,
        32.6252, 32.4011, 32.4093, 32.5013, 32.5431, 32.4595,
        32.3379, 32.2641, 32.1986, 32.041, 31.9645, 31.8507,
        31.7781, 31.7719, 31.6615, 31.3977, 31.3443, 31.3763,
        31.4895, 31.4905, 31.411, 31.2429, 31.149, 30.9339, 30.8732,
        30.8157, 30.582, 30.4408, 30.3573, 30.2822, 30.1287,
        29.9504, 29.8857, 29.7112, 29.5418, 29.5291, 29.6419,
        29.8034, 30.3682, 30.4104, 30.6746, 30.8537, 31.2311,
        31.2907, 31.377, 31.5339, 31.5959, 31.7045, 31.935, 32.2364,
        32.4725, 32.8273, 32.8492, 33.093), dim = c(75L, 2L)))),
        plotOrder = 1L, labpt = c(34.9687651840375, 31.3612675920041
        ), ID = "37", area = 1.966682235)), plotOrder = 1L, bbox = structure(c(34.265,
    29.5291, 35.6986, 33.2832), dim = c(2L, 2L), dimnames = list(
        c("x", "y"), c("min", "max"))), proj4string = new("CRS",
        projargs = "+proj=longlat +datum=WGS84 +no_defs"))

highchart(type = "map") |>
  # hc_chart(backgroundColor = "lightblue") |> ## problem : colors title and legend bg as well
  hc_add_series(
    mapData = geojson_list(mapISR),
    nullColor = "grey",
    borderColor = "grey"
  ) |>
  hc_title(
    text = "Title"
  )

or hcmap but I'm personally not using hcmap.

library(highcharter)
hcmap("countries/nz/nz-all",
  backgroundColor = "lightblue",
  nullColor = "grey"
) |>
  hc_title(
    text = "Title"
  )