mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 06:46:04 +02:00
fix mutual graph
This commit is contained in:
@@ -29,7 +29,6 @@ export const useChartsStore = defineStore('Charts', () => {
|
|||||||
const mutualGraphStatus = reactive({
|
const mutualGraphStatus = reactive({
|
||||||
isFetching: false,
|
isFetching: false,
|
||||||
hasFetched: false,
|
hasFetched: false,
|
||||||
fetchError: '',
|
|
||||||
completionNotified: false,
|
completionNotified: false,
|
||||||
friendSignature: 0,
|
friendSignature: 0,
|
||||||
needsRefetch: false,
|
needsRefetch: false,
|
||||||
@@ -103,7 +102,6 @@ export const useChartsStore = defineStore('Charts', () => {
|
|||||||
Object.assign(mutualGraphFetchState, createDefaultFetchState());
|
Object.assign(mutualGraphFetchState, createDefaultFetchState());
|
||||||
mutualGraphStatus.isFetching = false;
|
mutualGraphStatus.isFetching = false;
|
||||||
mutualGraphStatus.hasFetched = false;
|
mutualGraphStatus.hasFetched = false;
|
||||||
mutualGraphStatus.fetchError = '';
|
|
||||||
mutualGraphStatus.completionNotified = false;
|
mutualGraphStatus.completionNotified = false;
|
||||||
mutualGraphStatus.friendSignature = 0;
|
mutualGraphStatus.friendSignature = 0;
|
||||||
mutualGraphStatus.needsRefetch = false;
|
mutualGraphStatus.needsRefetch = false;
|
||||||
|
|||||||
@@ -75,7 +75,6 @@
|
|||||||
const chartRef = ref(null);
|
const chartRef = ref(null);
|
||||||
let chartInstance = null;
|
let chartInstance = null;
|
||||||
let resizeObserver = null;
|
let resizeObserver = null;
|
||||||
let lastRenderablePayload = null;
|
|
||||||
|
|
||||||
const isFetching = computed({
|
const isFetching = computed({
|
||||||
get: () => status.isFetching,
|
get: () => status.isFetching,
|
||||||
@@ -89,12 +88,6 @@
|
|||||||
status.hasFetched = val;
|
status.hasFetched = val;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const fetchError = computed({
|
|
||||||
get: () => status.fetchError,
|
|
||||||
set: (val) => {
|
|
||||||
status.fetchError = val;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const totalFriends = computed(() => friends.value.size);
|
const totalFriends = computed(() => friends.value.size);
|
||||||
const isOptOut = computed(() => Boolean(currentUser.value?.hasSharedConnectionsOptOut));
|
const isOptOut = computed(() => Boolean(currentUser.value?.hasSharedConnectionsOptOut));
|
||||||
@@ -181,9 +174,9 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
chartInstance = echarts.init(chartRef.value, chartTheme.value, { useDirtyRect: totalFriends.value > 1000 });
|
chartInstance = echarts.init(chartRef.value, chartTheme.value, { useDirtyRect: totalFriends.value > 1000 });
|
||||||
if (lastRenderablePayload) {
|
chartInstance.on('click', handleChartNodeClick);
|
||||||
updateChart(lastRenderablePayload);
|
|
||||||
} else if (graphReady.value) {
|
if (graphReady.value) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
updateChart(graphPayload.value);
|
updateChart(graphPayload.value);
|
||||||
}
|
}
|
||||||
@@ -286,7 +279,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
isFetching.value = true;
|
isFetching.value = true;
|
||||||
fetchError.value = '';
|
|
||||||
status.completionNotified = false;
|
status.completionNotified = false;
|
||||||
status.needsRefetch = false;
|
status.needsRefetch = false;
|
||||||
status.cancelRequested = false;
|
status.cancelRequested = false;
|
||||||
@@ -376,23 +368,13 @@
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastRenderablePayload = payload;
|
|
||||||
if (!chartInstance) {
|
if (!chartInstance) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
chartInstance.setOption(createChartOption(payload), true);
|
chartInstance.setOption(createChartOption(payload));
|
||||||
registerChartEvents();
|
|
||||||
nextTick(() => chartInstance?.resize());
|
nextTick(() => chartInstance?.resize());
|
||||||
}
|
}
|
||||||
|
|
||||||
function registerChartEvents() {
|
|
||||||
if (!chartInstance) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
chartInstance.off('click', handleChartNodeClick);
|
|
||||||
chartInstance.on('click', handleChartNodeClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleChartNodeClick(params) {
|
function handleChartNodeClick(params) {
|
||||||
if (params?.dataType !== 'node') {
|
if (params?.dataType !== 'node') {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -63,21 +63,17 @@ export function useMutualGraphChart({ cachedUsers, graphPayload }) {
|
|||||||
const links = [];
|
const links = [];
|
||||||
const linkKeys = new Set();
|
const linkKeys = new Set();
|
||||||
|
|
||||||
function ensureNode(id, name, rawUser) {
|
function ensureNode(id, name) {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const existing = nodes.get(id);
|
const existing = nodes.get(id);
|
||||||
if (existing) {
|
if (existing) {
|
||||||
if (!existing.rawUser && rawUser) {
|
|
||||||
existing.rawUser = rawUser;
|
|
||||||
}
|
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
const node = {
|
const node = {
|
||||||
id,
|
id,
|
||||||
name: name || id,
|
name: name || id
|
||||||
value: name || id
|
|
||||||
};
|
};
|
||||||
nodes.set(id, node);
|
nodes.set(id, node);
|
||||||
return node;
|
return node;
|
||||||
@@ -108,7 +104,7 @@ export function useMutualGraphChart({ cachedUsers, graphPayload }) {
|
|||||||
for (const [friendId, { friend, mutuals }] of mutualMap.entries()) {
|
for (const [friendId, { friend, mutuals }] of mutualMap.entries()) {
|
||||||
const friendRef = friend?.ref || cachedUsers.get(friendId);
|
const friendRef = friend?.ref || cachedUsers.get(friendId);
|
||||||
const friendName = friendRef?.displayName;
|
const friendName = friendRef?.displayName;
|
||||||
ensureNode(friendId, friendName, friendRef);
|
ensureNode(friendId, friendName);
|
||||||
|
|
||||||
for (const mutual of mutuals) {
|
for (const mutual of mutuals) {
|
||||||
if (!mutual?.id) {
|
if (!mutual?.id) {
|
||||||
@@ -137,7 +133,7 @@ export function useMutualGraphChart({ cachedUsers, graphPayload }) {
|
|||||||
node.symbolSize = size;
|
node.symbolSize = size;
|
||||||
node.label = {
|
node.label = {
|
||||||
show: true,
|
show: true,
|
||||||
formatter: `${displayName}`
|
formatter: displayName
|
||||||
};
|
};
|
||||||
node.itemStyle = {
|
node.itemStyle = {
|
||||||
...(node.itemStyle || {}),
|
...(node.itemStyle || {}),
|
||||||
@@ -205,14 +201,17 @@ export function useMutualGraphChart({ cachedUsers, graphPayload }) {
|
|||||||
roamTrigger: 'global',
|
roamTrigger: 'global',
|
||||||
data: nodes,
|
data: nodes,
|
||||||
links,
|
links,
|
||||||
animationThreshold: 1000,
|
|
||||||
label: {
|
label: {
|
||||||
position: 'right',
|
position: 'right'
|
||||||
formatter: '{b}'
|
|
||||||
},
|
},
|
||||||
symbol: 'circle',
|
symbol: 'circle',
|
||||||
emphasis: {
|
emphasis: {
|
||||||
focus: 'adjacency',
|
focus: 'adjacency',
|
||||||
|
scale: true,
|
||||||
|
itemStyle: {
|
||||||
|
borderWidth: 3,
|
||||||
|
opacity: 1
|
||||||
|
},
|
||||||
lineStyle: {
|
lineStyle: {
|
||||||
width: 5,
|
width: 5,
|
||||||
opacity: 0.5
|
opacity: 0.5
|
||||||
|
|||||||
Reference in New Issue
Block a user