Skip to content

Commit 77a74a6

Browse files
committed
Re-render latency chart
1 parent 5305df5 commit 77a74a6

File tree

4 files changed

+74
-29
lines changed

4 files changed

+74
-29
lines changed

app/charts/latency-chart.jsx

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,46 @@
11
import React, { useContext } from 'react';
22
import { Line } from 'react-chartjs-2';
33
import HealthContext from '../context/DetailsContext';
4+
import Plot from 'react-plotly.js';
45

56
const LatencyChart = (props) => {
6-
const xAxis = [];
7-
const yAxis = [];
87
const healthData = useContext(HealthContext).detailData;
9-
for (let i = 0; i < healthData.length; i++) {
10-
const element = healthData[i];
11-
if (element.currentmicroservice === props.service || element.currentMicroservice === props.service) {
12-
xAxis.push(i);
13-
yAxis.push(element.latency);
8+
const createChart = () => {
9+
const xAxis = [];
10+
const yAxis = [];
11+
for (let i = 0; i < healthData.length; i++) {
12+
const element = healthData[i];
13+
if (element.currentmicroservice === props.service || element.currentMicroservice === props.service) {
14+
xAxis.push(i);
15+
yAxis.push(element.latency);
16+
}
1417
}
15-
}
16-
const chartData = {
17-
datasets: [
18-
{
19-
label: `CPU latency of ${props.service}`,
20-
data: yAxis,
21-
backgroundColor: ['rgb(254, 255, 0)'],
22-
},
23-
],
24-
options: {
25-
xAxisID: 'TBD',
26-
yAxisID: 'TBD',
27-
},
28-
labels: xAxis,
29-
};
30-
return (
31-
<div>
32-
<Line data={chartData} />
33-
</div>
34-
);
18+
19+
return (
20+
<Plot
21+
data = {[{
22+
type: 'scatter',
23+
x: xAxis,
24+
y: yAxis,
25+
mode: 'lines',
26+
rangemode: 'nonnegative',
27+
name: `${props.service} CPU Latency`,
28+
marker: {
29+
color: '#155263',
30+
size: 1
31+
}
32+
}]}
33+
layout = {{
34+
width: 500,
35+
height: 500,
36+
paper_bgcolor: '#fffbe0',
37+
plot_bgcolor: '#fffbe0',
38+
showlegend: true
39+
}}
40+
/>
41+
)};
42+
43+
return <div>{createChart()}</div>;
3544
};
3645

3746
export default LatencyChart;

app/charts/plotly_copy_latency.jsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React, { useContext } from 'react';
2+
import { Line } from 'react-chartjs-2';
3+
import HealthContext from '../context/DetailsContext';
4+
5+
const LatencyChart = (props) => {
6+
const xAxis = [];
7+
const yAxis = [];
8+
const healthData = useContext(HealthContext).detailData;
9+
for (let i = 0; i < healthData.length; i++) {
10+
const element = healthData[i];
11+
if (element.currentmicroservice === props.service || element.currentMicroservice === props.service) {
12+
xAxis.push(i);
13+
yAxis.push(element.latency);
14+
}
15+
}
16+
const chartData = {
17+
datasets: [
18+
{
19+
label: `CPU latency of ${props.service}`,
20+
data: yAxis,
21+
backgroundColor: ['rgb(254, 255, 0)'],
22+
},
23+
],
24+
options: {
25+
xAxisID: 'TBD',
26+
yAxisID: 'TBD',
27+
},
28+
labels: xAxis,
29+
};
30+
return (
31+
<div>
32+
<Line data={chartData} />
33+
</div>
34+
);
35+
};
36+
37+
export default LatencyChart;

app/charts/processes-chart.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ const ProcessesChart = (props) => {
9090
/>
9191
)};
9292

93-
9493
return <div>{createChart()}</div>;
9594
};
9695

user/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"setupRequired":false,"services":[["asdf","MongoDB","mongodb+srv://alon:[email protected]/test?retryWrites=true&w=majority"]],"splash":true}
1+
{"setupRequired":false,"services":[["asdf","MongoDB","mongodb+srv://alon:[email protected]/test?retryWrites=true&w=majority"]],"splash":false}

0 commit comments

Comments
 (0)