Skip to content

Commit f66482c

Browse files
committed
added initial legends component to History component
1 parent bae1383 commit f66482c

File tree

3 files changed

+354
-18
lines changed

3 files changed

+354
-18
lines changed

src/app/components/History.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { Component, useEffect, useState } from 'react';
22
import * as d3 from 'd3';
3+
import Example from './legend';
34

45
/**
56
* @var colors: Colors array for the diffrerent node branches, each color is for a different branch
@@ -30,7 +31,6 @@ const filterHooks = (data: any[]) => {
3031
return JSON.stringify(data[0].state);
3132
};
3233

33-
3434
/**
3535
* @method maked3Tree :Creates a new D3 Tree
3636
*/
@@ -68,7 +68,7 @@ function History(props) {
6868
const g = svgContainer
6969
.append('g')
7070
// this is changing where the graph is located physically
71-
.attr('transform', `translate(${width / 2 + 4}, ${height / 2 + 2})`)
71+
.attr('transform', `translate(${width / 2 + 4}, ${height / 2 + 2})`);
7272

7373
// d3.hierarchy constructs a root node from the specified hierarchical data
7474
// (our object titled dataset), which must be an object representing the root node
@@ -83,7 +83,6 @@ function History(props) {
8383

8484
const d3root = tree(hierarchy);
8585

86-
8786
g.selectAll('.link')
8887
// root.links() gets an array of all the links,
8988
// where each element is an object containing a
@@ -109,12 +108,12 @@ function History(props) {
109108
.append('g')
110109
.style('fill', function (d) {
111110
let loadTime;
112-
if (d.data.stateSnapshot.children[0].componentData.actualDuration){
113-
loadTime = d.data.stateSnapshot.children[0].componentData.actualDuration;
114-
} else{
111+
if (d.data.stateSnapshot.children[0].componentData.actualDuration) {
112+
loadTime =
113+
d.data.stateSnapshot.children[0].componentData.actualDuration;
114+
} else {
115115
loadTime = 1;
116116
}
117-
118117

119118
if (loadTime !== undefined) {
120119
if (loadTime > 16) {
@@ -255,7 +254,8 @@ function History(props) {
255254

256255
return (
257256
<>
258-
<div ref={HistoryRef} className="history-d3-div" id="historyContainer"/>
257+
<div ref={HistoryRef} className="history-d3-div" id="historyContainer" />
258+
{/* <Example /> */}
259259
</>
260260
);
261261
}

src/app/components/StateRoute.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import ComponentMap from './ComponentMap';
1616
import PerfView from './PerfView';
1717
import AtomsRelationship from './AtomsRelationship.jsx';
1818
import Example from './AtomsRelationship.jsx';
19-
import { ParentSize } from '@visx/responsive'
19+
import { ParentSize } from '@visx/responsive';
2020
import { Console } from 'console';
21-
21+
import Legendary from './legend';
2222

2323
const History = require('./History').default;
2424

@@ -79,20 +79,21 @@ const StateRoute = (props: StateRouteProps) => {
7979
// if true involk render chart with hierarchy
8080
const renderHistory = () => {
8181
if (hierarchy) {
82-
return <History hierarchy={hierarchy} />;
82+
return (
83+
<History hierarchy={hierarchy} />;
84+
<Legendary />
85+
);
8386
}
8487
return <div className="noState">{NO_STATE_MSG}</div>;
8588
};
8689

8790
const renderAtomsRelationship = () => (
88-
89-
<ParentSize>{({ width, height }) =>
90-
<Example
91-
width={width}
92-
height={height}
93-
snapshots = {snapshots} />}
91+
<ParentSize>
92+
{({ width, height }) => (
93+
<Example width={width} height={height} snapshots={snapshots} />
94+
)}
9495
</ParentSize>
95-
96+
9697
// atomsComponents={snapshot.atomsComponents}
9798
// atomSelectors={snapshot.atomSelectors}
9899
// />

0 commit comments

Comments
 (0)