我正在开发可折叠树图.我试图在节点上生成鼠标悬停事件.当我在节点上鼠标悬停时,它应该显示节点的名称.我试过但我不知道如何计算转换属性值以显示节点上方或下方的名称.
var nodeEnter = node.enter().append("g")
.attr("class", "node")
.attr("transform", function(d) { return "translate(" + source.y0 + "," + source.x0 + ")"; })
.on("click", click)
.on("mouseover", function(d){
alert("over");
d3.select(this).attr('transform', function(d){ return 'translate(?,?)'})
.text(d.name + ": " + d.id)
.style('display', null);
})
.on("mouseout", function(d){ alert("out"); d3.select(this).style('display', 'none'); });
Run Code Online (Sandbox Code Playgroud)
翻译(?,?)
可折叠树图链接:http://bl.ocks.org/mbostock/4339083
请尽量帮助我谢谢
我是D3的新手.我正在使用力导向图.我想在节点的位置添加两种不同类型的形状.
我的json如下:
{
"nodes":[
{"name":"00:00:00:00:00:00:00:01","group":0,"shape":1},
{"name":"00:00:00:00:00:00:00:02","group":1,"shape":1},
{"name":"00:00:00:00:00:00:00:03","group":2,"shape":1},
{"name":"00:00:00:00:00:00:00:11","group":0,"shape":0},
{"name":"00:00:00:00:00:00:00:21","group":1,"shape":0},
{"name":"00:00:00:00:00:00:00:31","group":2,"shape":0},
{"name":"00:00:00:00:00:00:00:32","group":2,"shape":0},
{"name":"00:00:00:00:00:00:00:12","group":0,"shape":0},
{"name":"00:00:00:00:00:00:00:22","group":1,"shape":0}
],
"links":[
{ "source": 0, "target": 0, "value": 5 },
{ "source": 1, "target": 1, "value": 5 },
{ "source": 2, "target": 2, "value": 5 },
{ "source": 3, "target": 0, "value": 5 },
{ "source": 4, "target": 1, "value": 5 },
{ "source": 5, "target": 2, "value": 5 },
{ "source": 6, "target": 2, "value": 5 },
{ "source": 7, "target": 0, "value": 5 },
{ …Run Code Online (Sandbox Code Playgroud) 我使用强制有向图来显示图形视图上的拓扑数据.我写了下面的代码:
var force = d3.layout.force()
.charge(-120)
.alpha(0)
.linkDistance(65)
.gravity(0.03)
.size([width, height]);
force
.nodes(data.nodes)
.links(data.links)
.start();
Run Code Online (Sandbox Code Playgroud)
当我执行代码图初始化时,我需要停止一些运动.我希望静态位置上的图形显示没有任何移动,并且所有链接大小在图形初始化时应该相同.如果我会拖动它然后它会移动.任何帮助将非常感激....!
我想访问像哈希对象的json字符串,以便我可以使用键值来访问json temp["anykey"].如何将ruby格式的json字符串转换为json对象?
我有以下json字符串
temp = '{"accept"=>"*/*", "host"=>"localhost:4567", "version"=>"HTTP/1.1",
"user_agent"=>"curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3",
"http_token"=>"375fe428b1d32787864264b830c54b97"}'
Run Code Online (Sandbox Code Playgroud) 我想使用Java Script或jquery在html输入框中的每2位数后自动插入冒号.
我按下了
00然后像00一样自动插入冒号:
继续保持最多5次
00:00:00:00:00:00
我已经实现了一个数据表的例子.当我点击数据表标题中的"全部"复选框时,它只检查并取消选中一次.第二次它无法检查表体中的所有复选框.我的代码如下:
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="http://cdn.datatables.net/1.10.0-beta.1/js/jquery.dataTables.js"></script>
<link href="http://cdn.datatables.net/1.10.0-beta.1/css/jquery.dataTables.css" rel="stylesheet">
</head>
<body>
<h1>DataTable Checkbox</h1>
<table class="display dataTable" id="flow-table">
<thead>
<th class="check">
<input type="checkbox" id="flowcheckall" value=""> All</input>
</th>
<th>Name</th>
<!-- <th>Cookie</th> -->
<th>Priority</th>
</thead>
<tbody>
</tbody>
</table>
</body>
<script>
$(document).ready(function () {
var str = "";
for (i = 0; i < 25; i++) {
a = i + 1;
str += "<tr><td><input type='checkbox' id='checkall' name='mydata' value=" + a + "></td><td>a" + a + "</td><td>name" + a + "</td></tr>";
} …Run Code Online (Sandbox Code Playgroud) 我想在d3.js的地图上实现语义缩放.我已经开发了一个地图和特定国家的主要城市的例子,它工作正常,但有时候圆圈由于地图附近的地方而重叠,所以如果我实现语义缩放,这将解决我的圆重叠问题.
我不明白如何在地图中仅转换图形而不是圆形.
我的缩放功能代码是:
var zoom = d3.behavior.zoom()
.on("zoom",function() {
g.attr("transform","translate("+
d3.event.translate.join(",")+")scale("+d3.event.scale+")");
g.selectAll("circle")
.attr("d", path.projection(projection));
g.selectAll("path")
.attr("d", path.projection(projection));
});
Run Code Online (Sandbox Code Playgroud)
有人帮帮我!
例如-1:我有像"aaa-23-34"这样的字符串,我希望字符串是"aaa-23"
例如-2: var str = "aaa-44-34-12"
输出应该是 "aaa-44-34"
这意味着我想在最后一个连字符之前使用字符串.