mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Fix: Fixed the issue that the graph could not display the grouping #4180 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -50,6 +50,9 @@ const ForceGraph = ({ data, show }: IProps) => {
|
|||||||
enterable: true,
|
enterable: true,
|
||||||
getContent: (e: IElementEvent, items: ElementDatum) => {
|
getContent: (e: IElementEvent, items: ElementDatum) => {
|
||||||
if (Array.isArray(items)) {
|
if (Array.isArray(items)) {
|
||||||
|
if (items.some((x) => x?.isCombo)) {
|
||||||
|
return `<p style="font-weight:600;color:red">${items?.[0]?.data?.label}</p>`;
|
||||||
|
}
|
||||||
let result = ``;
|
let result = ``;
|
||||||
items.forEach((item) => {
|
items.forEach((item) => {
|
||||||
result += `<section style="color:${TooltipColorMap[e['targetType'] as keyof typeof TooltipColorMap]};"><h3>${item?.id}</h3>`;
|
result += `<section style="color:${TooltipColorMap[e['targetType'] as keyof typeof TooltipColorMap]};"><h3>${item?.id}</h3>`;
|
||||||
|
|||||||
@ -63,12 +63,18 @@ export const isDataExist = (data: any) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const findCombo = (communities: string[]) => {
|
||||||
|
const combo = Array.isArray(communities) ? communities[0] : undefined;
|
||||||
|
return combo;
|
||||||
|
};
|
||||||
|
|
||||||
export const buildNodesAndCombos = (nodes: any[]) => {
|
export const buildNodesAndCombos = (nodes: any[]) => {
|
||||||
const combos: any[] = [];
|
const combos: any[] = [];
|
||||||
nodes.forEach((x) => {
|
nodes.forEach((x) => {
|
||||||
const combo = Array.isArray(x?.communities) ? x.communities[0] : undefined;
|
const combo = findCombo(x?.communities);
|
||||||
if (combo && combos.every((y) => y.data.label !== combo)) {
|
if (combo && combos.every((y) => y.data.label !== combo)) {
|
||||||
combos.push({
|
combos.push({
|
||||||
|
isCombo: true,
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
data: {
|
data: {
|
||||||
label: combo,
|
label: combo,
|
||||||
@ -80,7 +86,7 @@ export const buildNodesAndCombos = (nodes: any[]) => {
|
|||||||
const nextNodes = nodes.map((x) => {
|
const nextNodes = nodes.map((x) => {
|
||||||
return {
|
return {
|
||||||
...x,
|
...x,
|
||||||
combo: combos.find((y) => y.data.label === x.id)?.id,
|
combo: combos.find((y) => y.data.label === findCombo(x?.communities))?.id,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user