Skip to content

Commit fc3a35a

Browse files
committed
renamed chart to history
1 parent 4a5689c commit fc3a35a

File tree

2 files changed

+30
-38
lines changed

2 files changed

+30
-38
lines changed

src/app/components/Chart.tsx renamed to src/app/components/History.tsx

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,26 @@ const filterHooks = (data: any[]) => {
3030
return JSON.stringify(data[0].state);
3131
};
3232

33-
interface ChartProps {
33+
interface HistoryProps {
3434
hierarchy: Record<string, unknown>;
3535
}
3636

3737
let root = {};
38-
class Chart extends Component {
38+
class History extends Component {
3939
/**
4040
* @method maked3Tree :Creates a new D3 Tree
4141
*/
42-
constructor(props: ChartProps) {
42+
constructor(props: HistoryProps) {
4343
super(props);
4444
// what React.createRef() is doing.
45-
this.chartRef = React.createRef();
45+
this.HistoryRef = React.createRef();
4646
this.maked3Tree = this.maked3Tree.bind(this);
4747
this.removed3Tree = this.removed3Tree.bind(this);
4848
this.isRecoil = false;
4949
}
5050

5151
componentDidMount() {
5252
const { hierarchy } = this.props;
53-
console.log('HIERARCHYYYYY', hierarchy);
5453
root = JSON.parse(JSON.stringify(hierarchy));
5554
this.maked3Tree();
5655
}
@@ -62,23 +61,23 @@ class Chart extends Component {
6261
}
6362

6463
removed3Tree() {
65-
const { current } = this.chartRef;
64+
const { current } = this.HistoryRef;
6665
while (current.hasChildNodes()) {
6766
current.removeChild(current.lastChild);
6867
}
6968
}
7069

7170
/**
72-
* @method maked3Tree Creates a new Tree Chart
71+
* @method maked3Tree Creates a new Tree History
7372
* @var
7473
*/
7574
maked3Tree(): void {
7675
this.removed3Tree();
77-
78-
const width = 800;
79-
const height = 600;
76+
77+
const width = 800;
78+
const height = 600;
8079
const svgContainer = d3
81-
.select(this.chartRef.current)
80+
.select(this.HistoryRef.current)
8281
.append('svg') // svgContainer is now pointing to svg
8382
.attr('width', width)
8483
.attr('height', height);
@@ -88,19 +87,13 @@ class Chart extends Component {
8887
// this is changing where the graph is located physically
8988
.attr('transform', `translate(${width / 2 + 4}, ${height / 2 + 2})`);
9089

91-
// if we consider the container for our radial node graph as a box encapsulating
92-
// half of this container width is essentially the radius of our radial node graph
93-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
94-
const radius = width / 2;
95-
9690
// d3.hierarchy constructs a root node from the specified hierarchical data
9791
// (our object titled dataset), which must be an object representing the root node
9892
const hierarchy = d3.hierarchy(root);
9993

10094
const tree = d3
10195
.tree()
102-
// this assigns width of tree to be 2pi
103-
// .size([2 * Math.PI, radius / 1.3])
96+
10497
.nodeSize([width / 10, height / 10])
10598
// .separation(function (a, b) { return (a.parent == b.parent ? 1 : 2) / a.depth; });
10699
.separation(function (a: { parent: object }, b: { parent: object }) {
@@ -227,21 +220,12 @@ class Chart extends Component {
227220
return `${d.data.name}.${d.data.branch}`;
228221
});
229222

230-
// allows svg to be dragged around
231-
node.call(
232-
d3
233-
.drag()
234-
.on('start', dragstarted)
235-
.on('drag', dragged)
236-
.on('end', dragended)
237-
);
238-
239-
// d3 zoom functionality
223+
// Zoom Functions
240224
let zoom = d3.zoom().on('zoom', zoomed);
241225
svgContainer.call(
242226
zoom.transform,
243227
// Changes the initial view, (left, top)
244-
d3.zoomIdentity.translate(width/2, height/2).scale(1)
228+
d3.zoomIdentity.translate(width / 2, height / 2).scale(1)
245229
);
246230
// allows the canvas to be zoom-able
247231
svgContainer.call(
@@ -255,7 +239,15 @@ class Chart extends Component {
255239
g.attr('transform', d3.event.transform);
256240
}
257241

258-
// Drag
242+
// DRAG FUNCTIONS
243+
node.call(
244+
d3
245+
.drag()
246+
.on('start', dragstarted)
247+
.on('drag', dragged)
248+
.on('end', dragended)
249+
);
250+
259251
function dragstarted() {
260252
d3.select(this).raise();
261253
g.attr('cursor', 'grabbing');
@@ -286,10 +278,10 @@ class Chart extends Component {
286278
render() {
287279
return (
288280
<div className="history-d3-container">
289-
<div ref={this.chartRef} className="history-d3-div" />
281+
<div ref={this.HistoryRef} className="history-d3-div" />
290282
</div>
291283
);
292284
}
293285
}
294286

295-
export default Chart;
287+
export default History;

src/app/components/StateRoute.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Tree from './Tree';
1515
import Map from './Map';
1616
import PerfView from './PerfView';
1717

18-
const Chart = require('./Chart').default;
18+
const History = require('./History').default;
1919

2020
const ErrorHandler = require('./ErrorHandler').default;
2121

@@ -51,9 +51,9 @@ const StateRoute = (props: StateRouteProps) => {
5151
// the hierarchy gets set on the first click in the page
5252
// when the page is refreshed we may not have a hierarchy, so we need to check if hierarchy was initialized
5353
// if true involk render chart with hierarchy
54-
const renderChart = () => {
54+
const renderHistory = () => {
5555
if (hierarchy) {
56-
return <Chart hierarchy={hierarchy} />;
56+
return <History hierarchy={hierarchy} />;
5757
}
5858
return <div className="noState">{NO_STATE_MSG}</div>;
5959
};
@@ -67,7 +67,7 @@ const StateRoute = (props: StateRouteProps) => {
6767
}
6868
return <div className="noState">{NO_STATE_MSG}</div>;
6969
};
70-
console.log('NORENDER DATA', noRenderData);
70+
7171
let perfChart;
7272
if (true) {
7373
console.log('ViewINDex', viewIndex);
@@ -110,7 +110,7 @@ const StateRoute = (props: StateRouteProps) => {
110110
<NavLink
111111
className="router-link"
112112
activeClassName="is-active"
113-
to="/chart"
113+
to="/history"
114114
>
115115
History
116116
</NavLink>
@@ -127,7 +127,7 @@ const StateRoute = (props: StateRouteProps) => {
127127
</div>
128128
<Switch>
129129
<Route path="/map" render={renderMap} />
130-
<Route path="/chart" render={renderChart} />
130+
<Route path="/history" render={renderHistory} />
131131
<Route path="/performance" render={renderPerfView} />
132132
<Route path="/" render={renderTree} />
133133
</Switch>

0 commit comments

Comments
 (0)