🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Refactor Chart and PerformanceChart components for improved UI consistency and tooltip formatting. Updated styles for better visual alignment and adjusted tooltip value display. Removed unused formatting function in PerformanceChart for cleaner code.
Bill Yang8fd72a7258e6
diff --git a/client/src/app/[site]/main/components/MainSection/Chart.tsx b/client/src/app/[site]/main/components/MainSection/Chart.tsxindex 3da127aa7..237e5fc0c 100644--- a/client/src/app/[site]/main/components/MainSection/Chart.tsx+++ b/client/src/app/[site]/main/components/MainSection/Chart.tsx@@ -321,10 +321,10 @@ export function Chart({const diffPercentage = previousY ? (diff / previousY) * 100 : null;return (- <div className="text-sm bg-neutral-850 p-2 rounded-md border border-neutral-750">+ <div className="text-sm bg-neutral-850 rounded-lg border border-neutral-750">{diffPercentage !== null && (<div- className="text-lg font-medium"+ className="text-base font-medium px-2 pt-1.5 pb-1"style={{color: diffPercentage > 0 ? "hsl(var(--green-400))" : "hsl(var(--red-400))",}}@@ -333,17 +333,26 @@ export function Chart({{diffPercentage.toFixed(2)}%</div>)}+ <div className="w-full h-[1px] bg-neutral-750"></div>- <div className="flex justify-between text-sm w-40">- <div>{formatChartDateTime(currentTime, bucket)}</div>- <div>{formatTooltipValue(currentY, selectedStat)}</div>- </div>- {previousTime && (- <div className="flex justify-between text-sm text-muted-foreground">- <div>{formatChartDateTime(previousTime, bucket)}</div>- <div>{formatTooltipValue(previousY, selectedStat)}</div>+ <div className="m-2">+ <div className="flex justify-between text-sm w-40">+ <div className="flex items-center gap-2">+ <div className="w-1 h-3 rounded-[3px] bg-dataviz" />+ {formatChartDateTime(currentTime, bucket)}+ </div>+ <div>{formatTooltipValue(currentY, selectedStat)}</div></div>- )}+ {previousTime && (+ <div className="flex justify-between text-sm text-muted-foreground">+ <div className="flex items-center gap-2">+ <div className="w-1 h-3 rounded-[3px] bg-neutral-600" />+ {formatChartDateTime(previousTime, bucket)}+ </div>+ <div>{formatTooltipValue(previousY, selectedStat)}</div>+ </div>+ )}+ </div></div>);}}diff --git a/client/src/app/[site]/performance/components/PerformanceChart.tsx b/client/src/app/[site]/performance/components/PerformanceChart.tsxindex 1e9e2bbd7..9c9add317 100644--- a/client/src/app/[site]/performance/components/PerformanceChart.tsx+++ b/client/src/app/[site]/performance/components/PerformanceChart.tsx@@ -138,10 +138,6 @@ export function PerformanceChart() {return dt.toFormat(hour12 ? "MMM d" : "dd MMM");};- const formatTooltipValue = (value: number) => {- return `${formatMetricValue(selectedPerformanceMetric, value)}${getMetricUnit(selectedPerformanceMetric, value)}`;- };-// Get performance thresholds for the current metricconst thresholds = getPerformanceThresholds(selectedPerformanceMetric);@@ -298,19 +294,23 @@ export function PerformanceChart() {const currentTime = DateTime.fromJSDate(new Date(slice.points[0].data.x));return (- <div className="text-sm bg-neutral-850 p-3 rounded-md min-w-[150px] border border-neutral-750">+ <div className="text-sm bg-neutral-850 p-3 rounded-lg min-w-[150px] border border-neutral-750">{formatChartDateTime(currentTime, bucket)}<div className="space-y-2 mt-2">{slice.points.map((point: any) => {return (<div key={point.seriesId} className="flex justify-between items-center"><div className="flex items-center gap-2">- <div className="w-3 h-3 rounded-full" style={{ backgroundColor: point.seriesColor }} />- <span className="text-neutral-200 font-medium">{point.seriesId}</span>+ <div className="w-1 h-3 rounded-[3px]" style={{ backgroundColor: point.seriesColor }} />+ <span className="text-neutral-200">{point.seriesId}</span></div>- <span className="text-white">- {point.serieId}- {formatTooltipValue(Number(point.data.yFormatted))}+ <span>+ <span className="text-white">+ {formatMetricValue(selectedPerformanceMetric, Number(point.data.yFormatted))}+ </span>+ <span className="text-neutral-300">+ {getMetricUnit(selectedPerformanceMetric, Number(point.data.yFormatted))}+ </span></span></div>);diff --git a/client/src/lib/dateTimeUtils.ts b/client/src/lib/dateTimeUtils.tsindex 3effad078..b9db368a1 100644--- a/client/src/lib/dateTimeUtils.ts+++ b/client/src/lib/dateTimeUtils.ts@@ -168,7 +168,6 @@ export const formatChartDateTime = (dt: DateTime, bucket: TimeBucket) => {if (bucket === "day") {options.minute = undefined;options.hour = undefined;- options.month = "long";options.weekday = "short";}if (bucket === "fifteen_minutes" || bucket === "ten_minutes" || bucket === "five_minutes" || bucket === "minute") {