Fix tooltip label, retention report for mysql, pass minDate into eventsChart

This commit is contained in:
Francis Cao 2024-08-27 16:02:43 -07:00
parent a5e2242486
commit ab050e51c5
4 changed files with 14 additions and 13 deletions

View file

@ -64,7 +64,7 @@ export function RetentionTable({ days = DAYS }) {
key={day} key={day}
className={classNames(styles.cell, { [styles.empty]: !percentage })} className={classNames(styles.cell, { [styles.empty]: !percentage })}
> >
{percentage ? `${percentage.toFixed(2)}%` : ''} {percentage ? `${Number(percentage).toFixed(2)}%` : ''}
</div> </div>
); );
})} })}

View file

@ -1,9 +1,8 @@
import { useMemo } from 'react';
import { useTheme } from 'components/hooks';
import Chart, { ChartProps } from 'components/charts/Chart';
import { renderNumberLabels } from 'lib/charts';
import { useState } from 'react';
import BarChartTooltip from 'components/charts/BarChartTooltip'; import BarChartTooltip from 'components/charts/BarChartTooltip';
import Chart, { ChartProps } from 'components/charts/Chart';
import { useTheme } from 'components/hooks';
import { renderNumberLabels } from 'lib/charts';
import { useMemo, useState } from 'react';
export interface BarChartProps extends ChartProps { export interface BarChartProps extends ChartProps {
unit: string; unit: string;
@ -36,7 +35,7 @@ export function BarChart(props: BarChartProps) {
x: { x: {
type: XAxisType, type: XAxisType,
stacked: true, stacked: true,
min: unit === 'year' ? '' : minDate, min: minDate && new Date(minDate).getSeconds() === 0 ? minDate : '',
max: maxDate, max: maxDate,
time: { time: {
unit, unit,

View file

@ -47,6 +47,8 @@ export function EventsChart({ websiteId, className }: EventsChartProps) {
return ( return (
<BarChart <BarChart
minDate={startDate.toISOString()}
maxDate={endDate.toISOString()}
className={className} className={className}
data={chartData} data={chartData}
unit={unit} unit={unit}

View file

@ -14,17 +14,17 @@ const log = debug('umami:prisma');
const MYSQL_DATE_FORMATS = { const MYSQL_DATE_FORMATS = {
minute: '%Y-%m-%dT%H:%i:00', minute: '%Y-%m-%dT%H:%i:00',
hour: '%Y-%m-%d %H:00:00', hour: '%Y-%m-%d %H:00:00',
day: '%Y-%m-%d', day: '%Y-%m-%d 00:00:00',
month: '%Y-%m-01', month: '%Y-%m-01 00:00:00',
year: '%Y-01-01', year: '%Y-01-01 00:00:00',
}; };
const POSTGRESQL_DATE_FORMATS = { const POSTGRESQL_DATE_FORMATS = {
minute: 'YYYY-MM-DD HH24:MI:00', minute: 'YYYY-MM-DD HH24:MI:00',
hour: 'YYYY-MM-DD HH24:00:00', hour: 'YYYY-MM-DD HH24:00:00',
day: 'YYYY-MM-DD', day: 'YYYY-MM-DD HH24:00:00',
month: 'YYYY-MM-01', month: 'YYYY-MM-01 HH24:00:00',
year: 'YYYY-01-01', year: 'YYYY-01-01 HH24:00:00',
}; };
function getAddIntervalQuery(field: string, interval: string): string { function getAddIntervalQuery(field: string, interval: string): string {