-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
406 additions
and
140 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import ReactECharts from 'echarts-for-react'; | ||
import { useTheme } from '@mui/material/styles'; | ||
import { Typography, Stack } from '@mui/material'; | ||
|
||
interface TooltipParams { | ||
dataIndex: number; | ||
} | ||
|
||
function formatHash(number: number) { | ||
const suffixes = ['', 'K', 'M', 'G', 'T', 'P']; | ||
let suffixIndex = 0; | ||
while (number >= 1000 && suffixIndex < suffixes.length - 1) { | ||
number /= 1000; | ||
suffixIndex++; | ||
} | ||
return number.toFixed(1) + ' ' + suffixes[suffixIndex] + 'H'; | ||
} | ||
|
||
const HashRateChartGannt = () => { | ||
const theme = useTheme(); | ||
const chartHeight = 150; | ||
|
||
const data = [ | ||
{ hashRate: 2725148000, blockNo: 8703 }, | ||
{ hashRate: 2425148500, blockNo: 8704 }, | ||
{ hashRate: 2325149000, blockNo: 8705 }, | ||
{ hashRate: 2725149500, blockNo: 8706 }, | ||
{ hashRate: 2625150000, blockNo: 8707 }, | ||
{ hashRate: 2825150500, blockNo: 8708 }, | ||
{ hashRate: 2725151000, blockNo: 8709 }, | ||
{ hashRate: 2325151500, blockNo: 8710 }, | ||
{ hashRate: 2425152000, blockNo: 8711 }, | ||
{ hashRate: 2925152500, blockNo: 8712 }, | ||
{ hashRate: 2925153000, blockNo: 8713 }, | ||
{ hashRate: 3325153500, blockNo: 8714 }, | ||
{ hashRate: 3625154000, blockNo: 8715 }, | ||
{ hashRate: 3225154500, blockNo: 8716 }, | ||
{ hashRate: 3425155000, blockNo: 8717 }, | ||
{ hashRate: 3325155500, blockNo: 8718 }, | ||
{ hashRate: 2725156000, blockNo: 8719 }, | ||
{ hashRate: 3025156500, blockNo: 8720 }, | ||
{ hashRate: 3125157000, blockNo: 8721 }, | ||
]; | ||
|
||
const option = { | ||
height: chartHeight, | ||
tooltip: { | ||
trigger: 'axis', | ||
formatter: (params: TooltipParams[]) => { | ||
const { hashRate, blockNo } = data[params[0].dataIndex]; | ||
return `<strong>${formatHash(hashRate)}</strong> at <br />block <strong>${blockNo}</strong>`; | ||
}, | ||
}, | ||
xAxis: { | ||
type: 'category', | ||
data: data?.map((item) => item.blockNo), | ||
axisLabel: { | ||
show: false, | ||
}, | ||
}, | ||
yAxis: { | ||
type: 'value', | ||
axisLabel: { | ||
formatter: formatHash, | ||
}, | ||
}, | ||
grid: { | ||
left: '0', | ||
right: '0', | ||
bottom: '20', | ||
top: '10', | ||
containLabel: true, | ||
}, | ||
series: [ | ||
{ | ||
name: 'Hash Rate', | ||
type: 'line', | ||
data: data?.map((item) => item.hashRate), | ||
smooth: false, | ||
itemStyle: { | ||
color: '#F3B927', | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
return ( | ||
<Stack direction="column" spacing={0.5}> | ||
<Stack direction="row" justifyContent="space-between"> | ||
<Typography variant="body2">Network Hash Rate</Typography> | ||
<Typography variant="body2"> | ||
<span | ||
style={{ | ||
color: theme.palette.text.primary, | ||
fontFamily: 'PoppinsSemiBold', | ||
}} | ||
> | ||
2M | ||
</span>{' '} | ||
AVG block time | ||
</Typography> | ||
</Stack> | ||
<ReactECharts style={{ height: chartHeight }} option={option} /> | ||
</Stack> | ||
); | ||
}; | ||
|
||
export default HashRateChartGannt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import React from 'react'; | ||
import ReactECharts from 'echarts-for-react'; | ||
import { useTheme } from '@mui/material/styles'; | ||
import { Typography, Stack } from '@mui/material'; | ||
|
||
const MinerUptimeChart: React.FC = () => { | ||
const theme = useTheme(); | ||
const chartHeight = 25; | ||
|
||
const uptime = [ | ||
{ status: 'on', time: '00:00:00' }, | ||
{ status: 'off', time: '01:00:00' }, | ||
{ status: 'off', time: '02:00:00' }, | ||
{ status: 'on', time: '03:00:00' }, | ||
{ status: 'on', time: '04:00:00' }, | ||
{ status: 'off', time: '05:00:00' }, | ||
{ status: 'on', time: '06:00:00' }, | ||
{ status: 'on', time: '07:00:00' }, | ||
{ status: 'on', time: '08:00:00' }, | ||
{ status: 'off', time: '09:00:00' }, | ||
{ status: 'on', time: '10:00:00' }, | ||
{ status: 'off', time: '11:00:00' }, | ||
{ status: 'on', time: '12:00:00' }, | ||
{ status: 'on', time: '13:00:00' }, | ||
{ status: 'on', time: '14:00:00' }, | ||
{ status: 'off', time: '15:00:00' }, | ||
{ status: 'on', time: '16:00:00' }, | ||
{ status: 'off', time: '17:00:00' }, | ||
{ status: 'on', time: '18:00:00' }, | ||
{ status: 'on', time: '19:00:00' }, | ||
{ status: 'off', time: '20:00:00' }, | ||
{ status: 'off', time: '21:00:00' }, | ||
{ status: 'on', time: '22:00:00' }, | ||
{ status: 'off', time: '23:00:00' }, | ||
]; | ||
|
||
const data = uptime.map(({ status }) => ({ | ||
value: 1, | ||
itemStyle: { | ||
color: | ||
status === 'on' | ||
? theme.palette.success.main | ||
: theme.palette.divider, | ||
}, | ||
})); | ||
|
||
const option = { | ||
height: chartHeight, | ||
xAxis: { | ||
type: 'category', | ||
data: uptime.map((_, index) => index + 1), | ||
show: false, | ||
}, | ||
yAxis: { | ||
type: 'value', | ||
min: 0, | ||
max: 1, | ||
show: false, | ||
}, | ||
series: [ | ||
{ | ||
data: data, | ||
type: 'bar', | ||
itemStyle: { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
color: (params: any) => | ||
params.value === 'on' | ||
? theme.palette.success.main | ||
: theme.palette.divider, | ||
borderRadius: 3, | ||
}, | ||
}, | ||
], | ||
grid: { | ||
left: '0', | ||
right: '0', | ||
bottom: '0', | ||
top: '0', | ||
containLabel: false, | ||
}, | ||
tooltip: { | ||
trigger: 'axis', | ||
axisPointer: { | ||
type: 'shadow', | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
formatter: (params: any) => { | ||
const { status, time } = uptime[params[0].dataIndex]; | ||
const color = | ||
status === 'on' | ||
? theme.palette.success.main | ||
: theme.palette.divider; | ||
return `<span style="color: ${color};">●</span> <strong>${status === 'on' ? 'Online' : 'Offline'}</strong> <br />at ${time}`; | ||
}, | ||
}, | ||
}; | ||
|
||
return ( | ||
<Stack direction="column" spacing={0.5}> | ||
<Typography variant="body2">24h Miner Uptime</Typography> | ||
<ReactECharts style={{ height: chartHeight }} option={option} /> | ||
</Stack> | ||
); | ||
}; | ||
|
||
export default MinerUptimeChart; |
Oops, something went wrong.