mirror of
https://github.com/plausible/analytics.git
synced 2024-11-23 11:12:15 +03:00
Add weekday to the visitor graph (#386)
* Add weekdays to the visitor graph Abbreviate both weekday and month in order to keep horizontal spacing roughly the same as it's been. Closes #175. * Add note to CHANGELOG
This commit is contained in:
parent
ff515c641d
commit
73375b8289
@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Ability to add event metadata plausible/analytics#381
|
- Ability to add event metadata plausible/analytics#381
|
||||||
|
- Display weekday on the visitor graph plausible/analytics#175
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Use alpine as base image to decrease Docker image size plausible/analytics#353
|
- Use alpine as base image to decrease Docker image size plausible/analytics#353
|
||||||
|
@ -53,6 +53,14 @@ const MONTHS = [
|
|||||||
"November", "December"
|
"November", "December"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const MONTHS_ABBREV = [
|
||||||
|
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||||
|
]
|
||||||
|
|
||||||
|
const DAYS_ABBREV = [
|
||||||
|
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
|
||||||
|
]
|
||||||
|
|
||||||
function dateFormatter(interval, longForm) {
|
function dateFormatter(interval, longForm) {
|
||||||
return function(isoDate) {
|
return function(isoDate) {
|
||||||
let date = new Date(isoDate)
|
let date = new Date(isoDate)
|
||||||
@ -60,7 +68,10 @@ function dateFormatter(interval, longForm) {
|
|||||||
if (interval === 'month') {
|
if (interval === 'month') {
|
||||||
return MONTHS[date.getUTCMonth()];
|
return MONTHS[date.getUTCMonth()];
|
||||||
} else if (interval === 'date') {
|
} else if (interval === 'date') {
|
||||||
return date.getUTCDate() + ' ' + MONTHS[date.getUTCMonth()];
|
var day = DAYS_ABBREV[date.getUTCDay()];
|
||||||
|
var date_ = date.getUTCDate();
|
||||||
|
var month = MONTHS_ABBREV[date.getUTCMonth()];
|
||||||
|
return day + ', ' + date_ + ' ' + month;
|
||||||
} else if (interval === 'hour') {
|
} else if (interval === 'hour') {
|
||||||
const parts = isoDate.split(/[^0-9]/);
|
const parts = isoDate.split(/[^0-9]/);
|
||||||
date = new Date(parts[0],parts[1]-1,parts[2],parts[3],parts[4],parts[5])
|
date = new Date(parts[0],parts[1]-1,parts[2],parts[3],parts[4],parts[5])
|
||||||
|
Loading…
Reference in New Issue
Block a user