-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate back-end with Overview Charts and Key Metrics Table (#1557)
Co-authored-by: Trung-Tin Pham <[email protected]>
- Loading branch information
1 parent
ee60e32
commit a3853bd
Showing
32 changed files
with
778 additions
and
156 deletions.
There are no files selected for viewing
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
33 changes: 33 additions & 0 deletions
33
apps/hubble-stats/components/ChartTooltip/ChartTooltip.tsx
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,33 @@ | ||
import { FC } from 'react'; | ||
import { Typography } from '@webb-tools/webb-ui-components'; | ||
|
||
import { ChartTooltipProps } from './types'; | ||
|
||
const ChartTooltip: FC<ChartTooltipProps> = ({ date, info }) => { | ||
return ( | ||
<div className="rounded-lg p-2 bg-[rgba(255,255,255,0.70)] dark:bg-[rgba(31,29,43,0.70)]"> | ||
<Typography variant="body2"> | ||
{new Date(date).toLocaleDateString('en-US', { | ||
month: 'short', | ||
day: 'numeric', | ||
year: 'numeric', | ||
})} | ||
</Typography> | ||
{info.map((item, idx) => ( | ||
<div key={idx} className="flex items-center gap-1"> | ||
<div | ||
className="rounded-full w-2 h-2" | ||
style={{ backgroundColor: item.color }} | ||
/> | ||
<Typography variant="body2"> | ||
{item.label}: {item.valuePrefix ?? ''} | ||
{item.value.toFixed(2)} | ||
{item.valueSuffix ?? ''} | ||
</Typography> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ChartTooltip; |
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 @@ | ||
export { default as ChartTooltip } from './ChartTooltip'; |
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,10 @@ | ||
export interface ChartTooltipProps { | ||
date: Date; | ||
info: Array<{ | ||
color: string; | ||
label: string; | ||
value: number; | ||
valuePrefix?: string; | ||
valueSuffix?: string; | ||
}>; | ||
} |
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 |
---|---|---|
|
@@ -3,4 +3,5 @@ export interface MetricItemProps { | |
value?: number; | ||
changeRate?: number; | ||
prefix?: string; | ||
suffix?: string; | ||
} |
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,77 @@ | ||
'use client'; | ||
|
||
import { FC } from 'react'; | ||
import { ResponsiveContainer, BarChart, XAxis, Tooltip, Bar } from 'recharts'; | ||
|
||
import { ChartTooltip } from '..'; | ||
import { VolumeChartProps } from './types'; | ||
|
||
const VolumeChart: FC<VolumeChartProps> = ({ | ||
data, | ||
setValue, | ||
setDate, | ||
width = '100%', | ||
height = 180, | ||
}) => { | ||
return ( | ||
<ResponsiveContainer width={width} height={height}> | ||
<BarChart | ||
data={data} | ||
onMouseLeave={() => { | ||
setValue && setValue(null); | ||
setDate && setDate(null); | ||
}} | ||
barGap={0} | ||
> | ||
<XAxis | ||
dataKey="date" | ||
tickFormatter={(date) => | ||
new Date(date).toLocaleDateString('en-US', { | ||
day: 'numeric', | ||
}) | ||
} | ||
strokeOpacity={0} | ||
tick={{ | ||
fontSize: '16px', | ||
fill: '#9CA0B0', | ||
fontWeight: 400, | ||
}} | ||
tickMargin={16} | ||
interval="preserveStartEnd" | ||
/> | ||
<Tooltip | ||
content={({ active, payload }) => { | ||
if (active && payload && payload.length) { | ||
setValue && setValue(payload[0].payload['deposit']); | ||
setDate && setDate(payload[0].payload['date']); | ||
return ( | ||
<ChartTooltip | ||
date={payload[0].payload['date']} | ||
info={[ | ||
{ | ||
color: '#624FBE', | ||
label: 'Deposits', | ||
value: payload[0].payload['deposit'], | ||
valueSuffix: ' tTNT', | ||
}, | ||
{ | ||
color: '#B5A9F2', | ||
label: 'Withdrawals', | ||
value: payload[0].payload['withdrawal'], | ||
valueSuffix: ' tTNT', | ||
}, | ||
]} | ||
/> | ||
); | ||
} | ||
return null; | ||
}} | ||
/> | ||
<Bar dataKey="deposit" fill="#624FBE" /> | ||
<Bar dataKey="withdrawal" fill="#B5A9F2" /> | ||
</BarChart> | ||
</ResponsiveContainer> | ||
); | ||
}; | ||
|
||
export default VolumeChart; |
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 @@ | ||
export { default as VolumeChart } from './VolumeChart'; |
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,11 @@ | ||
export type VolumeChartProps = { | ||
data: Array<{ | ||
date: Date; | ||
deposit: number; | ||
withdrawal: number; | ||
}>; | ||
setValue: (value: number | null) => void; | ||
setDate: (date: Date | null) => void; | ||
width?: number | string; | ||
height?: number | string; | ||
}; |
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 |
---|---|---|
@@ -1,9 +1,21 @@ | ||
import vAnchorClient from '@webb-tools/vanchor-client'; | ||
|
||
export const vAnchorAddresses = ['0x4b88368Eb14D7d09f0ca737832cEBfb8F12e3f05']; | ||
|
||
export const allSubgraphUrls = [ | ||
export const LIVE_SUBGRAPH_URLS = [ | ||
vAnchorClient.SubgraphUrl.vAnchorOrbitAthena, | ||
vAnchorClient.SubgraphUrl.vAnchorOrbitHermes, | ||
vAnchorClient.SubgraphUrl.vAnchorOrbitDemeter, | ||
]; | ||
|
||
export const LOCAL_SUBGRAPH_URLS = [ | ||
vAnchorClient.SubgraphUrl.vAnchorAthenaLocal, | ||
vAnchorClient.SubgraphUrl.vAnchorHermesLocal, | ||
vAnchorClient.SubgraphUrl.vAnchorDemeterLocal, | ||
]; | ||
|
||
export const ACTIVE_SUBGRAPH_URLS = process.env.USING_LOCAL_SUBGRAPHS | ||
? LOCAL_SUBGRAPH_URLS | ||
: LIVE_SUBGRAPH_URLS; | ||
|
||
export const VANCHOR_ADDRESSES: string[] = process.env.VANCHOR_ADDRESSES | ||
? JSON.parse(process.env.VANCHOR_ADDRESSES) | ||
: ['0x7aA556dD0AF8bed063444E14A6A9af46C9266973']; |
Oops, something went wrong.