WIP: level capsule. However, one capsule is failed
This commit is contained in:
@@ -72,6 +72,8 @@ import ImgCapsule2 from '@/assets/capsule2.svg';
|
|||||||
import ImgCapsule3 from '@/assets/capsule3.svg';
|
import ImgCapsule3 from '@/assets/capsule3.svg';
|
||||||
import ImgCapsule4 from '@/assets/capsule4.svg';
|
import ImgCapsule4 from '@/assets/capsule4.svg';
|
||||||
|
|
||||||
|
const ImgCapsules = [ImgCapsule1, ImgCapsule2, ImgCapsule3, ImgCapsule4];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
const loadingStore = LoadingStore();
|
const loadingStore = LoadingStore();
|
||||||
@@ -351,7 +353,6 @@ export default {
|
|||||||
shape:"round-rectangle",
|
shape:"round-rectangle",
|
||||||
freq:node.freq,
|
freq:node.freq,
|
||||||
duration:node.duration,
|
duration:node.duration,
|
||||||
nodeImageUrl: ImgCapsule1,
|
|
||||||
backgroundOpacity: 0,
|
backgroundOpacity: 0,
|
||||||
borderOpacity: 0,
|
borderOpacity: 0,
|
||||||
}
|
}
|
||||||
@@ -399,12 +400,42 @@ export default {
|
|||||||
let graphId = document.getElementById('cy');
|
let graphId = document.getElementById('cy');
|
||||||
let mapData = type === 'processMap'? this.processMapData: this.bpmnData;
|
let mapData = type === 'processMap'? this.processMapData: this.bpmnData;
|
||||||
|
|
||||||
if(this[type].vertices.length !== 0){
|
if(this[type].vertices.length !== 0){
|
||||||
this.setNodesData(mapData);
|
this.setNodesData(mapData);
|
||||||
this.setEdgesData(mapData);
|
this.setEdgesData(mapData);
|
||||||
|
this.setActivityBgImage(mapData);
|
||||||
this.cytoscapeGraph = cytoscapeMap(mapData, this.dataLayerType, this.dataLayerOption, this.curveStyle, this.rank, graphId);
|
this.cytoscapeGraph = cytoscapeMap(mapData, this.dataLayerType, this.dataLayerOption, this.curveStyle, this.rank, graphId);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
setActivityBgImage(mapData) {
|
||||||
|
const nodes = mapData.nodes;
|
||||||
|
const groupSize = Math.floor(nodes.length / ImgCapsules.length);
|
||||||
|
let nodeOptionArr = [];
|
||||||
|
const leveledGroups = []; // 每一個level會使用不同的膠囊圖片
|
||||||
|
// 設定除了 start, end 的 node 顏色
|
||||||
|
// 找出 type activity's node
|
||||||
|
const activityNodeArray = nodes.filter(node => node.data.type === 'activity');
|
||||||
|
// 找出除了 start, end 以外所有的 node 的 option value
|
||||||
|
activityNodeArray.map(node => nodeOptionArr.push(node.data[this.dataLayerType][this.dataLayerOption]));
|
||||||
|
// 刪掉重複的元素,將node的option值從小到大排序(映對色階淺到深)
|
||||||
|
nodeOptionArr = [...new Set(nodeOptionArr)].sort((a, b) => a - b);
|
||||||
|
|
||||||
|
for(let i = 0; i < ImgCapsules.length; i++) {
|
||||||
|
const startIdx = i * groupSize;
|
||||||
|
const endIdx = (i === ImgCapsules.length - 1) ? activityNodeArray.length : startIdx + groupSize;
|
||||||
|
leveledGroups.push(nodeOptionArr.slice(startIdx, endIdx));
|
||||||
|
}
|
||||||
|
for(let level = 0; level < leveledGroups.length; level++) {
|
||||||
|
leveledGroups[level].map(option => {
|
||||||
|
const curNode = activityNodeArray.find(activityNode => activityNode.data[this.dataLayerType][this.dataLayerOption] === option);
|
||||||
|
curNode.data = {
|
||||||
|
...curNode.data,
|
||||||
|
nodeImageUrl: ImgCapsules[level],
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
const routeParams = this.$route.params;
|
const routeParams = this.$route.params;
|
||||||
|
|||||||
Reference in New Issue
Block a user