我是网络开发的小伙子.我正在尝试创建一个树状的分层公司组织结构图.我尝试了google的可视化图表和Mike Bostock的D3 Reingold树.
我想要这些功能:
上面我标记了哪个工具允许哪些功能,afaik.
我更喜欢D3版本,因为它看起来很酷.
我可以修改.json以包含其他字段(标题,URL到照片等) - 这是一个示例
我的问题是 - 如何修改D3代码以显示员工的姓名,然后在下一行显示标题,也可能是图片?
或者,如果这不可行 - 如何修改谷歌代码以自动调整间距,以便节点的所有子节点都靠近,我不必水平滚动?
这显然是一个流行的面试问题。
有 2 个包含恐龙数据的 CSV 文件。我们需要查询它们以返回满足特定条件的恐龙。
注意 - 我们不能使用 q、fsql、csvkit 等附加模块。
文件1.csv:
NAME,LEG_LENGTH,DIET
Hadrosaurus,1.2,herbivore
Struthiomimus,0.92,omnivore
Velociraptor,1.0,carnivore
Triceratops,0.87,herbivore
Euoplocephalus,1.6,herbivore
Stegosaurus,1.40,herbivore
Tyrannosaurus Rex,2.5,carnivore
Run Code Online (Sandbox Code Playgroud)
文件2.csv
NAME,STRIDE_LENGTH,STANCE
Euoplocephalus,1.87,quadrupedal
Stegosaurus,1.90,quadrupedal
Tyrannosaurus Rex,5.76,bipedal
Hadrosaurus,1.4,bipedal
Deinonychus,1.21,bipedal
Struthiomimus,1.34,bipedal
Velociraptor,2.72,bipedal
Run Code Online (Sandbox Code Playgroud)
使用论坛:速度 = ((STRIDE_LENGTH / LEG_LENGTH) - 1) * SQRT(LEG_LENGTH * g),其中 g = 9.8 m/s^2
编写一个程序来读取 csv 文件,并仅打印双足恐龙的名称,按速度从最快到最慢排序。
在 SQL 中,这很简单:
select f2.name from
file1 f1 join file2 f2 on f1.name = f2.name
where f1.stance = 'bipedal'
order by (f2.stride_length/f1.leg_length - 1)*pow(f1.leg_length*9.8,0.5) desc
Run Code Online (Sandbox Code Playgroud)
这如何在 python 中完成?