Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update tooltips

Tim Wilson34020fa81a93
diff --git a/apps/web/ui/analytics/analytics-area-chart.tsx b/apps/web/ui/analytics/analytics-area-chart.tsx
index 999823e2c7..d5035e4b42 100644
--- a/apps/web/ui/analytics/analytics-area-chart.tsx
+++ b/apps/web/ui/analytics/analytics-area-chart.tsx
@@ -89,33 +89,38 @@ export default function ClicksChart({
key={queryString}
data={chartData}
series={series}
+ tooltipClassName="p-0"
tooltipContent={(d) => (
<>
- {show.map((resource) => {
- const s = series.find(({ id }) => id === resource);
- const value = d.values[resource];
- return (
- <div className="flex items-center gap-2">
- {s && (
- <div
- className={cn(
- s.colorClassName,
- "h-2 w-2 rounded-sm bg-current opacity-50 shadow-[inset_0_0_0_1px_#0003]",
- )}
- />
- )}
- <p className="text-gray-600">
- <strong className="font-medium text-gray-800">
- {nFormatter(value, { full: true })}
- </strong>{" "}
- {value === 1 ? resource.slice(0, -1) : resource}
- </p>
- </div>
- );
- })}
- <p className="mt-0.5 text-sm text-gray-500">
+ <p className="border-b border-gray-200 px-4 py-3 text-sm text-gray-900">
{formatDate(d.date)}
</p>
+ <div className="grid grid-cols-2 gap-x-6 gap-y-2 px-4 py-3 text-sm">
+ {show.map((resource) => {
+ const s = series.find(({ id }) => id === resource);
+ const value = d.values[resource];
+ return (
+ <>
+ <div className="flex items-center gap-2">
+ {s && (
+ <div
+ className={cn(
+ s.colorClassName,
+ "h-2 w-2 rounded-sm bg-current opacity-50 shadow-[inset_0_0_0_1px_#0003]",
+ )}
+ />
+ )}
+ <p className="capitalize text-gray-600">
+ {value === 1 ? resource.slice(0, -1) : resource}
+ </p>
+ </div>
+ <p className="text-right font-medium text-gray-900">
+ {nFormatter(value, { full: true })}
+ </p>
+ </>
+ );
+ })}
+ </div>
</>
)}
>
diff --git a/apps/web/ui/charts/time-series-chart.tsx b/apps/web/ui/charts/time-series-chart.tsx
index 27c2486be1..d157bff073 100644
--- a/apps/web/ui/charts/time-series-chart.tsx
+++ b/apps/web/ui/charts/time-series-chart.tsx
@@ -1,3 +1,4 @@
+import { cn } from "@dub/utils";
import { Group } from "@visx/group";
import { ParentSize } from "@visx/responsive";
import { scaleLinear, scaleUtc } from "@visx/scale";
@@ -37,6 +38,7 @@ function TimeSeriesChartInner<T extends Datum>({
data,
series,
tooltipContent = (d) => series[0].valueAccessor(d).toString(),
+ tooltipClassName = "",
margin: marginProp = {
top: 12,
right: 4,
@@ -117,6 +119,7 @@ function TimeSeriesChartInner<T extends Datum>({
margin,
padding,
tooltipContent,
+ tooltipClassName,
leftAxisMargin,
setLeftAxisMargin,
};
@@ -196,7 +199,12 @@ function TimeSeriesChartInner<T extends Datum>({
className="absolute"
unstyled={true}
>
- <div className="pointer-events-none rounded-md border border-gray-200 bg-white px-4 py-2 text-base shadow-md">
+ <div
+ className={cn(
+ "pointer-events-none rounded-lg border border-gray-200 bg-white px-4 py-2 text-base shadow-sm",
+ tooltipClassName,
+ )}
+ >
{tooltipContent?.(tooltipData) ??
series[0].valueAccessor(tooltipData)}
</div>
diff --git a/apps/web/ui/charts/types.ts b/apps/web/ui/charts/types.ts
index 9b75e24cba..23c5e7de4e 100644
--- a/apps/web/ui/charts/types.ts
+++ b/apps/web/ui/charts/types.ts
@@ -31,6 +31,7 @@ type ChartRequiredProps<T extends Datum = any> = {
type ChartOptionalProps<T extends Datum = any> = {
tooltipContent?: (datum: TimeSeriesDatum<T>) => ReactElement | string;
+ tooltipClassName?: string;
/**
* Absolute pixel values for margins around the chart area.