我正在尝试在d3 v4中创建一个forceSimulation,它不会像在本示例中针对d3 v3 https://bl.ocks.org/mbostock/1129492那样使节点漂浮在svg的边界之外。
在Simulation.on(“ tick”,tick)中尝试了几项不同的尝试均无济于事。我的codePen在下面。关于如何实现这一目标的任何想法?
https://codepen.io/mtsvelik/pen/rzxVrE
//Read the data from the mis element
var graph = document.getElementById('json').innerHTML;
graph = JSON.parse(graph);
render(graph);
function render(graph){
// Dimensions of sunburst.
var radius = 6;
var maxValue = d3.max(graph.links, function(d, i, data) {
return d.value;
});
//sub-in max-value from
d3.select("div").html('<form class="force-control" ng-if="formControl">Link threshold 0 <input type="range" id="thersholdSlider" name="points" value="0" min="0" max="'+ maxValue +'">'+ maxValue +'</form>');
document.getElementById("thersholdSlider").onchange = function() {threshold(this.value);};
var svg = d3.select("svg");
var width = svg.attr("width");
var height = svg.attr("height");
console.log(graph); …Run Code Online (Sandbox Code Playgroud) d3.js ×1