Skip to content

Commit 91dfc04

Browse files
[fix]知识图谱处理fontName review by qiw
1 parent c5102dd commit 91dfc04

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

src/common/overlay/knowledge-graph/format.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,9 @@ function getEdgeStyle(entity, style) {
100100
const types = JSON.parse(relationTypes || '[]');
101101
if (ids.includes(id) || types.includes(type)) {
102102
return {
103-
fontSize: compileFontSize(font.fontSize),
104-
fontFamily: font.fontName,
103+
fontSize: font.fontSize,
105104
fill: textColor,
106-
105+
...formatFontName(font.fontName),
107106
...formatFontStyle(font.fontStyle)
108107
};
109108
}
@@ -124,11 +123,10 @@ function getNodeStyle(entity, style) {
124123
if (ids.includes(id) || types.includes(labels[0])) {
125124
return {
126125
fillColor: color,
127-
fontSize: compileFontSize(font.fontSize),
128-
fontFamily: font.fontName,
126+
fontSize: font.fontSize,
129127
fill: textColor,
130128
size: size,
131-
// stroke: color,
129+
...formatFontName(font.fontName),
132130
...formatFontStyle(font.fontStyle)
133131
};
134132
}
@@ -153,18 +151,30 @@ function getNodeLabel(entity, captionField) {
153151
}
154152

155153
function formatFontStyle(fontStyle) {
156-
if (fontStyle === 1) {
157-
return { fontWeight: 600 };
154+
//TODO: fontStyle为0是plain
155+
if (fontStyle === 1 || fontStyle === 'bold') {
156+
return { fontWeight: 'bold' };
158157
}
159-
if (fontStyle === 2) {
158+
if (fontStyle === 2 || fontStyle === 'italic') {
160159
return { fontStyle: 'italic' };
161160
}
161+
if (fontStyle === 'bolditalic') {
162+
return { fontWeight: 'bold', fontStyle: 'italic' };
163+
}
162164
return {};
163165
}
164166

165-
function compileFontSize(fontSize) {
166-
return fontSize * 0.8;
167+
function formatFontName(fontName) {
168+
if (!fontName) {
169+
return {};
170+
}
171+
const arrs = fontName.split('.');
172+
return {
173+
fontFamily: arrs[0],
174+
...formatFontStyle(arrs[1])
175+
};
167176
}
177+
168178
// 处理graphMap数据的展开 折叠 隐藏的实体数据
169179
export function transformExpandCollapseHiddenData(graphMap) {
170180
const { expand, collapse, hidden } = graphMap.dataContent;

test/resources/knowledgeGraphService.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)