Skip to content

Commit 85ccb13

Browse files
committed
broken
1 parent 6719331 commit 85ccb13

File tree

2 files changed

+22
-127
lines changed

2 files changed

+22
-127
lines changed

src/app/components/PerfView.jsx

Lines changed: 21 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,36 @@ import React, { useEffect, useRef } from 'react';
1111
import * as d3 from 'd3';
1212
import { addNewSnapshots } from '../actions/actions';
1313

14+
const chartData = {
15+
name: 'App',
16+
actualDuration: 35000,
17+
value: 17010,
18+
children: [
19+
{ name: 'DisplayPanel', actualDuration: 35000, value: 17010 },
20+
{ name: 'AltDisplay', actualDuration: 35000, value: 5842 },
21+
{ name: 'MarketSContainer', actualDuration: 35000, value: 1041 },
22+
{ name: 'MainSlider', actualDuration: 35000, value: 5176 },
23+
],
24+
};
25+
1426
const PerfView = ({
1527
width = 200,
1628
height = 200,
17-
snapshots
29+
// snapshots
1830
}) => {
19-
console.log('this is snapshots at PerfView', snapshots);
20-
console.log('this is snapshots[snapshots.length-1] at PerfView', snapshots[snapshots.length - 1]);
21-
const chartData = snapshots[snapshots.length - 1];
31+
// const chartData = snapshots;
32+
// const chartData = snapshots[snapshots.length - 1].children[0];
33+
// console.log("snapshots", snapshots);
34+
console.log("chartData", chartData);
35+
2236
const svgRef = useRef(null);
37+
2338
// returns color scale function
2439
const color = d3.scaleLinear()
2540
.domain([0, 5])
2641
.range(['hsl(152,80%,80%)', 'hsl(228,30%,40%)'])
2742
.interpolate(d3.interpolateHcl);
2843

29-
// returns a function that formats numbers
30-
const numFormat = d3.format(',d');
31-
32-
const margin = { top: 0, right: 60, bottom: 200, left: 120, };
33-
3444
// create a new circle packing layout function
3545
const packFunc = data => d3.pack()
3646
.size([width, height])
@@ -70,7 +80,7 @@ const PerfView = ({
7080
.append('text')
7181
.style('fill-opacity', d => (d.parent === packedRoot ? 1 : 0))
7282
.style('display', d => (d.parent === packedRoot ? 'inline' : 'none'))
73-
.text(d => `${d.data.name}: ${Number.parseFloat(d.data.actualDuration).toFixed(2)}ms`);
83+
.text(d => `${d.name}: ${Number.parseFloat(d.actualDuration).toFixed(2)}ms`);
7484

7585
console.log('PerfView -> node', node);
7686
zoomTo([packedRoot.x, packedRoot.y, packedRoot.r * 2]);
@@ -105,123 +115,8 @@ const PerfView = ({
105115
}
106116
}, [chartData]);
107117

108-
return <div className="d3divContainer"><svg viewBox="-250 -250 500 500" className="perfContainer" ref={svgRef} /></div>;
118+
return <svg viewBox="-250 -250 500 500" className="perfContainer" ref={svgRef} />;
109119
};
110120

111-
// class PerfView extends React.Component {
112-
// constructor(props) {
113-
// super(props);
114-
// this.svgRef = React.createRef(null);
115-
// // returns color scale function
116-
// this.color = d3.scaleLinear()
117-
// .domain([0, 5])
118-
// .range(['hsl(152,80%,80%)', 'hsl(228,30%,40%)'])
119-
// .interpolate(d3.interpolateHcl);
120-
121-
// // returns a function that formats numbers
122-
// this.numFormat = d3.format(',d');
123-
124-
// this.margin = { top: 0, right: 60, bottom: 200, left: 120, };
125-
126-
// // create a new circle packing layout function
127-
// this.packFunc = data => d3.pack()
128-
// .size([this.props.width, this.props.height])
129-
// .padding(3)(d3.hierarchy(data)
130-
// .sum(d => d.value)
131-
// .sort((a, b) => b.value - a.value));
132-
133-
// this.drawChart = this.drawChart.bind(this);
134-
// }
135-
136-
// componentDidMount() {
137-
// this.drawChart();
138-
// }
139-
140-
// componentDidUpdate() {
141-
// this.drawChart();
142-
// }
143-
144-
// drawChart() {
145-
// console.log("PerfView -> drawChart -> chartData", chartData)
146-
// console.log("PerfView -> drawChart -> this.props.width", this.props.width)
147-
// const packedRoot = this.packFunc(chartData);
148-
// // console.log('** PerfView -> packedRoot', packedRoot);
149-
// let focus = packedRoot;
150-
// let view;
151-
// console.log('packedRoot.descendents().slice(1)', packedRoot.descendants().slice(1));
152-
153-
// const svg = d3.select(this.svgRef.current)
154-
// .attr('class', 'd3Container')
155-
// .attr('viewBox', `-${this.props.width / 2} -${this.props.height / 2} ${this.props.width} ${this.props.height}`)
156-
// .style('display', 'block')
157-
// .style('margin', '0 -14px')
158-
// .style('background', this.color(0))
159-
// .style('cursor', 'pointer')
160-
// .on('click', () => zoom(packedRoot));
161-
162-
163-
// const node = svg.append('g')
164-
// .selectAll('circle')
165-
// .data(packedRoot.descendants().slice(1))
166-
// // .join('circle')
167-
// .enter()
168-
// .append('circle')
169-
// .attr('fill', d => (d.children ? this.color(d.depth) : 'white'))
170-
// .attr('pointer-events', d => (!d.children ? 'none' : null))
171-
// .on('mouseover', function () { d3.select(this).attr('stroke', '#000'); })
172-
// .on('mouseout', function () { d3.select(this).attr('stroke', null); })
173-
// .on('click', d => focus !== d && (zoom(d), d3.event.stopPropagation()));
174-
175-
// const label = svg.append('g')
176-
// .style('font', '10px sans-serif')
177-
// .attr('pointer-events', 'none')
178-
// .attr('text-anchor', 'middle')
179-
// .selectAll('text')
180-
// .data(packedRoot.descendants())
181-
// // .join('text')
182-
// .enter()
183-
// .append('text')
184-
// .style('fill-opacity', d => (d.parent === packedRoot ? 1 : 0))
185-
// .style('display', d => (d.parent === packedRoot ? 'inline' : 'none'))
186-
// .text(d => d.data.name);
187-
188-
// console.log('PerfView -> node', node);
189-
190-
// zoomTo([packedRoot.x, packedRoot.y, packedRoot.r * 2], this.props.width);
191-
192-
// function zoomTo(v, width) {
193-
// const k = width / v[2];
194-
// view = v;
195-
196-
// label.attr('transform', d => `translate(${(d.x - v[0]) * k},${(d.y - v[1]) * k})`);
197-
// node.attr('transform', d => `translate(${(d.x - v[0]) * k},${(d.y - v[1]) * k})`);
198-
// node.attr('r', d => d.r * k);
199-
// }
200-
201-
// function zoom(d) {
202-
// const focus0 = focus;
203-
204-
// focus = d;
205-
206-
// const transition = svg.transition()
207-
// .duration(d3.event.altKey ? 7500 : 750)
208-
// .tween('zoom', d => {
209-
// const i = d3.interpolateZoom(view, [focus.x, focus.y, focus.r * 2]);
210-
// return t => zoomTo(i(t));
211-
// });
212-
213-
// label
214-
// .filter(function (d) { return d.parent === focus || this.style.display === 'inline'; })
215-
// .transition(transition)
216-
// .style('fill-opacity', d => (d.parent === focus ? 1 : 0))
217-
// .on('start', function (d) { if (d.parent === focus) this.style.display = 'inline'; })
218-
// .on('end', function (d) { if (d.parent !== focus) this.style.display = 'none'; });
219-
// }
220-
// }
221-
222-
// render() {
223-
// return <svg ref={this.svgRef} />;
224-
// }
225-
// }
226121

227122
export default PerfView;

src/app/components/StateRoute.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const StateRoute = ({
4545

4646
const renderPerfView = () => {
4747
if (hierarchy) {
48-
return <PerfView width={600} height={600} snapshots={snapshots} />; // ref={windowRef}
48+
return <PerfView width={600} height={600} snapshots={snapshot} />; // ref={windowRef}
4949
}
5050
return <div className="noState">{NO_STATE_MSG}</div>;
5151
};

0 commit comments

Comments
 (0)