diff --git a/components/charts/day-forecast-charts.tsx b/components/charts/day-forecast-charts.tsx
index ff8579e..5bc8e08 100644
--- a/components/charts/day-forecast-charts.tsx
+++ b/components/charts/day-forecast-charts.tsx
@@ -1,6 +1,6 @@
"use client";
-import { Bar, CartesianGrid, ComposedChart, Legend, Line, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
+import { Bar, CartesianGrid, ComposedChart, Line, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
import { Card } from "@/components/ui/card";
import { ChartTooltip } from "@/components/charts/chart-tooltip";
import { CHART_COLORS } from "@/lib/chart-theme";
@@ -12,10 +12,37 @@ import type { HourlyForecast } from "@/types/forecast";
const INITIAL_CHART_DIMENSION = { width: 1, height: 1 };
+interface ChartLegendItem {
+ color: string;
+ label: string;
+ marker: "bar" | "line" | "dashed-line";
+}
+
function formatHour(value: string) {
return value.slice(11, 16);
}
+function ChartLegend({ items }: { items: ChartLegendItem[] }) {
+ return (
+
+ {items.map((item) => (
+
+ {item.marker === "bar" ? (
+
+ ) : (
+
+ )}
+ {item.label}
+
+ ))}
+
+ );
+}
+
export function DayForecastCharts({ hours }: { hours: HourlyForecast[] }) {
const { language, t } = useI18n();
const temperatureUnit = useWeatherStore((state) => state.temperatureUnit);
@@ -27,6 +54,14 @@ export function DayForecastCharts({ hours }: { hours: HourlyForecast[] }) {
precipitationProbability: hour.precipitationProbability,
}));
const temperatureUnitLabel = getTemperatureUnitLabel(temperatureUnit);
+ const temperatureLegendItems: ChartLegendItem[] = [
+ { color: CHART_COLORS.temperature, label: t("forecast.temperature"), marker: "line" },
+ { color: CHART_COLORS.feelsLike, label: t("forecast.apparentTemperature"), marker: "dashed-line" },
+ ];
+ const rainfallLegendItems: ChartLegendItem[] = [
+ { color: CHART_COLORS.rainfall, label: t("forecast.precipitation"), marker: "bar" },
+ { color: CHART_COLORS.probability, label: t("forecast.precipitationProbability"), marker: "line" },
+ ];
return (
@@ -68,7 +103,6 @@ export function DayForecastCharts({ hours }: { hours: HourlyForecast[] }) {
/>
}
/>
-
+
@@ -141,7 +176,6 @@ export function DayForecastCharts({ hours }: { hours: HourlyForecast[] }) {
/>
}
/>
-
+
);