Skip to content

Commit eb41f09

Browse files
committed
add radius default and change chart text color to app white
1 parent 1aa44eb commit eb41f09

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/app/components/PerfView.jsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ const PerfView = ({ snapshots, viewIndex, width = 600, height = 600 }) => {
4242
const packFunc = useCallback(data => {
4343
return d3.pack()
4444
.size([width, height])
45+
.radius(d => { return d.r; })
4546
.padding(3)(d3.hierarchy(data)
46-
.sum(d => { return d.componentData.actualDuration || 0; })
47-
.sort((a, b) => { return b.value - a.value; }));
47+
.sum(d => { return d.componentData.actualDuration || 0; })
48+
.sort((a, b) => { return b.value - a.value; }));
4849
}, [width, height]);
4950

5051
// If indexToDisplay changes, clear old tree nodes
@@ -56,13 +57,14 @@ const PerfView = ({ snapshots, viewIndex, width = 600, height = 600 }) => {
5657
}, [indexToDisplay, svgRef]);
5758

5859
useEffect(() => {
59-
// console.log(`***** useEffect - MAIN -> snapshots[${indexToDisplay}]`, snapshots[indexToDisplay]);
60-
60+
console.log(`***** useEffect - MAIN -> snapshots[${indexToDisplay}]`, snapshots[indexToDisplay]);
61+
6162
// Error, no App-level component present
6263
if (snapshots[indexToDisplay].children.length < 1) return;
6364

6465
// Generate tree with our data
6566
const packedRoot = packFunc(snapshots[indexToDisplay]);
67+
console.log('PerfView -> packedRoot', packedRoot);
6668

6769
// Set initial focus to root node
6870
let curFocus = packedRoot;
@@ -82,13 +84,12 @@ const PerfView = ({ snapshots, viewIndex, width = 600, height = 600 }) => {
8284
.enter().append('circle')
8385
.attr('fill', d => (d.children ? colorScale(d.depth) : 'white'))
8486
.attr('pointer-events', d => (!d.children ? 'none' : null))
85-
.on('mouseover', () => d3.select(this).attr('stroke', '#000'))
86-
.on('mouseout', () => d3.select(this).attr('stroke', null))
87+
.on('mouseover', function () { d3.select(this).attr('stroke', '#000'); })
88+
.on('mouseout', function () { d3.select(this).attr('stroke', null); })
8789
.on('click', d => curFocus !== d && (zoomToNode(d), d3.event.stopPropagation()));
8890

8991
// Generate text labels. Set (only) root to visible initially
9092
const label = svg.append('g')
91-
// .style('fill', 'rgb(231, 231, 231)')
9293
.attr('class', 'perf-chart-labels')
9394
.selectAll('text')
9495
.data(packedRoot.descendants())
@@ -107,7 +108,7 @@ const PerfView = ({ snapshots, viewIndex, width = 600, height = 600 }) => {
107108

108109
// Zoom/relocated nodes and labels based on dimensions given [x, y, r]
109110
function zoomViewArea(newXYR) {
110-
console.log("zoomTo -> newXYR", newXYR);
111+
// console.log('zoomTo -> newXYR', newXYR);
111112
const k = width / newXYR[2];
112113
view = newXYR;
113114
label.attr('transform', d => `translate(${(d.x - newXYR[0]) * k},${(d.y - newXYR[1]) * k})`);
@@ -144,4 +145,4 @@ export default PerfView;
144145

145146

146147
// d3.quantize(d3.interpolateHcl('#60c96e', '#4d4193'), 10);
147-
// const colorScale = d3.scaleOrdinal(colorScheme);
148+
// const colorScale = d3.scaleOrdinal(colorScheme);

src/app/styles/components/d3graph.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ div.tooltip {
107107
}
108108

109109
.perf-chart-labels {
110-
font: 15px sans-serif;
111-
color: white;
110+
font: 12px sans-serif;
111+
/* color: white; */
112+
fill: rgb(231, 231, 231);
112113
pointer-events: none;
113114
text-anchor: middle;
114115
};

0 commit comments

Comments
 (0)