display player type in Sociogram in RGB

This commit is contained in:
2026-01-24 11:42:20 +01:00
parent 039b43be8e
commit 052065acf9
2 changed files with 130 additions and 6 deletions

View File

@@ -49,6 +49,7 @@ export const GraphComponent = () => {
const [showLikes, setShowLikes] = useState(true);
const [showDislikes, setShowDislikes] = useState(false);
const [popularity, setPopularity] = useState(false);
const [showPlayerType, setShowPlayerType] = useState(false);
const [mutuality, setMutuality] = useState(false);
const [showHelp, setShowHelp] = useState(false);
const { user, teams } = useSession();
@@ -95,6 +96,10 @@ export const GraphComponent = () => {
popularityLabel(!popularity);
setPopularity(!popularity);
}
function handlePlayerType() {
playerType(!showPlayerType);
setShowPlayerType(!showPlayerType);
}
function handleMutuality() {
colorMatches(!mutuality);
@@ -138,13 +143,25 @@ export const GraphComponent = () => {
setData({ nodes: data.nodes, edges: newEdges });
}
function playerType(popularity: boolean) {
const newNodes = data.nodes;
if (popularity) {
newNodes.forEach((node) => {
node.fill = node.data.playertype;
});
} else {
newNodes.forEach((node) => (node.fill = undefined));
}
setData({ nodes: newNodes, edges: data.edges });
}
function popularityLabel(popularity: boolean) {
const newNodes = data.nodes;
console.log(data.nodes);
if (popularity) {
newNodes.forEach(
(node) => (node.subLabel = `pop.: ${node.data.inDegree.toFixed(1)}`)
);
newNodes.forEach((node) => {
node.subLabel = `pop.: ${node.data.inDegree.toFixed(1)}`;
node.fill = node.data.playertype;
});
} else {
newNodes.forEach((node) => (node.subLabel = undefined));
}
@@ -305,6 +322,51 @@ export const GraphComponent = () => {
<span className="ml-1">popularity</span>
</label>
</div>
<div className="control">
<label className="checkbox">
<input
type="checkbox"
checked={showPlayerType}
onClick={handlePlayerType}
/>
<span className="ml-1">player type</span>
</label>
</div>
<div className="control pl-4">
{showPlayerType && (
<>
<p>RGB:</p>
<p
style={{
color: "red",
fontWeight: "bold",
paddingLeft: "1rem",
}}
>
handler
</p>
<p
style={{
color: "green",
fontWeight: "bold",
paddingLeft: "1rem",
}}
>
combi
</p>
<p
style={{
color: "blue",
fontWeight: "bold",
paddingLeft: "1rem",
}}
>
cutter
</p>
</>
)}
</div>
</div>
</div>
)}