Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): audit trace graph left align #354

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions glados-web/assets/js/trace/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function ForceGraph({

// Replace the input nodes and links with mutable objects for the simulation.
if (sortByNodeId) {
nodes = d3.map(nodes, (node, i) => ({ id: N[i], fixedX: (calculateNodeIdX(node.id) * width) - (width / 2), ...node}));
nodes = d3.map(nodes, (node, i) => ({ id: N[i], fixedX: calculateNodeIdX(node.id, width) - (width / 2), ...node}));
} else {
nodes = d3.map(nodes, (_, i) => ({ id: N[i] }));
}
Expand All @@ -60,7 +60,6 @@ function ForceGraph({
if (linkStrength !== undefined) forceLink.strength(linkStrength);

const paddingY = 50;
const xPadding = 0;
let simulation;

if (sortByNodeId) {
Expand All @@ -83,11 +82,11 @@ function ForceGraph({
.attr("width", width)
.attr("height", height)
.attr("viewBox", [-width / 2, -height / 2, width, height])
.attr("style", "max-width: 100%; height: auto; height: intrinsic;");
.attr("style", "max-width: 100%; height: auto; height: intrinsic; padding-left: 25px;");

if (sortByNodeId) {
// Add the vertical dotted line
const contentIdMarkerX = calculateNodeIdX(contentId) * width;
const contentIdMarkerX = calculateNodeIdX(contentId, width);
svg.append("line")
.attr("x1", contentIdMarkerX - (width / 2))
.attr("y1", -height / 2)
Expand Down Expand Up @@ -208,11 +207,9 @@ function enforceBorder(position, lowerLimit, upperLimit) {
return position;
}

function calculateNodeIdX(nodeId) {
const MAX_NODE_ID = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");

const nodeIdInt = BigInt(nodeId);
const maxNodeId = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
const nodeIdRatio = (Number(nodeIdInt.toString()) / Number(maxNodeId.toString()));
return nodeIdRatio;

function calculateNodeIdX(nodeId, width) {
const x_pos = BigInt(nodeId) * BigInt(Math.floor(width)) / MAX_NODE_ID;
return Number(x_pos);
}