🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Refactor GrowthChart and ServiceUsageChart components to improve date handling and UI consistency. Updated sorting logic to use DateTime for accurate time comparisons and adjusted tooltip date formatting to display in a shorter format. Modified margin settings for better layout.
Bill Yang1eb9ef078a8f
diff --git a/client/src/app/admin/components/shared/GrowthChart.tsx b/client/src/app/admin/components/shared/GrowthChart.tsxindex b85ba268f..b1e9a0857 100644--- a/client/src/app/admin/components/shared/GrowthChart.tsx+++ b/client/src/app/admin/components/shared/GrowthChart.tsx@@ -34,8 +34,9 @@ export function GrowthChart({ data, color = "#3b82f6", title }: GrowthChartProps.map(([date, count]) => ({x: date,y: count,+ currentTime: DateTime.fromISO(date),}))- .sort((a, b) => a.x.localeCompare(b.x));+ .sort((a, b) => a.currentTime.toMillis() - b.currentTime.toMillis());return [{@@ -58,7 +59,7 @@ export function GrowthChart({ data, color = "#3b82f6", title }: GrowthChartProps<ResponsiveLinedata={chartData}theme={nivoTheme}- margin={{ top: 10, right: 10, bottom: 25, left: 50 }}+ margin={{ top: 10, right: 10, bottom: 25, left: 40 }}xScale={{type: "time",format: "%Y-%m-%d",@@ -109,7 +110,7 @@ export function GrowthChart({ data, color = "#3b82f6", title }: GrowthChartPropsreturn (<div className="text-sm bg-neutral-850 p-3 rounded-md min-w-[100px] border border-neutral-750">- <div className="font-medium mb-1">{currentTime.toLocaleString(DateTime.DATE_MED)}</div>+ <div className="font-medium mb-1">{point.data.currentTime.toLocaleString(DateTime.DATE_SHORT)}</div><div className="flex justify-between gap-4 text-sm"><div className="flex items-center gap-2 text-neutral-300"><div className="w-2 h-2 rounded-full" style={{ backgroundColor: point.seriesColor }} />diff --git a/client/src/app/admin/components/shared/ServiceUsageChart.tsx b/client/src/app/admin/components/shared/ServiceUsageChart.tsxindex 426b54b42..315820b07 100644--- a/client/src/app/admin/components/shared/ServiceUsageChart.tsx+++ b/client/src/app/admin/components/shared/ServiceUsageChart.tsx@@ -110,7 +110,7 @@ export function ServiceUsageChart({ startDate, endDate, title }: ServiceUsageCha<ResponsiveLinedata={chartData}theme={nivoTheme}- margin={{ top: 10, right: 10, bottom: 25, left: 50 }}+ margin={{ top: 10, right: 10, bottom: 25, left: 40 }}xScale={{type: "time",format: "%Y-%m-%d",@@ -163,7 +163,7 @@ export function ServiceUsageChart({ startDate, endDate, title }: ServiceUsageChareturn (<div className="text-sm bg-neutral-850 p-3 rounded-md min-w-[100px] border border-neutral-750">- <div className="font-medium mb-1">{currentTime.toLocaleString(DateTime.DATE_MED)}</div>+ <div className="font-medium mb-1">{currentTime.toLocaleString(DateTime.DATE_SHORT)}</div>{slice.points.sort((a: any, b: any) => a.seriesId.localeCompare(b.seriesId)).map((point: any) => {