Skip to content

Commit d1ece17

Browse files
committed
fixed some d3 graph code
1 parent afbe85d commit d1ece17

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/app/components/Chart.jsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class Chart extends Component {
3737
maked3Tree() {
3838
// this.removed3Tree();
3939
const dataset = {
40-
name: "parentMost",
40+
name: "rootNode",
41+
diffState: {},
4142
children: [
4243
{
4344
name: 'state1',
@@ -124,26 +125,33 @@ class Chart extends Component {
124125

125126
let g = chartContainer
126127
.append("g")
127-
.attr("transform", `translate(${width / 2 + 40}, ${height / 2 + 90})`);
128+
// this is changing where the graph is located physically
129+
.attr("transform", `translate(${width / 2.5}, ${height / 2 + 90})`);
130+
131+
// if we consider the container for our radial node graph as a box encapsulating, half of this container width is essentially the radius of our radial node graph
128132
let radius = width / 2;
129133

130-
let root = d3.hierarchy(dataset);
134+
// d3.hierarchy constructs a root node from the specified hierarchical data (our object titled dataset), which must be an object representing the root node
135+
let hierarchy = d3.hierarchy(dataset);
131136

132-
let treeLayout = d3.tree()
137+
let tree = d3.tree()
138+
// this assigns width of tree to be 2pi
133139
.size([2 * Math.PI, radius])
134140

135-
let tree = treeLayout(root);
141+
let root = tree(hierarchy);
136142

137143
console.log('children', root.descendants());
138144

139-
g.selectAll('path')
145+
g.selectAll('.link')
146+
// root.links() gets an array of all the links, where each element is an object containing a source property, which represents the link's source node, and a target property, which represents the link's target node.
140147
.data(root.links())
141148
.enter()
142149
.append('path')
143150
.attr('class', 'link')
144151
.attr("d", d3.linkRadial()
145152
.angle(d => d.x)
146153
.radius(d => d.y));
154+
147155
let node = g.selectAll(".node")
148156
// root.descendants gets an array of of all nodes
149157
.data(root.descendants())

src/extension/background.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ function createTabObj(title) {
1616
};
1717
}
1818

19+
// create a helper function that groups all the snapshots underneath each other
20+
// current state snapshot
21+
// needs to be supplied by the UI
22+
// also need to figure out how we would traverse through the big ass object to find the current state
23+
// Create a new object with name,
24+
1925
// establishing connection with devtools
2026
chrome.runtime.onConnect.addListener(port => {
2127
// push every port connected to the ports array
@@ -122,6 +128,7 @@ chrome.runtime.onMessage.addListener((request, sender) => {
122128
reloaded[tabId] = false;
123129

124130
tabsObj[tabId].snapshots.push(request.payload);
131+
console.log(tabsObj[tabId].snapshots);
125132
if (portsArr.length > 0) {
126133
portsArr.forEach(bg => bg.postMessage({
127134
action: 'initialConnectSnapshots',

0 commit comments

Comments
 (0)