improve mutual friends graph performance

This commit is contained in:
pa
2025-12-13 23:26:32 +09:00
committed by Natsumi
parent 9d9805265a
commit 728434f336
2 changed files with 13 additions and 3 deletions

View File

@@ -287,7 +287,7 @@
if (!chartRef.value) {
return;
}
chartInstance = echarts.init(chartRef.value, chartTheme.value, { useDirtyRect: totalFriends.value > 1000 });
chartInstance = echarts.init(chartRef.value, chartTheme.value, { renderer: 'svg' });
chartInstance.on('click', handleChartNodeClick);
if (graphReady.value) {

View File

@@ -184,16 +184,23 @@ export function useMutualGraphChart({ cachedUsers, graphPayload }) {
function createChartOption(payload, force) {
const nodes = payload?.nodes ?? [];
const links = payload?.links ?? [];
const resolvedForce = force || computeForceOptions(nodes, links);
const labelMap = Object.create(null);
nodes.forEach((node) => {
if (node?.id) {
labelMap[node.id] = node.name || node.id;
}
});
const resolvedForce = {
...(force || {}),
layoutAnimation: false
};
return {
color: COLORS_PALETTE,
backgroundColor: 'transparent',
animation: false,
animationDuration: 0,
animationDurationUpdate: 0,
tooltip: {
trigger: 'item',
formatter: (params) => {
@@ -231,6 +238,9 @@ export function useMutualGraphChart({ cachedUsers, graphPayload }) {
legendHoverLink: false,
roam: true,
roamTrigger: 'global',
animation: false,
animationDuration: 0,
animationDurationUpdate: 0,
data: nodes,
links,
label: {
@@ -249,7 +259,7 @@ export function useMutualGraphChart({ cachedUsers, graphPayload }) {
opacity: 0.5
}
},
force,
force: resolvedForce,
itemStyle: {
borderColor: '#ffffff',
borderWidth: 1,