Skip to content

Commit 9394f61

Browse files
authored
Merge pull request #13 from Umius-Brian/MVP-Features
MVP Features
2 parents a635394 + 8f48fc7 commit 9394f61

3 files changed

Lines changed: 50 additions & 28 deletions

File tree

app/charts/route-trace.jsx

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
import * as d3 from 'd3';
2-
class RouteTrace {
32

3+
let text = [{
4+
t: 'reverseproxy',
5+
}, {
6+
t: 'books',
7+
}, {
8+
t: 'orders',
9+
}, {
10+
t: 'customers'
11+
}]
12+
class RouteTrace {
413
containerEl;
514
props;
615
svg;
7-
16+
17+
// creating D3 container for the nodes
818
constructor(containerEl, props) {
919
this.containerEl = containerEl;
1020
this.props = props;
@@ -17,38 +27,52 @@ class RouteTrace {
1727
this.updateDatapoints();
1828
}
1929

30+
2031
updateDatapoints = () => {
2132
const { svg, props: { data, width, height } } = this;
2233
console.log('data: ', data)
2334
console.log('nodes: ', data[0])
2435
console.log('links: ', data[1])
36+
37+
console.log('1st data point: ', data[0][0])
38+
console.log('4th data point: ', data[0][3])
2539

2640

2741
var simulation = d3.forceSimulation(data[0])
2842
  .force('link', d3.forceLink())
2943
  .force('charge', d3.forceManyBody())
3044
.force('center', d3.forceCenter(width / 2, height / 2))
31-
45+
3246
const node = svg
33-
.selectAll("circle")
34-
.data(data[0])
35-
.enter()
36-
.append("circle")
37-
.attr("r", 20)
38-
.attr('cx', () => Math.random() * width)
39-
.attr('cy', () => Math.random() * height)
40-
.style("fill", "#00eda0")
41-
.on('mouseup', (d, i, nodes) => this.setActiveDatapoint(d, nodes[i]));
47+
.selectAll('circle')
48+
.data(data[0])
49+
.enter()
50+
.append('circle')
51+
.on('mouseover', () => d3.select(this).text(d.id))
52+
53+
const circleAttr = node
54+
.attr('r', 20)
55+
.attr('cx', 200)
56+
.attr('cy', 200)
57+
.style('fill', '#00eda0')
58+
.on('mouseup', (d, i, nodes) => this.setActiveDatapoint(d, nodes[i]))
4259

43-
node.append("title")
44-
.text(function(d) { return d.id; });
60+
const text = svg.selectAll('text')
61+
.data(data[0]).enter().append('text')
62+
63+
const textLabels = text
64+
.attr('x', d => d.x)
65+
.attr('y', d => d.y)
66+
.attr('dx', 100)
67+
.attr('dy','10em')
68+
.text(d => d.id);
4569

4670
const link = svg
47-
.selectAll("line")
71+
.selectAll('line')
4872
.data(data[1])
4973
.enter()
50-
.append("line")
51-
.style("stroke", "black")
74+
.append('line')
75+
.style('stroke', 'black')
5276

5377
simulation
5478
.nodes(data[0])
@@ -57,19 +81,17 @@ class RouteTrace {
5781
simulation.force('link')
5882
.links(link);
5983

60-
6184
function ticked() {
6285
link
63-
.attr("x1", function(d) { return d.source.x; })
64-
.attr("y1", function(d) { return d.source.y; })
65-
.attr("x2", function(d) { return d.target.x; })
66-
.attr("y2", function(d) { return d.target.y; });
86+
.attr('x1', function(d) { return d.source.x; })
87+
.attr('y1', function(d) { return d.source.y; })
88+
.attr('x2', function(d) { return d.target.x; })
89+
.attr('y2', function(d) { return d.target.y; });
6790

6891
node
69-
.attr("cx", function(d) { return d.x; })
70-
.attr("cy", function(d) { return d.y; });
92+
.attr('cx', function(d) { return d.x; })
93+
.attr('cy', function(d) { return d.y; });
7194
}
72-
7395
}
7496

7597
setActiveDatapoint = (d, node) => {

app/containers/GraphsContainer.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import TemperatureChart from '../charts/temperature-chart.jsx';
77
import LatencyChart from '../charts/latency-chart.jsx';
88
import MemoryChart from '../charts/memory-chart.jsx';
99
import RouteTrace from '../charts/route-trace.jsx';
10+
// import RouteLocations from '../charts/route-copy.jsx';
1011
import MicroServiceTraffic from '../charts/microservice-traffic.jsx';
1112
import '../stylesheets/graphs.css';
1213

@@ -55,11 +56,10 @@ const GraphsContainer = (props) => {
5556
vis = new RouteTrace(canvas.current, d3Props);
5657
}
5758
}
58-
59+
5960
return (
6061
<div className="graphsGrid">
6162
<div className='routes'>
62-
<div>{active}</div>
6363
<div ref={canvas} />
6464
</div>
6565
<SpeedChart service={service} />

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@babel/preset-react"
1818
],
1919
"plugins": [
20-
"@babel/plugin-proposal-class-properties"
20+
"@babel/plugin-proposal-class-properties"
2121
]
2222
},
2323
"keywords": [],

0 commit comments

Comments
 (0)