可以在固定圆圈尺寸的d3.js中使用圆形包装布局吗? [英] Possible to use a circle pack layout in d3.js with fixed circle sizes?

查看:131
本文介绍了可以在固定圆圈尺寸的d3.js中使用圆形包装布局吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此圈组布局示例(



当您按常量按钮时,你会看到这样的东西:





关键代码行是:

  pack。值(函数(d){返回100;})

这将使圆半径成为数据的常量。 100当然可以是任何常数。你可以在circle pack初始化中应用这一行(很可能就是你的情况),或者重新初始化(比如我的例子)。



希望这有帮助。


This circle pack layout example (http://bl.ocks.org/4063269) is perfect for a project I'm working on, however it sizes all the circles relative to one another:

Is there a simple way to specify fixed radii for each circle?

I've scoured the source code, examples, google, and stackoverflow and can't seem to find anything helpful.

The exact sizing of circles is important to me.

解决方案

It is possible, and simple thing to do. The first answer is accurate, but I believe mine is simpler, more explicit, so I am attaching it too.

Please take a look at this example: jsfiddle

When you press "Constant" button, you will see something like this:

The key code line is this:

    pack.value(function(d) { return 100; })

This will make circle radiuses constant regardles of data. 100 can be any constant of course. You can apply this line in circle pack initialization (most likely this will be your case), or reinitialization (like in my example).

Hope this helps.

这篇关于可以在固定圆圈尺寸的d3.js中使用圆形包装布局吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆