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 bug with one chart date X

kruzhambusd6aa42ee6014
diff --git a/src/pages/Project/View/ViewProject.jsx b/src/pages/Project/View/ViewProject.jsx
index 212732928..21741629b 100644
--- a/src/pages/Project/View/ViewProject.jsx
+++ b/src/pages/Project/View/ViewProject.jsx
@@ -60,6 +60,28 @@ countries.registerLocale(countriesZh)
countries.registerLocale(countriesSv)
const getColumns = (chart, showTotal, t) => {
+
+ if (chart.x.length === 1 && chart.uniques.length === 1 && chart.visits.length === 1) {
+ // eslint-disable-next-line no-extend-native
+ Date.prototype.addHours= function(h){
+ this.setHours(this.getHours()+h);
+ return this;
+ }
+
+ if (showTotal) {
+ return [
+ ['x', ..._map(chart.x, el => dayjs(el).toDate()), dayjs(new Date(chart.x[0]).addHours(1)).toDate()],
+ [t('project.unique'), ...chart.uniques, ...chart.uniques],
+ [t('project.total'), ...chart.visits, ...chart.visits ],
+ ]
+ }
+
+ return [
+ ['x', ..._map(chart.x, el => dayjs(el).toDate()), dayjs(new Date(chart.x[0]).addHours(1)).toDate()],
+ [t('project.unique'), ...chart.uniques, ...chart.uniques]
+ ]
+ }
+
if (showTotal) {
return [
['x', ..._map(chart.x, el => dayjs(el).toDate())],