小编How*_*ith的帖子

如何让ggmap路径数据遵循道路路径

我正在使用ggmap route函数来计算和显示使用DC Capital Bikeshare数据的数百条路线.我成功地解决了一个小问题,路线不跟随道路,特别是弯曲的道路(见下面的截图).有没有办法将我的代码调到所有更详细的路径?

在此输入图像描述

library(tidyverse)
library(ggmap)

# Example dataset
feb_14 <- read.csv('https://raw.githubusercontent.com/smitty1788/Personal-Website/master/dl/CaBi_Feb_2017.csv', stringsAsFactors = FALSE)

# Subset first 300 rows, keep start and end Lat/Long strings
start<-c(feb_14[1:300, 14])
dest<-c(feb_14[1:300, 15])

# df of individual routes
routes <- tibble(
  start,
  dest)

# Function to calculate route
calculationroute <- function(startingpoint, stoppoint) {
  route(from = startingpoint,
        to = stoppoint,
        mode = 'bicycling',
        structure = "route")}

# Calculate route path for all individual trips
calculatedroutes <- mapply(calculationroute,
                           startingpoint = routes$start,
                           stoppoint = routes$dest,
                           SIMPLIFY …
Run Code Online (Sandbox Code Playgroud)

r

9
推荐指数
1
解决办法
524
查看次数

在Barchart D3js上添加标签文本

我正在试图找出正确的方法来显示位于条形图中每个条形顶部的标签.我也希望他们在数字后显示%.

这是我的Plunker:https://plnkr.co/edit/FbIquWxfLjcRTg7tiX4E p = preview

我尝试使用以下链接中的问题代码.但是,我无法让它正常工作(意味着整个图表无法显示)

在D3条形图上添加标签

var yTextPadding = 20;
svg.selectAll(".bartext")
.data(data)
.enter()
.append("text")
.attr("class", "bartext")
.attr("text-anchor", "top")
.attr("fill", "white")
.attr("x", function(d,i) {
    return x(i)+x.rangeBand()/2;
})
.attr("y", function(d,i) {
    return height-y(d)+yTextPadding;
})
.text(function(d){
     return d;
});
Run Code Online (Sandbox Code Playgroud)

javascript d3.js

2
推荐指数
1
解决办法
939
查看次数

标签 统计

d3.js ×1

javascript ×1

r ×1