mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-06-24 02:14:17 +00:00
viz: specify all rect styles in parent (#12115)
* viz: specify all rect styles in parent Visually a no-op, but it's easier to reason about when the rect's coloring comes from `g` parent that holds UOp data. * this stays
This commit is contained in:
parent
400ad93892
commit
e76211fcbc
2 changed files with 4 additions and 4 deletions
|
|
@ -90,11 +90,11 @@
|
|||
.label :is(text, p) {
|
||||
font-weight: 350;
|
||||
}
|
||||
rect.node {
|
||||
g.node rect {
|
||||
stroke-width: 1.4;
|
||||
stroke: #4a4b57;
|
||||
}
|
||||
rect.overlay {
|
||||
g.overlay rect {
|
||||
fill: rgba(26, 27, 38, 0.5);
|
||||
}
|
||||
.edgePath {
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ function renderDag(graph, additions, recenter) {
|
|||
// draw nodes
|
||||
const STROKE_WIDTH = 1.4;
|
||||
d3.select("#graph-svg").on("click", () => d3.selectAll(".highlight").classed("highlight", false));
|
||||
const nodes = d3.select("#nodes").selectAll("g").data(g.nodes().map(id => g.node(id)), d => d).join("g")
|
||||
const nodes = d3.select("#nodes").selectAll("g").data(g.nodes().map(id => g.node(id)), d => d).join("g").attr("class", d => d.className ?? "node")
|
||||
.attr("transform", d => `translate(${d.x},${d.y})`).classed("clickable", d => d.ref != null).on("click", (e,d) => {
|
||||
if (d.ref != null) return setCtxWithHistory(d.ref);
|
||||
const parents = g.predecessors(d.id);
|
||||
|
|
@ -80,7 +80,7 @@ function renderDag(graph, additions, recenter) {
|
|||
e.stopPropagation();
|
||||
});
|
||||
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("class", d => d.className ?? "node");
|
||||
.attr("x", d => -d.width/2).attr("y", d => -d.height/2);
|
||||
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+STROKE_WIDTH;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue