Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
components/SimulationGraph.tsx
CHANGED
|
@@ -7,10 +7,11 @@ import { GradioService } from '../services/gradioService';
|
|
| 7 |
interface SimulationGraphProps {
|
| 8 |
isBuilding: boolean;
|
| 9 |
societyType: string;
|
|
|
|
| 10 |
onStartChat?: () => void;
|
| 11 |
}
|
| 12 |
|
| 13 |
-
const SimulationGraph: React.FC<SimulationGraphProps> = ({ isBuilding, societyType, onStartChat }) => {
|
| 14 |
const graphDiv = useRef<HTMLDivElement>(null);
|
| 15 |
const [selectedProfile, setSelectedProfile] = useState<{ x: number, y: number, data: any } | null>(null);
|
| 16 |
|
|
@@ -87,7 +88,31 @@ const SimulationGraph: React.FC<SimulationGraphProps> = ({ isBuilding, societyTy
|
|
| 87 |
|
| 88 |
const nodeX = nodes.map(n => n.x);
|
| 89 |
const nodeY = nodes.map(n => n.y);
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
const edgeTrace = {
|
| 93 |
x: edgeX,
|
|
@@ -142,7 +167,7 @@ const SimulationGraph: React.FC<SimulationGraphProps> = ({ isBuilding, societyTy
|
|
| 142 |
};
|
| 143 |
|
| 144 |
renderGraph();
|
| 145 |
-
}, [isBuilding, societyType]);
|
| 146 |
|
| 147 |
return (
|
| 148 |
<div className="relative w-full h-full bg-black">
|
|
|
|
| 7 |
interface SimulationGraphProps {
|
| 8 |
isBuilding: boolean;
|
| 9 |
societyType: string;
|
| 10 |
+
viewMode: string;
|
| 11 |
onStartChat?: () => void;
|
| 12 |
}
|
| 13 |
|
| 14 |
+
const SimulationGraph: React.FC<SimulationGraphProps> = ({ isBuilding, societyType, viewMode, onStartChat }) => {
|
| 15 |
const graphDiv = useRef<HTMLDivElement>(null);
|
| 16 |
const [selectedProfile, setSelectedProfile] = useState<{ x: number, y: number, data: any } | null>(null);
|
| 17 |
|
|
|
|
| 88 |
|
| 89 |
const nodeX = nodes.map(n => n.x);
|
| 90 |
const nodeY = nodes.map(n => n.y);
|
| 91 |
+
|
| 92 |
+
// Determine node colors based on viewMode
|
| 93 |
+
const nodeColor = nodes.map(n => {
|
| 94 |
+
if (viewMode === 'Sentiment') {
|
| 95 |
+
const s = n.sentiment || 'Neutral';
|
| 96 |
+
if (s === 'Positive') return 1;
|
| 97 |
+
if (s === 'Negative') return 2;
|
| 98 |
+
if (s === 'Mixed') return 3;
|
| 99 |
+
return 0; // Neutral
|
| 100 |
+
}
|
| 101 |
+
if (viewMode === 'Activity Level') {
|
| 102 |
+
const a = n.activity || 'Lurker';
|
| 103 |
+
if (a === 'Power User') return 1;
|
| 104 |
+
if (a === 'Daily Active') return 2;
|
| 105 |
+
if (a === 'Weekly Active') return 3;
|
| 106 |
+
return 0;
|
| 107 |
+
}
|
| 108 |
+
if (viewMode === 'Job Title') {
|
| 109 |
+
// Assign numeric index based on role string hash or predefined mapping
|
| 110 |
+
const roles = ["Founder", "Product Manager", "Engineer", "Investor", "Designer"];
|
| 111 |
+
const idx = roles.indexOf(n.role);
|
| 112 |
+
return idx >= 0 ? idx : (n.role ? n.role.length % 5 : 0);
|
| 113 |
+
}
|
| 114 |
+
return n.connections || 0;
|
| 115 |
+
});
|
| 116 |
|
| 117 |
const edgeTrace = {
|
| 118 |
x: edgeX,
|
|
|
|
| 167 |
};
|
| 168 |
|
| 169 |
renderGraph();
|
| 170 |
+
}, [isBuilding, societyType, viewMode]);
|
| 171 |
|
| 172 |
return (
|
| 173 |
<div className="relative w-full h-full bg-black">
|
components/SimulationPage.tsx
CHANGED
|
@@ -318,7 +318,12 @@ const SimulationPage: React.FC<SimulationPageProps> = ({
|
|
| 318 |
|
| 319 |
{/* Graph Container */}
|
| 320 |
<div className="flex-1 w-full h-full">
|
| 321 |
-
<SimulationGraph
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
</div>
|
| 323 |
|
| 324 |
{/* Modals */}
|
|
|
|
| 318 |
|
| 319 |
{/* Graph Container */}
|
| 320 |
<div className="flex-1 w-full h-full">
|
| 321 |
+
<SimulationGraph
|
| 322 |
+
isBuilding={isBuilding}
|
| 323 |
+
societyType={society}
|
| 324 |
+
viewMode={viewMode}
|
| 325 |
+
onStartChat={onOpenChat}
|
| 326 |
+
/>
|
| 327 |
</div>
|
| 328 |
|
| 329 |
{/* Modals */}
|