diff --git a/tinygrad/viz/js/index.js b/tinygrad/viz/js/index.js index 970bca83ac..2469ff7ec8 100644 --- a/tinygrad/viz/js/index.js +++ b/tinygrad/viz/js/index.js @@ -35,16 +35,17 @@ async function renderDag(graph, additions, recenter=false) { d3.select("#bars").html(""); const g = dagre.graphlib.json.read(e.data); // draw nodes + const STROKE_WIDTH = 1.4; const nodes = d3.select("#nodes").selectAll("g").data(g.nodes().map(id => g.node(id)), d => d).join("g") .attr("transform", d => `translate(${d.x},${d.y})`); nodes.selectAll("rect").data(d => [d]).join("rect").attr("width", d => d.width).attr("height", d => d.height).attr("fill", d => d.color) - .attr("x", d => -d.width/2).attr("y", d => -d.height/2).attr("style", d => "stroke:#4a4b57; stroke-width:1.4px;"+d.style); + .attr("x", d => -d.width/2).attr("y", d => -d.height/2).attr("style", d => `stroke:#4a4b57; stroke-width:${STROKE_WIDTH}px; ${d.style}`); nodes.selectAll("g.label").data(d => [d]).join("g").attr("class", "label").attr("transform", d => { const x = (d.width-d.padding*2)/2; - const y = (d.height-d.padding*2)/2; + const y = (d.height-d.padding*2)/2+STROKE_WIDTH; return `translate(-${x}, -${y})`; - }).selectAll("text").data(d => [d.label.split("\n")]).join("text").selectAll("tspan").data(d => d).join("tspan").text(d => d).attr("x", "1") - .attr("dy", 14).attr("xml:space", "preserve"); + }).selectAll("text").data(d => [d.label.split("\n")]).join("text").selectAll("tspan").data(d => d).join("tspan").text(d => d).attr("x", "0") + .attr("dy", 14).attr("xml:space", "preserve"); // draw edges const line = d3.line().x(d => d.x).y(d => d.y).curve(d3.curveBasis); d3.select("#edges").selectAll("path.edgePath").data(g.edges()).join("path").attr("class", "edgePath").attr("d", (e) => {