import { useState } from 'react';
import {
BarChart,
Bar,
XAxis,
YAxis,
Tooltip,
ResponsiveContainer,
Cell,
CartesianGrid,
} from 'recharts';
import { lookupMedicalTerm } from '../utils/medicalDictionary';
const COLOR_POSITIVE = '#910505';
const COLOR_NEGATIVE = '#24a316';
/**
* Horizontal bar chart of SHAP values.
* Positive (risk-increasing) bars are red, negative (protective) are green.
*
* Props:
* chartData — Array of { feature: string, shap_value: number } sorted by
* |shap_value| descending (as returned by the backend).
* baseValue — Optional base (expected) value from the SHAP explainer.
* maxVisible — Maximum number of features to show before "Show All" (default 10).
*/
export default function ShapBarChart({ chartData, baseValue, maxVisible = 10 }) {
const [showAll, setShowAll] = useState(false);
if (!chartData || chartData.length === 0) {
return (