Skip to content

Commit

Permalink
Fix chart y-axis
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamedmansour committed Jun 28, 2021
1 parent 16ec086 commit 98e19e9
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/components/BaseFeeChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,33 @@ export const BaseFeeChart = forwardRef<BaseFeeChartProps, 'div'>((props: BaseFee

useEffect(() => {
const newData = []

for (let i = props.data.length-1; i >= 0; i--) {
const block = props.data[i]
newData.push({
const chartData: {[key: string]: any} = {
index: i,
block: block.number,
burned: utils.formatUnits(block.burned, 'wei'),
burnedFormatted: autoFormatBigNumberToString(block.burned),
basefee: utils.formatUnits(block.basefee, 'wei'),
basefeeFormatted: autoFormatBigNumberToString(block.basefee),
transactions: block.transactions.length
})
}

if (chartType === 'burned') {
chartData['burned'] = parseFloat(utils.formatUnits(block.burned, 'ether'))
}

if (chartType === 'basefee') {
chartData.basefee = parseInt(utils.formatUnits(block.basefee, 'gwei'))
}

if (chartType === 'transactions') {
chartData.transactions = block.transactions.length
}

newData.push(chartData)
}

setData(newData)
}, [props.data])
}, [chartType, props.data])

const group = getRootProps()
const isMobileLayout = window.innerWidth < 500
Expand All @@ -109,7 +122,7 @@ export const BaseFeeChart = forwardRef<BaseFeeChartProps, 'div'>((props: BaseFee

<ResponsiveContainer width="100%" height="100%" minHeight="400px">
<LineChart data={data}
margin={isMobileLayout ? {} : { bottom: 20, right: 50, top: 50, left: 50}}>
margin={isMobileLayout ? {} : { bottom: 20, right: 50, top: 50, left: 10}}>
{!isMobileLayout && <YAxis domain={['auto', 'auto']} /> }
{!isMobileLayout && <XAxis dataKey="block" angle={30} dx={20} dy={10} /> }
<Tooltip content={<CustomTooltip />}/>
Expand Down

0 comments on commit 98e19e9

Please sign in to comment.