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.

Add `highlightLast` prop to `XAxis`

Tim Wilson87bb72ace435
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/usage-chart.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/usage-chart.tsx
index fd65a7e27d..d629f5978a 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/usage-chart.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/usage-chart.tsx
@@ -85,7 +85,7 @@ export function UsageChart() {
},
]}
/>
- <XAxis />
+ <XAxis highlightLast={false} />
<YAxis
showGridLines
tickFormat={
diff --git a/apps/web/ui/charts/x-axis.tsx b/apps/web/ui/charts/x-axis.tsx
index 71df0e333f..7a634a992e 100644
--- a/apps/web/ui/charts/x-axis.tsx
+++ b/apps/web/ui/charts/x-axis.tsx
@@ -16,6 +16,11 @@ export type XAxisProps = {
*/
showGridLines?: boolean;
+ /**
+ * Whether to highlight the latest tick label when no other area is hovered
+ */
+ highlightLast?: boolean;
+
/**
* Custom formatting function for tick labels
*/
@@ -25,6 +30,7 @@ export type XAxisProps = {
export default function XAxis({
maxTicks: maxTicksProp,
showGridLines = false,
+ highlightLast = true,
tickFormat = (date) =>
date.toLocaleDateString("en-US", { month: "short", day: "numeric" }),
}: XAxisProps) {
@@ -67,7 +73,11 @@ export default function XAxis({
textAnchor:
idx === 0 ? "start" : idx === length - 1 ? "end" : "middle",
fontSize: 12,
- fill: (tooltipData ? tooltipData.date === date : idx === length - 1)
+ fill: (
+ tooltipData
+ ? tooltipData.date === date
+ : highlightLast && idx === length - 1
+ )
? "#000"
: "#00000066",
})}