JohnCoene / datamaps

📍 datamaps htmlwidget for R
http://datamaps.john-coene.com/
Other
23 stars 3 forks source link

Add documentation for available values for "scope" #1

Open happyshows opened 6 years ago

happyshows commented 6 years ago

Is there any scope like 'pacific' which allow me to have a arc from China to US?

World may be to much for the above use case.

JohnCoene commented 6 years ago
arcs <- data.frame(from = "USA", to = "CHN")

arcs %>% 
    datamaps(width = 600, height = 600) %>% 
    add_arcs_name(from, to) %>% 
    set_projection(htmlwidgets::JS('function() {
      var projection = d3.geo.mercator()
                                   .rotate([150,0])
                                   .scale(600 / 2 / Math.PI)
                                   .translate([600 / 2, 600 / 2]);
                                   var path = d3.geo.path().projection( projection );
                                   return {path: path, projection: projection};
                                   }')
    )
happyshows commented 6 years ago

Maybe there's some issue with the transformation function, it's pointing to Canada at the moment.

Also, is it possible to mark multiple airport in china and point to multiple airports in US?

JohnCoene commented 6 years ago

Indeed. I will investigate this.In the meantime it looks like you might need a more powerful library for what you want to do, I have echarts4r which, though not on CRAN, has been thoroughly tested and includes much more powerful functions for what you want to do, the gallery includes a good example of connected airports. Will let you know about datamaps arcs when I have the time.

happyshows commented 6 years ago

echarts4r is very cool, thanks.