Skip to content

Commit

Permalink
FIX: responsive chart
Browse files Browse the repository at this point in the history
  • Loading branch information
silvareal committed Jan 5, 2023
1 parent 37f5013 commit c3f6aae
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 34 deletions.
9 changes: 9 additions & 0 deletions web/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,13 @@ code {
display: grid;
grid-gap: 10px;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

pre {
margin: 20px; padding: 20px;
color: #aaa; background-color: #222;
white-space: pre; text-shadow: 0 1px 0 #000;
border-radius: 15px; border-bottom: 1px solid #555;
box-shadow: 0 1px 5px rgba(0,0,0,0.4) inset, 0 0 20px rgba(0,0,0,0.2) inset;
font: 16px/24px 'Courier New', Courier, 'Lucida Sans Typewriter', 'Lucida Typewriter', monospace;
}
10 changes: 6 additions & 4 deletions web/src/server/ServerDetailServicesTabPaneCustom.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { ServerServiceNameType } from './ServerType';
import React from "react";
import { ServerServiceNameType } from "./ServerType";

interface ServerDetailServicesTabPanelLoadAvgType {
serverName: ServerServiceNameType;
Expand All @@ -10,7 +10,7 @@ interface ServerDetailServicesTabPanelLoadAvgType {
export default function ServerDetailServicesTabPanelCustom(
props: ServerDetailServicesTabPanelLoadAvgType
) {
const { serverData } = props;
const { serverData } = props;

if (serverData.Error) {
return (
Expand All @@ -23,7 +23,9 @@ export default function ServerDetailServicesTabPanelCustom(
return (
<div>
<h1>{serverData.Message.Data.Command}</h1>
<pre className="text-white bg-black p-4">{serverData.Message?.Data?.Output}</pre>
<pre className="text-white bg-black p-4">
{serverData.Message?.Data?.Output}
</pre>
</div>
);
}
26 changes: 13 additions & 13 deletions web/src/server/ServerDetailServicesTabPanelDisk.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import styled from '@emotion/styled';
import React from "react";
import styled from "@emotion/styled";
import {
BarChart,
Bar,
Expand All @@ -8,13 +8,14 @@ import {
CartesianGrid,
Tooltip,
Legend,
} from 'recharts';
ResponsiveContainer,
} from "recharts";

import {
DiskData,
ServerResponseType,
ServerServiceNameType,
} from './ServerType';
} from "./ServerType";

interface ServerDetailServicesTabPanelDiskType {
serverName: ServerServiceNameType;
Expand All @@ -36,19 +37,18 @@ export default function ServerDetailServicesTabPanelDisk(

return (
<Div>
{
/* <ServicesTabPanel /> */
<BarChart width={900} height={500} data={Data}>
<CartesianGrid strokeDasharray='3 3' />
<XAxis dataKey='FileSystem' />
<ResponsiveContainer width="100%" height={500}>
<BarChart data={Data}>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="FileSystem" />
<YAxis />
<Tooltip />
<Legend />
<Bar dataKey='Available' fill='#8884d8' />
<Bar dataKey='Used' fill='red' />
<Bar dataKey='Size' fill='green' />
<Bar dataKey="Available" fill="#8884d8" />
<Bar dataKey="Used" fill="red" />
<Bar dataKey="Size" fill="green" />
</BarChart>
}
</ResponsiveContainer>
</Div>
);
}
26 changes: 15 additions & 11 deletions web/src/server/ServerDetailServicesTabPanelLoadAvg.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import styled from '@emotion/styled';
import styled from "@emotion/styled";
import {
BarChart,
Bar,
Expand All @@ -8,9 +8,14 @@ import {
CartesianGrid,
Tooltip,
Legend,
} from 'recharts';
ResponsiveContainer,
} from "recharts";

import { LoadingAvgData, ServerResponseType, ServerServiceNameType } from "./ServerType";
import {
LoadingAvgData,
ServerResponseType,
ServerServiceNameType,
} from "./ServerType";

interface ServerDetailServicesTabPanelLoadAvgType {
serverName: ServerServiceNameType;
Expand All @@ -24,7 +29,6 @@ const Div = styled.div`
export default function ServerDetailServicesTabPanelLoadAvg(
props: ServerDetailServicesTabPanelLoadAvgType
) {

const {
serverData: {
Message: { Data },
Expand All @@ -33,18 +37,18 @@ export default function ServerDetailServicesTabPanelLoadAvg(

return (
<Div>
{
<ResponsiveContainer width="100%" height={500}>
<BarChart width={900} height={500} data={[Data]}>
<CartesianGrid strokeDasharray='3 3' />
<XAxis dataKey='Name' />
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="Name" />
<YAxis />
<Tooltip />
<Legend />
<Bar dataKey='Load1M' fill='#8884d8' />
<Bar dataKey='Load5M' fill='red' />
<Bar dataKey='Load15M' fill='green' />
<Bar dataKey="Load1M" fill="#8884d8" />
<Bar dataKey="Load5M" fill="red" />
<Bar dataKey="Load15M" fill="green" />
</BarChart>
}
</ResponsiveContainer>
</Div>
);
}
10 changes: 4 additions & 6 deletions web/src/server/ServerDetailServicesTabPanelMemory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
CartesianGrid,
Tooltip,
Legend,
ResponsiveContainer,
} from "recharts";
import {
MemoryData,
Expand All @@ -34,10 +35,8 @@ export default function ServerDetailServicesTabPanelMemory(
} = props;
return (
<Div>
{
/* <ServicesTabPanel /> */
// <ResponsiveContainer width='100%' height='100%'>
<BarChart width={900} height={500} data={[Data]}>
<ResponsiveContainer width="100%" height={500}>
<BarChart data={[Data]}>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="FileSystem" />
<YAxis />
Expand All @@ -48,8 +47,7 @@ export default function ServerDetailServicesTabPanelMemory(
<Bar dataKey="SwapFree" fill="#bc5090" />
<Bar dataKey="SwapTotal" fill="#ff6361" />
</BarChart>
// </ResponsiveContainer>
}
</ResponsiveContainer>
</Div>
);
}

0 comments on commit c3f6aae

Please sign in to comment.