Allow basic chart display w/ non-archive (#1899)

This commit is contained in:
Jaco Greeff 2019-11-16 14:58:04 +01:00 committed by GitHub
parent ebdbadc2d3
commit 971c514a6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,6 +59,10 @@ function extractStake (values: [Hash, Exposure][], divisor: BN): LineData {
}
function extractSplit (values: [Hash, Exposure][], validatorId: string): SplitData | null {
if (!values.length) {
return null;
}
const last = values[values.length - 1][1];
const total = last.total.unwrap();
@ -129,7 +133,7 @@ function Validator ({ className, sessionRewards, t, validatorId }: Props): React
rewardsLabels.push(formatNumber(sessionIndex.subn(1)));
const neg = extractEraSlash(validatorId, slashes);
const pos = index
const pos = index && blockCounts[index - 1]
? reward.mul(blockCounts[index - 1]).div(blockNumber.sub(sessionRewards[index - 1].blockNumber))
: new BN(0);
@ -203,7 +207,7 @@ function Validator ({ className, sessionRewards, t, validatorId }: Props): React
<Column emptyText={t('Loading staker data')}>
{(stakeChart || splitChart) && (
<>
{stakeChart && (
{stakeChart && stakeChart[0].length !== 0 && (
<div className='staking--Chart'>
<h1>{t('elected stake')}</h1>
<Chart.Line