Skip to content

Commit 56fc2a6

Browse files
committed
Re-render all charts to friendly UI
1 parent 2a07ebe commit 56fc2a6

File tree

5 files changed

+137
-35
lines changed

5 files changed

+137
-35
lines changed

app/charts/latency-chart.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ const LatencyChart = (props) => {
4040
orientation: 'h',
4141
xanchor: 'center',
4242
x: .5
43+
},
44+
xaxis: {
45+
tickmode: 'linear',
46+
tick0: 0,
47+
dtick: 2000
4348
}
4449
}}
4550
/>

app/charts/memory-chart.jsx

Lines changed: 55 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useContext } from 'react';
2-
import { Bar } from 'react-chartjs-2';
32
import HealthContext from '../context/DetailsContext';
3+
import Plot from 'react-plotly.js';
44

55
const MemoryChart = (props) => {
66
const healthData = useContext(HealthContext).detailData;
@@ -31,37 +31,60 @@ const MemoryChart = (props) => {
3131
}
3232
}
3333

34-
const chartData = {
35-
datasets: [
36-
{
37-
label: 'Free Memory',
38-
backgroundColor: 'rgb(2, 210, 249)',
39-
data: free,
40-
// showLine: true,
41-
},
42-
{
43-
label: 'Used Memory',
44-
backgroundColor: 'rgb(239, 91, 145)',
45-
data: used,
46-
// showLine: true,
47-
},
48-
{
49-
label: 'Active Memory',
50-
backgroundColor: 'rgb(182, 219, 26)',
51-
data: active,
52-
// showLine: true,
53-
},
54-
{
55-
label: 'Total Memory',
56-
backgroundColor: 'rgb(252, 170, 52)',
57-
data: total,
58-
// showLine: true,
59-
},
60-
],
61-
labels: xAxis,
62-
};
63-
64-
return <Bar data={chartData} />;
34+
return (
35+
<Plot
36+
data = {[
37+
{
38+
type: 'scatter',
39+
fill: 'tozeroy',
40+
fillcolor: 'rgb(14, 49, 80)',
41+
mode: 'none',
42+
x: {autorange: true},
43+
y: free,
44+
name: 'Free Memory',
45+
rangemode: 'nonnegative'
46+
},
47+
{
48+
type: 'scatter',
49+
fill: 'tozeroy',
50+
fillcolor: 'rgba(255, 64, 87, .3)',
51+
mode: 'none',
52+
x: {autorange: true},
53+
y: used,
54+
name: 'Used Memory',
55+
rangemode: 'nonnegative'
56+
},
57+
{
58+
type: 'scatter',
59+
fill: 'tozeroy',
60+
fillcolor: 'rgba(144, 0, 72, .4)',
61+
mode: 'none',
62+
x: {autorange: true},
63+
y: active,
64+
name: 'Active Memory',
65+
rangemode: 'nonnegative'
66+
},
67+
{label: xAxis},
68+
]}
69+
layout = {{
70+
width: 500,
71+
height: 500,
72+
paper_bgcolor: '#fffbe0',
73+
plot_bgcolor: '#fffbe0',
74+
legend: {
75+
itemsizing: 'constant',
76+
orientation: 'h',
77+
xanchor: 'center',
78+
x: .5
79+
},
80+
xaxis: {
81+
tickmode: 'linear',
82+
tick0: 0,
83+
dtick: 500,
84+
},
85+
}}
86+
/>
87+
)
6588
};
6689

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

app/charts/plotly_copy_memory.jsx

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import React, { useContext } from 'react';
2+
import { Bar } from 'react-chartjs-2';
3+
import HealthContext from '../context/DetailsContext';
4+
5+
const MemoryChart = (props) => {
6+
const healthData = useContext(HealthContext).detailData;
7+
8+
const createChart = () => {
9+
const xAxis = [];
10+
const free = [];
11+
const used = [];
12+
const active = [];
13+
const total = [];
14+
15+
for (let i = 0; i < healthData.length; i += 1) {
16+
xAxis.push(i);
17+
// If Mongo
18+
if (healthData[i].currentMicroservice === props.service) {
19+
free.push(healthData[i].freeMemory);
20+
active.push(healthData[i].activeMemory);
21+
used.push(healthData[i].usedMemory);
22+
total.push(healthData[i].totalMemory);
23+
}
24+
25+
// If SQL
26+
if (healthData[i].currentmicroservice === props.service) {
27+
free.push(healthData[i].freememory);
28+
active.push(healthData[i].activememory);
29+
used.push(healthData[i].usedmemory);
30+
total.push(healthData[i].totalmemory);
31+
}
32+
}
33+
34+
const chartData = {
35+
datasets: [
36+
{
37+
label: 'Free Memory',
38+
backgroundColor: 'rgb(2, 210, 249)',
39+
data: free,
40+
// showLine: true,
41+
},
42+
{
43+
label: 'Used Memory',
44+
backgroundColor: 'rgb(239, 91, 145)',
45+
data: used,
46+
// showLine: true,
47+
},
48+
{
49+
label: 'Active Memory',
50+
backgroundColor: 'rgb(182, 219, 26)',
51+
data: active,
52+
// showLine: true,
53+
},
54+
{
55+
label: 'Total Memory',
56+
backgroundColor: 'rgb(252, 170, 52)',
57+
data: total,
58+
// showLine: true,
59+
},
60+
],
61+
labels: xAxis,
62+
};
63+
64+
return <Bar data={chartData} />;
65+
};
66+
67+
return <div>{createChart()}</div>;
68+
};
69+
70+
export default MemoryChart;

app/charts/processes-chart.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const ProcessesChart = (props) => {
7979
color: '#ff165d',
8080
size: 3
8181
}},
82-
{labels: communicationLabel},
82+
{label: communicationLabel},
8383
]}
8484
layout = {{
8585
width: 500,

app/charts/temperature-chart.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ const TemperatureChart = (props) => {
2929
data = {[{
3030
type: 'scatter',
3131
fill: 'tozeroy',
32-
fillcolor: 'rgba(240, 138, 93, .5)',
33-
line: {shape: 'spline', smoothing: 1.3},
32+
fillcolor: 'rgba(29, 39, 134, .5)',
3433
mode: 'none',
3534
x: yAxis,
3635
y: xAxis,
@@ -48,6 +47,11 @@ const TemperatureChart = (props) => {
4847
orientation: 'h',
4948
xanchor: 'center',
5049
x: .5
50+
},
51+
xaxis: {
52+
tickmode: 'linear',
53+
tick0: 0,
54+
dtick: 2000
5155
}
5256
}
5357
}

0 commit comments

Comments
 (0)