首页 \ 问答 \ 如何在圆圈之间均匀分割d3链接(How to evenly split d3 links between circles)

如何在圆圈之间均匀分割d3链接(How to evenly split d3 links between circles)

我有以下数据集

var data = { nodes: 
   [ { addr: '1',
       address: '1',
       x: 100,
       y: 200 },
     { addr: '2',
       address: '2',
       x: 200,
       y: 0 },
     { addr: '3',
       address: '3',
       x: 200,
       y: 150 },
     { addr: '4', address: '4', x: 200, y: 240 },
     { addr: '5', address: '5', x: 200, y: 360 }
  ],
  links: 
   [ { source: 0, target: 1 },
     { source: 0, target: 2 },
     { source: 0, target: 3 },
     { source: 0, target: 4 } ] }

目前看起来像这样:

在此处输入图像描述

我试图找到一个公式,允许我为任何给定数量的圆计算正确的Y值(在合理范围内,如果有1,2或10个圆,公式应该有效)。

我想尝试这样的事情:

在此处输入图像描述

这看起来很对称。

第一个圆圈(蓝色)的我的X和Y是已知的并且是静态的。


I have the following data set

var data = { nodes: 
   [ { addr: '1',
       address: '1',
       x: 100,
       y: 200 },
     { addr: '2',
       address: '2',
       x: 200,
       y: 0 },
     { addr: '3',
       address: '3',
       x: 200,
       y: 150 },
     { addr: '4', address: '4', x: 200, y: 240 },
     { addr: '5', address: '5', x: 200, y: 360 }
  ],
  links: 
   [ { source: 0, target: 1 },
     { source: 0, target: 2 },
     { source: 0, target: 3 },
     { source: 0, target: 4 } ] }

Which currently looks like this:

enter image description here

I'm trying to find a formula that will allow me to calculate the correct Y value for any given number of circles (within reason, the formula should work if there are 1, 2 or even 10 circles).

I'm trying to get to something like this:

enter image description here

That will look symmetrical.

My X and Y for the first circle (in blue) are known and are static.


原文:https://stackoverflow.com/questions/35050109
更新时间:2022-12-17 15:12

最满意答案

-s开关禁用每次测试捕获。


The -s switch disables per-test capturing.

相关问答

更多
  • 这很简单,你只需要正确构造: def main(): # argument parsing stuff here ... if __name__ == '__main__': main() 现在在测试中直接调用main()函数。 没有必要运行单独的python进程。 要模拟参数解析,您只需要修补sys.argv 。 如果您的脚本依赖于任何配置文件或环境变量,那么您也必须模拟/修补它们。 It's very easy, you just have to structure corr ...
  • 默认情况下, py.test捕获标准输出的结果,以便它可以控制它如何打印出来。 如果没有这样做,它会排除大量的文本,而没有打印该文本的测试的上下文。 但是,如果测试失败,它将在结果报告中包含一个部分,显示在该特定测试中打印到标准的内容。 例如, def test_good(): for i in range(1000): print(i) def test_bad(): print('this should fail!') assert False 结果如下输出: ...
  • -s开关禁用每次测试捕获。 The -s switch disables per-test capturing.
  • 使用pytest 3.x有一种简单的方法可以暂时禁用捕获(请参阅有关capsys.disabled()的部分。 还有pytest-warnings插件,它在专门的报告部分显示警告。 I've done it by manually redirecting stderr: import os import sys import warnings import pytest def test(): stderr = sys.stderr sys.stderr = open(os.devnull ...
  • 对于你的pytest-cov版本需要pytest==3.4.2这么简单编辑requirements.txt到 urllib3==1.22 cx_freeze==6.0b1 pytest==3.4.2 pytest-cov==2.5.1 pytest-dependency==0.2 第一次它帮助我,但现在它甚至工作3.2.2 $ workon ptest (ptest) $ python -V Python 3.5.3 看看安装 (ptest) $ pip freeze attrs==17.4.0 cov ...
  • Decimal((205 / 100) + 1).quantize(Decimal(10) ** -2) == Decimal('3.05') # --> True Decimal((205 / 100) + 1).quantize(Decimal(10) ** -2) == 3.05 # --> False 由于浮点算术的限制,即使它们具有相同的repr,也不能保证十进制值等于float值。 在这种情况下, 3.05不能精确地以二进制表示,所以当比较两个值时, 3.05被转换为 Decimal(3.0 ...
  • 有没有理由你不想在conftest.py文件中使用@pytest.fixture(scope='session')而不是编写自己的插件? 这可以实现在运行时更改灯具的功能吗? 在任何情况下,如果您更改缩进并将self添加到new_fixture的参数,它应该工作。 @pytest.fixture def new_fixture(): return new_fixture_value 至 @pytest.fixture(scope='sessi ...
  • 你可以使用py.io 就像是: capture = py.io.StdCapture() pytest.main(['--collect-only', '-q']) std, err = capture.reset() print(std) 会给你你想要的标准输出。 You could use py.io for this. something like: capture = py.io.StdCapture() pytest.main(['--collect-only', '-q']) std, err ...
  • 如果我正确理解您的评论,项目布局如下: ~/customersites/ ~/customersites/automation/ ~/customersites/automation/pytest.ini 然后按如下方式调用py.test: ~/customersites$ py.test --markers 将使py.test在~/customersites/查找配置文件,然后查找所有父项: ~/ , /home/ , / 。 在这种情况下,这不会使它找到pytest.ini 。 但是,当您使用一个或 ...
  • pytest_xdist有额外的钩子,可以在conftest.py( 钩子列表 )中使用。 为此目的的相关钩子是pytest_configure_node(node) ,它在每个新节点可用并且开始运行测试之前运行。 pytest_xdist has additional hooks that can be used in the conftest.py (list of hooks). The relevant hook for this purpose is pytest_configure_node(n ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。