Skip to content

Commit b092a42

Browse files
authored
Merge pull request #8 from aquinojardim/master
Reorganized chart display
2 parents 0bb9e8b + b4f9303 commit b092a42

File tree

4 files changed

+43
-12
lines changed

4 files changed

+43
-12
lines changed

src/app/components/Chart.jsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ class Chart extends Component {
2323

2424
componentDidMount() {
2525
const { hierarchy } = this.props;
26+
console.log('this is hierarchy on didMount chart', hierarchy)
2627
root = JSON.parse(JSON.stringify(hierarchy));
2728
this.maked3Tree();
2829
}
2930

3031
componentDidUpdate() {
3132
const { hierarchy } = this.props;
33+
console.log('this is hierarchy on didUpdate chart', hierarchy)
3234
root = JSON.parse(JSON.stringify(hierarchy));
3335
this.maked3Tree();
3436
}
@@ -50,7 +52,7 @@ class Chart extends Component {
5052
};
5153
const width = 600 - margin.right - margin.left;
5254
const height = 700 - margin.top - margin.bottom;
53-
55+
console.log('this is this.chartRef.current on chart', this.chartRef.current)
5456
const chartContainer = d3.select(this.chartRef.current)
5557
.append('svg') // chartContainer is now pointing to svg
5658
.attr('width', width)
@@ -71,7 +73,8 @@ class Chart extends Component {
7173
const tree = d3.tree()
7274
// this assigns width of tree to be 2pi
7375
.size([2 * Math.PI, radius / 1.3])
74-
.separation(function (a, b) { return (a.parent == b.parent ? 1 : 2) / a.depth; });
76+
// .separation(function (a, b) { return (a.parent == b.parent ? 1 : 2) / a.depth; });
77+
.separation(function (a, b) { return (a.parent == b.parent ? 1 : 2)});
7578

7679
const d3root = tree(hierarchy);
7780

@@ -142,7 +145,10 @@ class Chart extends Component {
142145
// this arranges the angle of the text
143146
.attr('transform', function (d) { return 'rotate(' + (d.x < Math.PI ? d.x - Math.PI / 2 : d.x + Math.PI / 2) * 1 / Math.PI + ')'; })
144147
.text(function (d) {
145-
return d.data.index;
148+
console.log('this is d from text char line 148', d)
149+
// save d.data.index to variable
150+
// gabi and nate :: display the name of of specific patch
151+
return `${d.data.name}.${d.data.branch}`;
146152
});
147153

148154
// allows svg to be dragged around

src/app/containers/ActionContainer.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const resetSlider = () => {
1414

1515
function ActionContainer() {
1616
const [{ tabs, currentTab }, dispatch] = useStoreContext();
17-
const { snapshots, sliderIndex, viewIndex } = tabs[currentTab];
17+
const { hierarchy, snapshots, sliderIndex, viewIndex } = tabs[currentTab];
18+
console.log('actionContainer tabs[currentTab];', tabs[currentTab])
19+
console.log('actionContainer snapshots;', snapshots)
1820

1921
let actionsArr = [];
2022
// build actions array

src/app/styles/components/d3graph.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ div.tooltip {
5858
pointer-events: none;
5959
}
6060

61-
/* .d3-tip {
61+
.d3-tip {
6262
line-height: 1;
6363
padding: 6px;
6464
background: #9cf4df;
@@ -68,9 +68,9 @@ div.tooltip {
6868
max-width: 400px;
6969
overflow-wrap: break-word;
7070
font-family: "Overpass Mono", monospace;
71-
} */
71+
}
7272

73-
/* Creates a small triangle extender for the tooltip
73+
/* Creates a small triangle extender for the tooltip */
7474
.d3-tip:after {
7575
box-sizing: border-box;
7676
display: inline;
@@ -80,11 +80,11 @@ div.tooltip {
8080
content: "\25BC";
8181
position: absolute;
8282
text-align: center;
83-
} */
83+
}
8484

8585
/* Style northward tooltips specifically */
86-
/* .d3-tip.n:after {
86+
.d3-tip.n:after {
8787
margin: -2px 0 0 0;
8888
top: 100%;
8989
left: 0;
90-
} */
90+
}

src/extension/background.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ function createTabObj(title) {
1717
title,
1818
// snapshots is an array of ALL state snapshots for the reactime tab working on a specific user application
1919
snapshots: [],
20-
index: 0,
20+
// gabi and nate :: index here is the tab index that show total amount of state changes
21+
index: 0,
2122
//* this is our pointer so we know what the current state the user is checking (this accounts for time travel aka when user clicks jump on the UI)
2223
currLocation: null,
24+
// gabi and nate :: point the node that will generate the next child set by newest node or jump
25+
currParent: 0,
26+
// gabi and nate :: points to the current branch
27+
currBranch: 0,
2328
//* inserting a new property to build out our hierarchy dataset for d3
2429
hierarchy: null,
2530
mode: {
@@ -35,7 +40,12 @@ class Node {
3540
// eslint-disable-next-line no-param-reassign
3641
// eslint-disable-next-line no-multi-assign
3742
// eslint-disable-next-line no-plusplus
43+
// gabi and nate :: continue the order of number of total state changes
3844
this.index = tabObj.index++;
45+
// gabi and nate :: continue the order of number of states changed from that parent
46+
this.name = tabObj.currParent+=1;
47+
// gabi and nate :: mark from what branch this node is originated
48+
this.branch = tabObj.currBranch;
3949
this.stateSnapshot = obj;
4050
this.children = [];
4151
console.log('created node in background.js constructor');
@@ -48,14 +58,24 @@ function sendToHierarchy(tabObj, newNode) {
4858
tabObj.hierarchy = newNode;
4959
} else {
5060
tabObj.currLocation.children.push(newNode);
61+
// gabi and nate :: if the node's children's array is empty
62+
if(tabObj.currLocation.children.length > 1){
63+
// gabi and nate :: increment the value of the nodes branch by 1
64+
newNode.branch+=1
65+
// gabi and nate :: reassign value of current branch to be the length of the children array less one
66+
tabObj.currBranch = tabObj.currLocation.children.length-1;
67+
}
5168
tabObj.currLocation = newNode;
5269
}
5370
}
5471

5572
function changeCurrLocation(tabObj, rootNode, index) {
73+
// gabi and nate :: index comes from the app's main reducer to locate the right current location on tabObj
5674
// check if current node has the index wanted
57-
if (rootNode.index === index) {
75+
if (rootNode.index === index) {
5876
tabObj.currLocation = rootNode;
77+
// gabi and nate :: index of current location from where the next node will be a child
78+
tabObj.currParent = index;
5979
return;
6080
}
6181
// base case if no children
@@ -165,6 +185,9 @@ chrome.runtime.onMessage.addListener((request, sender) => {
165185

166186
switch (action) {
167187
case 'jumpToSnap': {
188+
// console.log('this tabsObj[tabId] sent to changeCurrLocation', tabsObj[tabId])
189+
// console.log('this tabsObj[tabId].hierarchy sent to changeCurrLocation', tabsObj[tabId].hierarchy)
190+
// console.log('this index sent to changeCurrLocation', index)
168191
changeCurrLocation(tabsObj[tabId], tabsObj[tabId].hierarchy, index);
169192
break;
170193
}

0 commit comments

Comments
 (0)