WIP: createAllPaths

This commit is contained in:
Cindy Chang
2024-08-19 16:19:12 +08:00
parent 27d11997bd
commit 2de9a2b3e6
4 changed files with 53 additions and 10 deletions

View File

@@ -0,0 +1,34 @@
import { defineStore } from 'pinia';
import AllMapData from '@/stores/allMapData.js';
import { INSIGHTS_FIELDS_AND_LABELS } from '@/constants/constants';
import { elements } from 'chart.js';
export default defineStore('useMapPathStore', {
state: () => ({
clickedPath: [],
allMapData: AllMapData(),
cytoscape: null,
}),
actions: {
setCytoscape(cytoscape) {
this.cytoscape = cytoscape;
},
createAllPaths() {
const { insights } = this.allMapData;
for(let i = 0; i < INSIGHTS_FIELDS_AND_LABELS.length; i++) {
const curButton = insights[INSIGHTS_FIELDS_AND_LABELS[i][0]];
for(let listIndex = 0; listIndex < curButton.length; listIndex++) {
for(let nodeIndex = 0; nodeIndex < curButton[listIndex].length; nodeIndex++){
if(nodeIndex === 0) {
const startNodes = this.cytoscape.nodes().filter(function(elem) {
return elem.data('label').toLocaleLowerCase() === 'start';
// highlight between start node and first node
});
}
}
}
}
},
},
});