Skip to content

Commit

Permalink
update: display charts with static data #11
Browse files Browse the repository at this point in the history
  • Loading branch information
HammacheAbir committed Apr 30, 2021
1 parent ec0804b commit 2a361eb
Show file tree
Hide file tree
Showing 9 changed files with 469 additions and 26 deletions.
42 changes: 42 additions & 0 deletions src/components/DeviceDetails/FSDetails.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState, useEffect} from 'react';
import { Table ,Dropdown } from '../tailwind-ui';
import FSPlot from './FSPlot'

const FSDetails = (props)=>{

Expand Down Expand Up @@ -72,6 +73,9 @@ const FSDetails = (props)=>{
class="min-w-full table-auto"
Header={() => (
<tr class="bg-primary-900">
<th class="px-4 py-2">
<span class="text-white">Date</span>
</th>
<th class="px-4 py-2">
<span class="text-white">FS min</span>
</th>
Expand All @@ -83,6 +87,9 @@ const FSDetails = (props)=>{
Tr={({ value }) =>
value && value.doc.parameters ? (
<tr class="bg-white border-4 border-gray-200 text-center">
<td class="px-4 py-2">
<span>dd/mm/yy HH:MM:ss</span>
</td>
<td class="px-4 py-2">
<span>{value.doc.parameters.N}</span>
</td>
Expand All @@ -104,6 +111,41 @@ const FSDetails = (props)=>{
}}
/>
</div>
<div className="flex space-x-100 m-4">
<div class="flex-1">
<h2 class="text-2xl ">Variations Chart</h2>
<p class="text-sm text-gray-500">Chart of variations of the device.</p>
</div>
<div className="flex-2 object-right">
<Dropdown
onSelect={function noRefCheck(){}}
options={[
[
{
label: '1 hour',
type: 'option'
},
{
label: '1 day',
type: 'option'
},
{
label: '1 month',
type: 'option'
},
{
label: '1 year',
type: 'option'
}
]
]}
title="Diplay per"
/>
</div>

</div>
<FSPlot/>

</div>
);
}
Expand Down
66 changes: 66 additions & 0 deletions src/components/DeviceDetails/FSPlot.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React from 'react';
import { Axis, LineSeries, Plot, Heading, Legend } from 'react-plot';

const FSPlot = () => {
const data1 = [
{ x: 0, y: 0 },
{ x: 1, y: 2 },
{ x: 2, y: 5 },
{ x: 3, y: 9 },
{ x: 4, y: 16 },
{ x: 5, y: 22 },
{ x: 6, y: 26 },
{ x: 7, y: 28 },
{ x: 10, y: 28 },
];
const data2 = [
{ x: 0, y: 20 },
{ x: 5, y: 20 },
{ x: 5, y: 30 },
{ x: 10, y: 30 },
];

return (
<div className="w-max h-max m-2 p-4 flex justify-center items-center rounded-md bg-white shadow">
<Plot
width={900}
height={400}
margin={{ bottom: 50, left: 55, top: 20, right: 20 }}
seriesViewportStyle={{
stroke: 'black',
strokeWidth: 0.3,
}}
>
<Heading title="FS Details Variations" />

<Axis id="x" position="bottom" label="Time" labelSpace={25} />
<Axis
id="y"
position="left"
label="%"
labelSpace={40}
paddingEnd={0.1}
/>

<LineSeries
data={data1}
xAxis="x"
yAxis="y"
lineStyle={{ stroke: 'red', strokeWidth: 2 }}
label="FS Min"
/>

<LineSeries
data={data2}
xAxis="x"
yAxis="y"
lineStyle={{ stroke: 'green', strokeWidth: 2 }}
label="FS Max"
/>
<Legend position="embedded" bottom="80" left="0"></Legend>
</Plot>
</div>
);
};

export default FSPlot;
49 changes: 41 additions & 8 deletions src/components/DeviceDetails/InOutDetails.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState, useEffect} from 'react';
import { Table,Dropdown } from '../tailwind-ui';
import InOutPlot from './InOutPlot'

const InOutDetails = (props)=>{

Expand Down Expand Up @@ -92,7 +93,9 @@ const InOutDetails = (props)=>{
class="min-w-full table-auto"
Header={() => (
<tr class="bg-primary-900">

<th class="px-4 py-2">
<span class="text-white">Date</span>
</th>
<th class="px-2 py-2">
<span class="text-white">FS Read</span>
</th>
Expand All @@ -105,15 +108,14 @@ const InOutDetails = (props)=>{
<th class="px-2 py-2">
<span class="text-white">Network W</span>
</th>
<th class="px-2 py-2">
<span class="text-white">Load</span>
</th>
</tr>
)}
Tr={({ value }) =>
value && value.doc.parameters ? (
<tr class="bg-white border-4 border-gray-200 text-center">

<td class="px-4 py-2">
<span>dd/mm/yy HH:MM:ss</span>
</td>
<td class="px-4 py-2">
<span>{value.doc.parameters.D}</span>
</td>
Expand All @@ -126,9 +128,6 @@ const InOutDetails = (props)=>{
<td class="px-4 py-2">
<span>{value.doc.parameters.G}</span>
</td>
<td class="px-4 py-2">
<span>{value.doc.parameters.M}</span>
</td>
</tr>
) : null
}
Expand All @@ -144,6 +143,40 @@ const InOutDetails = (props)=>{
}}
/>
</div>
<div className="flex space-x-100 m-4">
<div class="flex-1">
<h2 class="text-2xl ">Variations Chart</h2>
<p class="text-sm text-gray-500">Chart of variations of the device.</p>
</div>
<div className="flex-2 object-right">
<Dropdown
onSelect={function noRefCheck(){}}
options={[
[
{
label: '1 hour',
type: 'option'
},
{
label: '1 day',
type: 'option'
},
{
label: '1 month',
type: 'option'
},
{
label: '1 year',
type: 'option'
}
]
]}
title="Diplay per"
/>
</div>

</div>
<InOutPlot/>
</div>
);
}
Expand Down
99 changes: 99 additions & 0 deletions src/components/DeviceDetails/InOutPlot.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import React from 'react';
import { Axis, LineSeries, Plot, Heading, Legend } from 'react-plot';

const InOutPlot = () => {
const data1 = [
{ x: 0, y: 0 },
{ x: 1, y: 2 },
{ x: 2, y: 5 },
{ x: 3, y: 9 },
{ x: 4, y: 16 },
{ x: 5, y: 22 },
{ x: 6, y: 26 },
{ x: 7, y: 28 },
{ x: 10, y: 28 },
];
const data2 = [
{ x: 0, y: 20 },
{ x: 5, y: 20 },
{ x: 5, y: 30 },
{ x: 10, y: 30 },
];
const data3 = [
{ x: 0, y: 0 },
{ x: 1, y: 17 },
{ x: 2, y: 19 },
{ x: 3, y: 22 },
{ x: 4, y: 40 },
{ x: 5, y: 45 },
{ x: 6, y: 60 },
{ x: 7, y: 78 },
{ x: 10, y: 80 },
];
const data4 = [
{ x: 0, y: 40 },
{ x: 5, y: 40 },
{ x: 5, y: 60 },
{ x: 10, y: 60 },
];

return (
<div className="w-max h-max m-2 p-4 flex justify-center items-center rounded-md bg-white shadow">
<Plot
width={900}
height={400}
margin={{ bottom: 50, left: 55, top: 20, right: 20 }}
seriesViewportStyle={{
stroke: 'black',
strokeWidth: 0.3,
}}
>
<Heading title="FS Details Variations" />

<Axis id="x" position="bottom" label="Time" labelSpace={25} />
<Axis
id="y"
position="left"
label="kb"
labelSpace={40}
paddingEnd={0.1}
/>

<LineSeries
data={data1}
xAxis="x"
yAxis="y"
lineStyle={{ stroke: 'red', strokeWidth: 2 }}
label="FS Read"
/>

<LineSeries
data={data2}
xAxis="x"
yAxis="y"
lineStyle={{ stroke: 'green', strokeWidth: 2 }}
label="FS Write"
/>

<LineSeries
data={data3}
xAxis="x"
yAxis="y"
lineStyle={{ stroke: 'blue', strokeWidth: 2 }}
label="Network Read"
/>

<LineSeries
data={data4}
xAxis="x"
yAxis="y"
lineStyle={{ stroke: 'yellow', strokeWidth: 2 }}
label="Network Write"
/>
<Legend position="embedded" bottom="80" left="0"></Legend>
</Plot>
</div>
);
};

export default InOutPlot;
41 changes: 41 additions & 0 deletions src/components/DeviceDetails/LoadDetails.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState, useEffect} from 'react';
import { Table,Dropdown } from '../tailwind-ui';
import LoadPlot from './LoadPlot'

const LoadDetails = (props)=>{

Expand Down Expand Up @@ -112,6 +113,9 @@ const LoadDetails = (props)=>{
class="min-w-full table-auto"
Header={() => (
<tr class="bg-primary-900">
<th class="px-4 py-2">
<span class="text-white">Date</span>
</th>
<th class="px-2 py-2">
<span class="text-white">Load</span>
</th>
Expand All @@ -135,6 +139,9 @@ const LoadDetails = (props)=>{
Tr={({ value }) =>
value && value.doc.parameters ? (
<tr class="bg-white border-4 border-gray-200 text-center">
<td class="px-4 py-2">
<span>dd/mm/yy HH:MM:ss</span>
</td>
<td class="px-4 py-2">
<span>{value.doc.parameters.H}</span>
</td>
Expand Down Expand Up @@ -168,6 +175,40 @@ const LoadDetails = (props)=>{
}}
/>
</div>
<div className="flex space-x-100 m-4">
<div class="flex-1">
<h2 class="text-2xl ">Variations Chart</h2>
<p class="text-sm text-gray-500">Chart of variations of the device.</p>
</div>
<div className="flex-2 object-right">
<Dropdown
onSelect={function noRefCheck(){}}
options={[
[
{
label: '1 hour',
type: 'option'
},
{
label: '1 day',
type: 'option'
},
{
label: '1 month',
type: 'option'
},
{
label: '1 year',
type: 'option'
}
]
]}
title="Diplay per"
/>
</div>

</div>
<LoadPlot/>
</div>
);
}
Expand Down
Loading

0 comments on commit 2a361eb

Please sign in to comment.