Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

(fix) tbs format mapper & chat axis x & tooltip for 12-hours and 24-hours

kruzhambus2555298ba628
diff --git a/src/pages/Project/View/ViewProject.helpers.tsx b/src/pages/Project/View/ViewProject.helpers.tsx
index 8f2f713d2..e6c1cbc4d 100644
--- a/src/pages/Project/View/ViewProject.helpers.tsx
+++ b/src/pages/Project/View/ViewProject.helpers.tsx
@@ -25,7 +25,7 @@ import _last from 'lodash/last'
import JSZip from 'jszip'
import {
- TimeFormat, chartTypes, tbsFormatMapper, tbsFormatMapper24h,
+ TimeFormat, chartTypes, tbsFormatMapper, tbsFormatMapper24h, tbsFormatMapperTooltip, tbsFormatMapperTooltip24h,
} from 'redux/constants'
import { getTimeFromSeconds, getStringFromTime, sumArrays } from 'utils/generic'
import countries from 'utils/isoCountries'
@@ -199,6 +199,7 @@ const getColumns = (chart: {
const columns: any[] = [
['x', ..._map(chart.x, el => dayjs(el).toDate())],
]
+ console.log(columns)
if (unique) {
columns.push(['unique', ...chart.uniques])
@@ -448,7 +449,7 @@ const getSettings = (
tick: {
fit: true,
rotate: rotateXAxias ? 45 : 0,
- format: timeFormat === TimeFormat['24-hour'] ? (x: string) => d3.timeFormat(tbsFormatMapper24h[timeBucket])(x) : null,
+ format: timeFormat === TimeFormat['24-hour'] ? (x: string) => d3.timeFormat(tbsFormatMapper24h[timeBucket])(x) : (x: string) => d3.timeFormat(tbsFormatMapper[timeBucket])(x),
},
localtime: timeFormat === TimeFormat['24-hour'],
type: 'timeseries',
@@ -465,7 +466,7 @@ const getSettings = (
},
tooltip: {
format: {
- title: (x: string) => d3.timeFormat(tbsFormatMapper[timeBucket])(x),
+ title: timeFormat === TimeFormat['24-hour'] ? (x: string) => d3.timeFormat(tbsFormatMapperTooltip24h[timeBucket])(x) : (x: string) => d3.timeFormat(tbsFormatMapperTooltip[timeBucket])(x),
},
contents: {
template: `
diff --git a/src/redux/constants/index.ts b/src/redux/constants/index.ts
index f27943ff7..254586bd5 100644
--- a/src/redux/constants/index.ts
+++ b/src/redux/constants/index.ts
@@ -91,6 +91,20 @@ export const timeBucketToDays: {
]
export const tbsFormatMapper: IStringObject = {
+ hour: '%I %p',
+ day: '%d %b',
+ week: '%d %b',
+ month: '%b %Y',
+}
+
+export const tbsFormatMapperTooltip: IStringObject = {
+ hour: '%d %b %I %p',
+ day: '%d %b',
+ week: '%d %b',
+ month: '%b %Y',
+}
+
+export const tbsFormatMapperTooltip24h: IStringObject = {
hour: '%d %b %H:%M',
day: '%d %b',
week: '%d %b',
@@ -101,7 +115,7 @@ export const tbsFormatMapper24h: IStringObject = {
hour: '%H:%M',
day: '%d %b',
week: '%d %b',
- month: '%d %b %Y',
+ month: '%b %Y',
}
export const TimeFormat: IStringObject = {