Skip to content

Commit

Permalink
Update TimelineGraph.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
LPeter1997 committed Sep 21, 2023
1 parent 35731dd commit e0cde78
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/Draco.Trace.Visualizer/src/TimelineGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ const TimelineGraph = (props: Props) => {

const colorScale = d3.interpolateHsl('green', 'red');

svg
.selectAll('rect')
const allNodes = svg
.selectAll('g')
.data(messageHierarchy.descendants())
.join('rect')
.join('g');

allNodes
.append('rect')
.attr('x', node => (node as any).x0)
.attr('y', node => height - (node as any).y1)
.attr('width', node => (node as any).x1 - (node as any).x0)
Expand All @@ -52,6 +55,19 @@ const TimelineGraph = (props: Props) => {
: 1;
return colorScale(fillPercentage);
});

const wideNodes = allNodes
.filter(node => !node.data.isPlaceholder)
.filter(node => (node as any).x1 - (node as any).x0 > 5);

wideNodes
.append('text')
.text(node => node.data.name)
.attr('color', 'black')
.attr('dominant-baseline', 'middle')
.attr('text-anchor', 'middle')
.attr('x', node => (node as any).x0 + ((node as any).x1 - (node as any).x0) / 2)
.attr('y', node => height - (node as any).y1 + ((node as any).y1 - (node as any).y0) / 2);
}, [data, width, height]);

return (
Expand Down

0 comments on commit e0cde78

Please sign in to comment.