diff --git a/apps/dashboard/src/components/report/chart/ReportChartTooltip.tsx b/apps/dashboard/src/components/report/chart/ReportChartTooltip.tsx
index 7fe3554c..fc0b31b9 100644
--- a/apps/dashboard/src/components/report/chart/ReportChartTooltip.tsx
+++ b/apps/dashboard/src/components/report/chart/ReportChartTooltip.tsx
@@ -22,7 +22,6 @@ export function ReportChartTooltip({
payload,
}: ReportLineChartTooltipProps) {
const { unit, interval } = useChartContext();
- const getLabel = useMappings();
const formatDate = useFormatDateInterval(interval);
const number = useNumber();
if (!active || !payload) {
diff --git a/apps/dashboard/src/components/report/chart/ReportLineChart.tsx b/apps/dashboard/src/components/report/chart/ReportLineChart.tsx
index 5c48e49d..b83d79ea 100644
--- a/apps/dashboard/src/components/report/chart/ReportLineChart.tsx
+++ b/apps/dashboard/src/components/report/chart/ReportLineChart.tsx
@@ -217,7 +217,7 @@ export function ReportLineChart({ data }: ReportLineChartProps) {
)}
{isAreaStyle && (
>[number];
export async function getChartSeries(input: IChartInputWithDates) {
const series = (
await Promise.all(
@@ -501,6 +502,9 @@ export async function getChartSeries(input: IChartInputWithDates) {
}
export async function getChart(input: IChartInput) {
+ const includeEventName =
+ uniq(pluck('name', input.events)).length !==
+ pluck('name', input.events).length;
const currentPeriod = getChartStartEndDate(input);
const previousPeriod = getChartPrevStartEndDate({
range: input.range,
@@ -518,6 +522,8 @@ export async function getChart(input: IChartInput) {
);
}
+ const getSerieId = (serie: IGetChartSerie) =>
+ [slug(serie.name.join('-')), serie.event.id].filter(Boolean).join('-');
const result = await Promise.all(promises);
const series = result[0]!;
const previousSeries = result[1];
@@ -526,7 +532,7 @@ export async function getChart(input: IChartInput) {
const final: FinalChart = {
series: series.map((serie) => {
const previousSerie = previousSeries?.find(
- (item) => item.name.join('-') === serie.name.join('-')
+ (prevSerie) => getSerieId(prevSerie) === getSerieId(serie)
);
const metrics = {
sum: sum(serie.data.map((item) => item.count)),
@@ -534,14 +540,20 @@ export async function getChart(input: IChartInput) {
min: min(serie.data.map((item) => item.count)),
max: max(serie.data.map((item) => item.count)),
};
+ const event = {
+ id: serie.event.id,
+ name: serie.event.displayName || serie.event.name,
+ };
return {
- id: slug(serie.name.join('-')),
- names: serie.name,
- event: {
- id: serie.event.id!,
- name: serie.event.displayName ?? serie.event.name,
- },
+ id: getSerieId(serie),
+ names: includeEventName
+ ? [
+ `(${event.id || event.name}) ${serie.name[0]}`,
+ ...serie.name.slice(1),
+ ]
+ : serie.name,
+ event,
metrics: {
...metrics,
...(input.previous
diff --git a/packages/trpc/src/routers/report.ts b/packages/trpc/src/routers/report.ts
index f498594f..cc94419b 100644
--- a/packages/trpc/src/routers/report.ts
+++ b/packages/trpc/src/routers/report.ts
@@ -31,6 +31,7 @@ export const reportRouter = createTRPCRouter({
lineType: report.lineType,
range: report.range === 'custom' ? '30d' : report.range,
formula: report.formula,
+ previous: report.previous ?? false,
},
});
}),
@@ -55,6 +56,7 @@ export const reportRouter = createTRPCRouter({
lineType: report.lineType,
range: report.range === 'custom' ? '30d' : report.range,
formula: report.formula,
+ previous: report.previous ?? false,
},
});
}),
diff --git a/packages/validation/src/types.validation.ts b/packages/validation/src/types.validation.ts
index 0e13dafe..c5236e57 100644
--- a/packages/validation/src/types.validation.ts
+++ b/packages/validation/src/types.validation.ts
@@ -67,7 +67,7 @@ export type IChartSerie = {
id: string;
names: string[];
event: {
- id: string;
+ id?: string;
name: string;
};
metrics: Metrics;