diff --git a/components/analytics/PredictionsChart.tsx b/components/analytics/PredictionsChart.tsx index 7949323..38ea22a 100644 --- a/components/analytics/PredictionsChart.tsx +++ b/components/analytics/PredictionsChart.tsx @@ -29,6 +29,7 @@ import { Brain, Layers, Zap, + Info, } from "lucide-react"; import { useToast } from "@/hooks/use-toast"; import { Skeleton } from "@/components/ui/skeleton"; @@ -54,9 +55,15 @@ import { XAxis, YAxis, CartesianGrid, - Tooltip, + Tooltip as RechartsTooltip, ResponsiveContainer, } from "recharts"; +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/components/ui/tooltip"; interface PredictionsChartProps { timeRange?: number; @@ -230,132 +237,185 @@ export default function PredictionsChart({
{/* Sales Predictions */}
- - - - - Revenue Prediction - - - - {predictions.sales.predicted !== null ? ( -
-
- {formatGBP(predictions.sales.predicted)} -
-
- + + + + + Revenue Prediction + + + + {predictions.sales.predicted !== null ? ( +
+ + +
+ {formatGBP(predictions.sales.predicted)} +
+
+ +

Predicted daily average revenue for the next {daysAhead} days

+
+
+ +
+ + +
+ + {getConfidenceLabel(predictions.sales.confidence)} Confidence + {predictions.sales.confidenceScore !== undefined && ( + + ({Math.round(predictions.sales.confidenceScore * 100)}%) + + )} + +
+
+ +

Based on data consistency, historical accuracy, and model agreement

+
+
+ + {predictions.sales.aiModel?.used && ( + + +
+ + 🤖 AI Powered + {predictions.sales.aiModel.modelAccuracy !== undefined && ( + + ({Math.round(predictions.sales.aiModel.modelAccuracy * 100)}%) + + )} + +
+
+ +

Predictions generated using a Deep Learning Ensemble Model (TensorFlow.js)

+
+
)} - > - {getConfidenceLabel(predictions.sales.confidence)} Confidence - {predictions.sales.confidenceScore !== undefined && ( - - ({Math.round(predictions.sales.confidenceScore * 100)}%) - + {predictions.sales.trend && ( + + +
+ + {predictions.sales.trend.direction === "up" && ( + + )} + {predictions.sales.trend.direction === "down" && ( + + )} + {predictions.sales.trend.direction === "up" + ? "Trending Up" + : predictions.sales.trend.direction === "down" + ? "Trending Down" + : "Stable"} + +
+
+ +

Direction of the recent sales trend (slope analysis)

+
+
)} - - {predictions.sales.aiModel?.used && ( - - 🤖 AI Powered - {predictions.sales.aiModel.modelAccuracy !== undefined && ( - - ({Math.round(predictions.sales.aiModel.modelAccuracy * 100)}%) - - )} - - )} - {predictions.sales.trend && ( - - {predictions.sales.trend.direction === "up" && ( - - )} - {predictions.sales.trend.direction === "down" && ( - - )} - {predictions.sales.trend.direction === "up" - ? "Trending Up" - : predictions.sales.trend.direction === "down" - ? "Trending Down" - : "Stable"} - - )} - - Next {daysAhead} days - -
- {predictions.sales.predictedOrders && ( -
- ~{Math.round(predictions.sales.predictedOrders)}{" "} - orders + + Next {daysAhead} days +
- )} - {!predictions.sales.confidenceIntervals && - predictions.sales.minPrediction && - predictions.sales.maxPrediction && ( -
- Range: {formatGBP(predictions.sales.minPrediction)} -{" "} - {formatGBP(predictions.sales.maxPrediction)} + {predictions.sales.predictedOrders && ( +
+ ~{Math.round(predictions.sales.predictedOrders)}{" "} + orders
)} -
- ) : ( -
- {predictions.sales.message || - "Insufficient data for prediction"} -
- )} - - - - {/* Model Intelligence Card */} - - - - - Model Intelligence - - - -
-
- Architecture - - - Hybrid Ensemble (Deep Learning) - -
- {stockPredictions?.predictions && ( -
- Features - - Multi-Feature Enabled - + {!predictions.sales.confidenceIntervals && + predictions.sales.minPrediction && + predictions.sales.maxPrediction && ( +
+ Range: {formatGBP(predictions.sales.minPrediction)} -{" "} + {formatGBP(predictions.sales.maxPrediction)} +
+ )} +
+ ) : ( +
+ {predictions.sales.message || + "Insufficient data for prediction"}
)} -
- Optimization - - - Performance Tuned - + + + + {/* Model Intelligence Card */} + + + + + Model Intelligence + + + + + +

Technical details about the active prediction model

+
+
+
+
+ +
+
+ Architecture + + + + + Hybrid Ensemble (Deep Learning) + + + +

Combines LSTM Neural Networks with Statistical Methods (Holt-Winters, ARIMA)

+
+
+
+ {stockPredictions?.predictions && ( +
+ Features + + Multi-Feature Enabled + +
+ )} +
+ Optimization + + + Performance Tuned + +
+
+ Model automatically retrains with new sales data. +
-
- Model automatically retrains with new sales data. -
-
- - + + +
{/* Daily Predictions Chart */} @@ -404,7 +464,7 @@ export default function PredictionsChart({ axisLine={false} tickFormatter={(value) => `£${value}`} /> -