yangdx commited on
Commit
76a1f9d
·
1 Parent(s): 478c53e

Update color

Browse files
lightrag_webui/src/hooks/useLightragGraph.tsx CHANGED
@@ -17,13 +17,13 @@ const TYPE_SYNONYMS: Record<string, string> = {
17
  'unknown': 'unknown',
18
  '未知': 'unknown',
19
  'other': 'unknown',
20
-
21
  // category 类型及其同义词
22
  'category': 'category',
23
  '类别': 'category',
24
  'type': 'category',
25
  '分类': 'category',
26
-
27
  // organization 类型及其同义词
28
  'organization': 'organization',
29
  '组织': 'organization',
@@ -31,32 +31,32 @@ const TYPE_SYNONYMS: Record<string, string> = {
31
  'company': 'organization',
32
  '公司': 'organization',
33
  '机构': 'organization',
34
-
35
  // event 类型及其同义词
36
  'event': 'event',
37
  '事件': 'event',
38
  'activity': 'event',
39
  '活动': 'event',
40
-
41
  // person 类型及其同义词
42
  'person': 'person',
43
  '人物': 'person',
44
  'people': 'person',
45
  'human': 'person',
46
  '人': 'person',
47
-
48
  // animal 类型及其同义词
49
  'animal': 'animal',
50
  '动物': 'animal',
51
  'creature': 'animal',
52
  '生物': 'animal',
53
-
54
  // geo 类型及其同义词
55
  'geo': 'geo',
56
  '地理': 'geo',
57
  'geography': 'geo',
58
  '地域': 'geo',
59
-
60
  // location 类型及其同义词
61
  'location': 'location',
62
  '地点': 'location',
@@ -64,19 +64,19 @@ const TYPE_SYNONYMS: Record<string, string> = {
64
  'address': 'location',
65
  '位置': 'location',
66
  '地址': 'location',
67
-
68
  // technology 类型及其同义词
69
  'technology': 'technology',
70
  '技术': 'technology',
71
  'tech': 'technology',
72
  '科技': 'technology',
73
-
74
  // equipment 类型及其同义词
75
  'equipment': 'equipment',
76
  '设备': 'equipment',
77
  'device': 'equipment',
78
  '装备': 'equipment',
79
-
80
  // weapon 类型及其同义词
81
  'weapon': 'weapon',
82
  '武器': 'weapon',
@@ -96,12 +96,12 @@ const NODE_TYPE_COLORS: Record<string, string> = {
96
  'location': '#cf6d17', // Carrot
97
  'technology': '#b300b3', // Purple
98
  'equipment': '#2F4F4F', // DarkSlateGray
99
- 'weapon': '#0f558a', // NavyBlue
100
  };
101
 
102
  // Extended colors pool - Used for unknown node types
103
  const EXTENDED_COLORS = [
104
- '#4421af', // DeepPurple
105
  '#cd071e', // ChinaRed
106
  '#5a2c6d', // DeepViolet
107
  '#0000ff', // Blue
@@ -117,7 +117,7 @@ const EXTENDED_COLORS = [
117
 
118
  // Select color based on node type
119
  const getNodeColorByType = (nodeType: string | undefined): string => {
120
-
121
  const defaultColor = '#5D6D7E';
122
 
123
  const normalizedType = nodeType ? nodeType.toLowerCase() : 'unknown';
@@ -145,11 +145,11 @@ const getNodeColorByType = (nodeType: string | undefined): string => {
145
  .filter(([, color]) => !Object.values(NODE_TYPE_COLORS).includes(color))
146
  .map(([, color]) => color)
147
  );
148
-
149
  // Find and use the first unused extended color
150
  const unusedColor = EXTENDED_COLORS.find(color => !usedExtendedColors.has(color));
151
  const newColor = unusedColor || defaultColor;
152
-
153
  // Update color mapping
154
  const newMap = new Map(typeColorMap);
155
  newMap.set(normalizedType, newColor);
 
17
  'unknown': 'unknown',
18
  '未知': 'unknown',
19
  'other': 'unknown',
20
+
21
  // category 类型及其同义词
22
  'category': 'category',
23
  '类别': 'category',
24
  'type': 'category',
25
  '分类': 'category',
26
+
27
  // organization 类型及其同义词
28
  'organization': 'organization',
29
  '组织': 'organization',
 
31
  'company': 'organization',
32
  '公司': 'organization',
33
  '机构': 'organization',
34
+
35
  // event 类型及其同义词
36
  'event': 'event',
37
  '事件': 'event',
38
  'activity': 'event',
39
  '活动': 'event',
40
+
41
  // person 类型及其同义词
42
  'person': 'person',
43
  '人物': 'person',
44
  'people': 'person',
45
  'human': 'person',
46
  '人': 'person',
47
+
48
  // animal 类型及其同义词
49
  'animal': 'animal',
50
  '动物': 'animal',
51
  'creature': 'animal',
52
  '生物': 'animal',
53
+
54
  // geo 类型及其同义词
55
  'geo': 'geo',
56
  '地理': 'geo',
57
  'geography': 'geo',
58
  '地域': 'geo',
59
+
60
  // location 类型及其同义词
61
  'location': 'location',
62
  '地点': 'location',
 
64
  'address': 'location',
65
  '位置': 'location',
66
  '地址': 'location',
67
+
68
  // technology 类型及其同义词
69
  'technology': 'technology',
70
  '技术': 'technology',
71
  'tech': 'technology',
72
  '科技': 'technology',
73
+
74
  // equipment 类型及其同义词
75
  'equipment': 'equipment',
76
  '设备': 'equipment',
77
  'device': 'equipment',
78
  '装备': 'equipment',
79
+
80
  // weapon 类型及其同义词
81
  'weapon': 'weapon',
82
  '武器': 'weapon',
 
96
  'location': '#cf6d17', // Carrot
97
  'technology': '#b300b3', // Purple
98
  'equipment': '#2F4F4F', // DarkSlateGray
99
+ 'weapon': '#4421af', // DeepPurple
100
  };
101
 
102
  // Extended colors pool - Used for unknown node types
103
  const EXTENDED_COLORS = [
104
+ '#0f558a', // NavyBlue
105
  '#cd071e', // ChinaRed
106
  '#5a2c6d', // DeepViolet
107
  '#0000ff', // Blue
 
117
 
118
  // Select color based on node type
119
  const getNodeColorByType = (nodeType: string | undefined): string => {
120
+
121
  const defaultColor = '#5D6D7E';
122
 
123
  const normalizedType = nodeType ? nodeType.toLowerCase() : 'unknown';
 
145
  .filter(([, color]) => !Object.values(NODE_TYPE_COLORS).includes(color))
146
  .map(([, color]) => color)
147
  );
148
+
149
  // Find and use the first unused extended color
150
  const unusedColor = EXTENDED_COLORS.find(color => !usedExtendedColors.has(color));
151
  const newColor = unusedColor || defaultColor;
152
+
153
  // Update color mapping
154
  const newMap = new Map(typeColorMap);
155
  newMap.set(normalizedType, newColor);