Echarts4r新西兰地图

发布于 2025-02-04 10:17:22 字数 839 浏览 4 评论 0原文

我正在尝试使用库echarts4r在R中创建新西兰的地图,但是该地图看起来很小,我无法弄清楚如何放大或确定LAT/LONG BONDARIES,以使其更大可见的。 这是我的代码(改编自文档中的示例 https://echarts://echarts4r.john-john-r.john--john-- coene.com/articles/map.html

library(echarts4r.maps)

df <- data.frame(
  region = c("Wellington", "Auckland"), 
  value = c(10,20)
)

df |> 
  e_charts(region) |>
  em_map("New_Zealand") |> 
  e_map(value, map = "New_Zealand") |> 
  e_visual_map(value) |> 
  e_theme("infographic")

屏幕截图

您知道如何在echarts4r中放大地图或设置lat/long界限吗? 任何帮助将不胜感激!

I'm trying to create a map of New Zealand in R using the library echarts4r but the map looks tiny and I couldn't figure out how to zoom in or determine lat/long boundaries to make it more visible.
Here is my code (adapted from the example in the documentation https://echarts4r.john-coene.com/articles/map.html)

library(echarts4r.maps)

df <- data.frame(
  region = c("Wellington", "Auckland"), 
  value = c(10,20)
)

df |> 
  e_charts(region) |>
  em_map("New_Zealand") |> 
  e_map(value, map = "New_Zealand") |> 
  e_visual_map(value) |> 
  e_theme("infographic")

screenshot
enter image description here

Do you know how to zoom in maps, or set lat/long boundaries, in echarts4r?
Any help would be much appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦幻的味道 2025-02-11 10:17:22

我认为来自echarts4r.maps的地图的编码可能有问题,但我不确定。

我可以告诉你,惠灵顿在echarts4r背后的数据中没有被列为新西兰的城市。我认为这可能就是原因,但这与渲染/变焦问题无关。

我查找了新西兰的纬度/长边界,并在情节中使用了这一点,现在肯定是可读的。

df <- data.frame(
  region = c("Southland", "Auckland"), 
  value = c(1, 2)
)

df |> 
  e_charts(region, elementId = 'chart') |>
  em_map("New_Zealand") |> 
  e_map(value, map = "New_Zealand",
        boundingCoords = list(
          list(166.4669, -48.0624), list(179.0637, -34.1473)
        )) |> 
  e_visual_map(value) |> 
  e_theme("infographic")

I think there may be something wrong with the encoding of the map coming from echarts4r.maps, but I'm not sure.

I can tell you that Wellington is not listed as a city in New Zealand in the data behind echarts4r. I thought that might have been why, but it had nothing to do with the rendering/zoom issue.

I looked up the lat/long boundaries of NZ and used that in the plot, and it's definitely readable now.

df <- data.frame(
  region = c("Southland", "Auckland"), 
  value = c(1, 2)
)

df |> 
  e_charts(region, elementId = 'chart') |>
  em_map("New_Zealand") |> 
  e_map(value, map = "New_Zealand",
        boundingCoords = list(
          list(166.4669, -48.0624), list(179.0637, -34.1473)
        )) |> 
  e_visual_map(value) |> 
  e_theme("infographic")

enter image description here

疯了 2025-02-11 10:17:22

祝福你凯特,真的在努力代码以闪亮将其用作条形图的过滤器。

使用 https://psim.shinyapps.io/echarts4r_callbacks/ 从鼠标中获得过滤。

# Update the filter date on click on data point
observeEvent(input$chart_clicked_data, {
filter_date(input$chart_clicked_data$value[1])
})

这有多容易。

Bless you Kat, really was struggling to Code to get it in shiny add this to a shiny app to use it as a filter for a bar chart.

using https://psim.shinyapps.io/echarts4r_callbacks/ to get the filtering from the mouse click.

# Update the filter date on click on data point
observeEvent(input$chart_clicked_data, {
filter_date(input$chart_clicked_data$value[1])
})

how easy is that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文