On mobile, show power of ten difficulty instead of full number
This commit is contained in:
parent
f45103e7e3
commit
1630ff717e
@ -43,7 +43,8 @@
|
|||||||
<tr *ngFor="let diffChange of diffChanges.data">
|
<tr *ngFor="let diffChange of diffChanges.data">
|
||||||
<td><a [routerLink]="['/block' | relativeUrl, diffChange.height]">{{ diffChange.height }}</a></td>
|
<td><a [routerLink]="['/block' | relativeUrl, diffChange.height]">{{ diffChange.height }}</a></td>
|
||||||
<td>‎{{ diffChange.timestamp * 1000 | date:'yyyy-MM-dd HH:mm' }}</td>
|
<td>‎{{ diffChange.timestamp * 1000 | date:'yyyy-MM-dd HH:mm' }}</td>
|
||||||
<td>{{ formatNumber(diffChange.difficulty, locale, '1.2-2') }}</td>
|
<td class="d-none d-md-block">{{ formatNumber(diffChange.difficulty, locale, '1.2-2') }}</td>
|
||||||
|
<td class="d-block d-md-none">{{ diffChange.difficultyShorten }}</td>
|
||||||
<td [style]="diffChange.change >= 0 ? 'color: #42B747' : 'color: #B74242'">{{ formatNumber(diffChange.change, locale, '1.2-2') }}%</td>
|
<td [style]="diffChange.change >= 0 ? 'color: #42B747' : 'color: #B74242'">{{ formatNumber(diffChange.change, locale, '1.2-2') }}%</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -44,6 +44,13 @@ export class DifficultyChartComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
const powerOfTen = {
|
||||||
|
terra: Math.pow(10, 12),
|
||||||
|
giga: Math.pow(10, 9),
|
||||||
|
mega: Math.pow(10, 6),
|
||||||
|
kilo: Math.pow(10, 3),
|
||||||
|
}
|
||||||
|
|
||||||
this.difficultyObservable$ = this.radioGroupForm.get('dateSpan').valueChanges
|
this.difficultyObservable$ = this.radioGroupForm.get('dateSpan').valueChanges
|
||||||
.pipe(
|
.pipe(
|
||||||
startWith('1y'),
|
startWith('1y'),
|
||||||
@ -62,8 +69,20 @@ export class DifficultyChartComponent implements OnInit {
|
|||||||
const tableData = [];
|
const tableData = [];
|
||||||
for (let i = 0; i < data.adjustments.length - 1; ++i) {
|
for (let i = 0; i < data.adjustments.length - 1; ++i) {
|
||||||
const change = (data.adjustments[i].difficulty / data.adjustments[i + 1].difficulty - 1) * 100;
|
const change = (data.adjustments[i].difficulty / data.adjustments[i + 1].difficulty - 1) * 100;
|
||||||
|
let selectedPowerOfTen = { divider: powerOfTen.terra, unit: 'T' };
|
||||||
|
if (data.adjustments[i].difficulty < powerOfTen.mega) {
|
||||||
|
selectedPowerOfTen = { divider: 1, unit: '' }; // no scaling
|
||||||
|
} else if (data.adjustments[i].difficulty < powerOfTen.giga) {
|
||||||
|
selectedPowerOfTen = { divider: powerOfTen.mega, unit: 'M' };
|
||||||
|
} else if (data.adjustments[i].difficulty < powerOfTen.terra) {
|
||||||
|
selectedPowerOfTen = { divider: powerOfTen.giga, unit: 'G' };
|
||||||
|
}
|
||||||
|
|
||||||
tableData.push(Object.assign(data.adjustments[i], {
|
tableData.push(Object.assign(data.adjustments[i], {
|
||||||
change: change
|
change: change,
|
||||||
|
difficultyShorten: formatNumber(
|
||||||
|
data.adjustments[i].difficulty / selectedPowerOfTen.divider,
|
||||||
|
this.locale, '1.2-2') + selectedPowerOfTen.unit
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user