Skip to content

Commit 58a0a7d

Browse files
committed
Re-render temperature chart
1 parent 77a74a6 commit 58a0a7d

File tree

4 files changed

+75
-17
lines changed

4 files changed

+75
-17
lines changed

app/charts/latency-chart.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import Plot from 'react-plotly.js';
55

66
const LatencyChart = (props) => {
77
const healthData = useContext(HealthContext).detailData;
8+
89
const createChart = () => {
910
const xAxis = [];
1011
const yAxis = [];
12+
1113
for (let i = 0; i < healthData.length; i++) {
1214
const element = healthData[i];
1315
if (element.currentmicroservice === props.service || element.currentMicroservice === props.service) {
@@ -27,7 +29,6 @@ const LatencyChart = (props) => {
2729
name: `${props.service} CPU Latency`,
2830
marker: {
2931
color: '#155263',
30-
size: 1
3132
}
3233
}]}
3334
layout = {{
@@ -38,7 +39,8 @@ const LatencyChart = (props) => {
3839
showlegend: true
3940
}}
4041
/>
41-
)};
42+
)
43+
};
4244

4345
return <div>{createChart()}</div>;
4446
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import React, { useContext } from 'react';
2+
import { Line } from 'react-chartjs-2';
3+
import HealthContext from '../context/DetailsContext';
4+
5+
const TemperatureChart = (props) => {
6+
const healthData = useContext(HealthContext).detailData;
7+
8+
const createChart = () => {
9+
const yAxis = [];
10+
const xAxis = [];
11+
for (let i = 0; i < healthData.length; i += 1) {
12+
const element = healthData[i];
13+
// If Mongo
14+
if ((element.currentMicroservice === props.service) && element.cpuTemperature) {
15+
yAxis.push(i);
16+
xAxis.push(element.cpuTemperature);
17+
}
18+
19+
// If SQL
20+
if ((element.currentmicroservice === props.service) && element.cputemperature) {
21+
yAxis.push(i);
22+
xAxis.push(element.cputemperature);
23+
}
24+
}
25+
26+
const chartData = {
27+
datasets: [
28+
{
29+
label: 'Temperature Data',
30+
data: xAxis,
31+
backgroundColor: [
32+
'rgb(2, 210, 249)',
33+
],
34+
},
35+
],
36+
labels: yAxis,
37+
};
38+
return <Line data={chartData} />;
39+
};
40+
41+
return <div>{createChart()}</div>;
42+
};
43+
44+
export default TemperatureChart;

app/charts/processes-chart.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import HealthContext from '../context/DetailsContext';
44

55
const ProcessesChart = (props) => {
66
const healthData = useContext(HealthContext).detailData;
7+
78
const createChart = () => {
89
const communicationLabel = [];
910
const totalProcesses = [];
@@ -88,7 +89,8 @@ const ProcessesChart = (props) => {
8889
legend: {itemsizing: 'constant'}
8990
}}
9091
/>
91-
)};
92+
)
93+
};
9294

9395
return <div>{createChart()}</div>;
9496
};

app/charts/temperature-chart.jsx

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useContext } from 'react';
2-
import { Line } from 'react-chartjs-2';
2+
import Plot from 'react-plotly.js';
33
import HealthContext from '../context/DetailsContext';
44

55
const TemperatureChart = (props) => {
@@ -8,6 +8,7 @@ const TemperatureChart = (props) => {
88
const createChart = () => {
99
const yAxis = [];
1010
const xAxis = [];
11+
1112
for (let i = 0; i < healthData.length; i += 1) {
1213
const element = healthData[i];
1314
// If Mongo
@@ -23,19 +24,28 @@ const TemperatureChart = (props) => {
2324
}
2425
}
2526

26-
const chartData = {
27-
datasets: [
28-
{
29-
label: 'Temperature Data',
30-
data: xAxis,
31-
backgroundColor: [
32-
'rgb(2, 210, 249)',
33-
],
34-
},
35-
],
36-
labels: yAxis,
37-
};
38-
return <Line data={chartData} />;
27+
return (
28+
<Plot
29+
data = {[{
30+
type: 'scatter',
31+
x: yAxis,
32+
y: xAxis,
33+
mode: 'lines',
34+
rangemode: 'nonnegative',
35+
name: 'CPU Temperature',
36+
marker: {
37+
color: '#155200',
38+
}
39+
}]}
40+
layout = {{
41+
width: 500,
42+
height: 500,
43+
paper_bgcolor: '#fffbe0',
44+
plot_bgcolor: '#fffbe0',
45+
showlegend: true
46+
}}
47+
/>
48+
)
3949
};
4050

4151
return <div>{createChart()}</div>;

0 commit comments

Comments
 (0)