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.

fix timeseries chart bug

Steven Teyaa6d9262f174
diff --git a/packages/ui/src/charts/time-series-chart.tsx b/packages/ui/src/charts/time-series-chart.tsx
index 5503c982f8..3999fa9da1 100644
--- a/packages/ui/src/charts/time-series-chart.tsx
+++ b/packages/ui/src/charts/time-series-chart.tsx
@@ -245,11 +245,17 @@ function TimeSeriesChartInner<T extends Datum>({
{tooltipData && (
<TooltipWrapper
key={tooltipData.date.toString()}
- left={(tooltipLeft ?? 0) + margin.left}
+ // Anchor bars at their center so the offset is symmetric when
+ // the tooltip flips to the left near the right edge
+ left={
+ (tooltipLeft ?? 0) +
+ margin.left +
+ ("bandwidth" in xScale ? xScale.bandwidth() / 2 : 0)
+ }
top={(tooltipTop ?? 0) + margin.top}
offsetLeft={
"bandwidth" in xScale
- ? xScale.bandwidth() * (1 + xScale.padding())
+ ? xScale.bandwidth() * (0.5 + xScale.padding())
: 8
}
offsetTop={12}