Format date properly according to the chosen time scale

This commit is contained in:
nymkappa 2021-12-09 22:29:40 +09:00
parent 00352d7e36
commit 2b3463519a
2 changed files with 48 additions and 2 deletions

View File

@ -123,7 +123,30 @@ export class IncomingTransactionsGraphComponent implements OnInit, OnChanges {
fontSize: 11, fontSize: 11,
lineHeight: 12 lineHeight: 12
}, },
data: this.data.labels.map((value: any) => `${formatDate(value, 'M/d', this.locale)}\n${formatDate(value, 'H:mm', this.locale)}`), data: this.data.labels.map((value: any) => {
switch (this.windowPreference) {
case "2h":
return `${formatDate(value, 'h:mm a', this.locale)}`
case "24h":
return `${formatDate(value, 'h a', this.locale)}`
case "1w":
return `${formatDate(value, 'EEE, MMM d', this.locale)}`
case "1m":
return `${formatDate(value, 'EEE, MMM d', this.locale)}`
case "3m":
return `${formatDate(value, 'MMM d', this.locale)}`
case "6m":
return `${formatDate(value, 'MMM d', this.locale)}`
case "1y":
return `${formatDate(value, 'MMM y', this.locale)}`
case "2y":
return `${formatDate(value, 'MMM y', this.locale)}`
case "3y":
return `${formatDate(value, 'MMM y', this.locale)}`
default:
return `${formatDate(value, 'M/d', this.locale)}\n${formatDate(value, 'H:mm', this.locale)}`
}
}),
}, },
yAxis: { yAxis: {
type: 'value', type: 'value',

View File

@ -320,7 +320,30 @@ export class MempoolGraphComponent implements OnInit, OnChanges {
fontSize: 11, fontSize: 11,
lineHeight: 12, lineHeight: 12,
}, },
data: labels.map((value: any) => `${formatDate(value, 'M/d', this.locale)}\n${formatDate(value, 'H:mm', this.locale)}`), data: labels.map((value: any) => {
switch (this.windowPreference) {
case "2h":
return `${formatDate(value, 'h:mm a', this.locale)}`
case "24h":
return `${formatDate(value, 'h a', this.locale)}`
case "1w":
return `${formatDate(value, 'EEE, MMM d', this.locale)}`
case "1m":
return `${formatDate(value, 'EEE, MMM d', this.locale)}`
case "3m":
return `${formatDate(value, 'MMM d', this.locale)}`
case "6m":
return `${formatDate(value, 'MMM d', this.locale)}`
case "1y":
return `${formatDate(value, 'MMM y', this.locale)}`
case "2y":
return `${formatDate(value, 'MMM y', this.locale)}`
case "3y":
return `${formatDate(value, 'MMM y', this.locale)}`
default:
return `${formatDate(value, 'M/d', this.locale)}\n${formatDate(value, 'H:mm', this.locale)}`
}
}),
} }
], ],
yAxis: { yAxis: {