Components / AI Data Visualization
AI Confidence Gauge
A gauge chart showing AI prediction confidence levels with color gradients from red (low) to green (high).
Components / AI Data Visualization
A gauge chart showing AI prediction confidence levels with color gradients from red (low) to green (high).
Prediction Confidence
Install the core libraries required for this component.
npm install react"use client";
import React from "react";
interface ConfidenceGaugeProps {
score?: number;
label?: string;
}
export default function AIConfidenceGauge({
score = 92.4,
label = "Prediction Confidence"
}: ConfidenceGaugeProps) {
const radius = 60;
const stroke = 12;
const normalizedRadius = radius - stroke * 2;
const circumference = normalizedRadius * 2 * Math.PI;
const arcPercentage = 0.75; // 3/4 circle
const arcLength = circumference * arcPercentage;
const strokeDashoffset = arcLength - (score / 100) * arcLength;
return (
<div className="rounded-xl border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-950 p-8 shadow-sm w-full max-w-xs mx-auto flex flex-col items-center">
<div className="relative h-32 w-48 flex items-center justify-center overflow-hidden">
<svg height={radius * 2} width={radius * 2} className="-rotate-[225deg]">
<circle
stroke="currentColor"
fill="transparent"
strokeWidth={stroke}
strokeDasharray={`${arcLength} ${circumference}`}
style={{ strokeDashoffset: 0 }}
r={normalizedRadius}
cx={radius}
cy={radius}
className="text-zinc-100 dark:text-zinc-800"
/>
<circle
stroke="url(#gradient)"
fill="transparent"
strokeWidth={stroke}
strokeDasharray={`${arcLength} ${circumference}`}
style={{ strokeDashoffset }}
strokeLinecap="round"
r={normalizedRadius}
cx={radius}
cy={radius}
className="transition-all duration-1000 ease-out"
/>
<defs>
<linearGradient id="gradient" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" stopColor="#ef4444" />
<stop offset="50%" stopColor="#eab308" />
<stop offset="100%" stopColor="#10b981" />
</linearGradient>
</defs>
</svg>
<div className="absolute inset-0 flex flex-col items-center justify-center pt-4">
<span className="text-3xl font-black text-zinc-900 dark:text-zinc-100">{score}%</span>
<span className="text-[10px] font-black text-emerald-500 uppercase tracking-widest mt-1">OPTIMAL</span>
</div>
</div>
<p className="text-xs font-bold text-zinc-500 uppercase tracking-widest mt-2">{label}</p>
</div>
);
} "use client";
import React from "react";
interface ConfidenceGaugeProps {
score?: number;
label?: string;
}
export default function AIConfidenceGauge({
score = 92.4,
label = "Prediction Confidence"
}: ConfidenceGaugeProps) {
const radius = 60;
const stroke = 12;
const normalizedRadius = radius - stroke * 2;
const circumference = normalizedRadius * 2 * Math.PI;
const arcPercentage = 0.75; // 3/4 circle
const arcLength = circumference * arcPercentage;
const strokeDashoffset = arcLength - (score / 100) * arcLength;
return (
<div className="rounded-xl border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-950 p-8 shadow-sm w-full max-w-xs mx-auto flex flex-col items-center">
<div className="relative h-32 w-48 flex items-center justify-center overflow-hidden">
<svg height={radius * 2} width={radius * 2} className="-rotate-[225deg]">
<circle
stroke="currentColor"
fill="transparent"
strokeWidth={stroke}
strokeDasharray={`${arcLength} ${circumference}`}
style={{ strokeDashoffset: 0 }}
r={normalizedRadius}
cx={radius}
cy={radius}
className="text-zinc-100 dark:text-zinc-800"
/>
<circle
stroke="url(#gradient)"
fill="transparent"
strokeWidth={stroke}
strokeDasharray={`${arcLength} ${circumference}`}
style={{ strokeDashoffset }}
strokeLinecap="round"
r={normalizedRadius}
cx={radius}
cy={radius}
className="transition-all duration-1000 ease-out"
/>
<defs>
<linearGradient id="gradient" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" stopColor="#ef4444" />
<stop offset="50%" stopColor="#eab308" />
<stop offset="100%" stopColor="#10b981" />
</linearGradient>
</defs>
</svg>
<div className="absolute inset-0 flex flex-col items-center justify-center pt-4">
<span className="text-3xl font-black text-zinc-900 dark:text-zinc-100">{score}%</span>
<span className="text-[10px] font-black text-emerald-500 uppercase tracking-widest mt-1">OPTIMAL</span>
</div>
</div>
<p className="text-xs font-bold text-zinc-500 uppercase tracking-widest mt-2">{label}</p>
</div>
);
} Types and interfaces defined in this component.
interface ConfidenceGaugeProps {
score?: number;
label?: string;
} interface ConfidenceGaugeProps {
score?: number;
label?: string;
} Internal functions used to handle component logic.
| Function | Parameters |
|---|---|
| AIConfidenceGauge() | { score = 92.4, label = "Prediction Confidence" }: ConfidenceGaugeProps |
All variable declarations found in this component.
| Name | Kind | Value |
|---|---|---|
| radius | | 60 |
| stroke | | 12 |
| normalizedRadius | | radius - stroke * 2 |
| circumference | | normalizedRadius * 2 * Math.PI |
| arcPercentage | | 0.75; // 3/4 circle |
| arcLength | | circumference * arcPercentage |
| strokeDashoffset | | arcLength - (score / 100) * arcLength |
Every JSX/HTML tag used in this component, with usage count and source.
| Tag | Count | Type | Source |
|---|---|---|---|
| <linearGradient> | 1× | | Local / Inline |
| <circle> | 2× | | Native HTML |
| <defs> | 1× | | Native HTML |
| <div> | 3× | | Native HTML |
| <p> | 1× | | Native HTML |
| <span> | 2× | | Native HTML |
| <stop> | 3× | | Native HTML |
| <svg> | 1× | | Native HTML |